1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

c++03 -> c++11 switch:

- use std versions of function, bind and ref
- OVERRIDE -> override
- NULL -> nullptr
- use std versions of random distributions

NOTE: this may be last revision that supports gcc-4.5
This commit is contained in:
Ivan Savenko
2013-06-26 11:18:27 +00:00
parent 1a2c8de6ad
commit 2b45e13c5c
110 changed files with 1523 additions and 1567 deletions

View File

@ -63,12 +63,12 @@ CBuildingRect::CBuildingRect(CCastleBuildings * Par, const CGTownInstance *Town,
if (!str->borderName.empty())
border = BitmapHandler::loadBitmap(str->borderName, true);
else
border = NULL;
border = nullptr;
if (!str->areaName.empty())
area = BitmapHandler::loadBitmap(str->areaName);
else
area = NULL;
area = nullptr;
}
CBuildingRect::~CBuildingRect()
@ -97,7 +97,7 @@ void CBuildingRect::hover(bool on)
if(parent->selectedBuilding == this)
{
parent->selectedBuilding = NULL;
parent->selectedBuilding = nullptr;
GH.statusbar->clear();
}
}
@ -237,7 +237,7 @@ void CBuildingRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
{
if(parent->selectedBuilding == this)
{
parent->selectedBuilding = NULL;
parent->selectedBuilding = nullptr;
GH.statusbar->clear();
}
}
@ -436,7 +436,7 @@ void CHeroGSlot::set(const CGHeroInstance *newHero)
else if(!upg && owner->showEmpty) //up garrison
image = new CAnimImage("CREST58", LOCPLINT->castleInt->town->getOwner().getNum(), 0, 0, 0);
else
image = NULL;
image = nullptr;
}
template <class ptr>
@ -456,7 +456,7 @@ SORTHELP<CStructure> structSorter;
CCastleBuildings::CCastleBuildings(const CGTownInstance* Town):
town(Town),
selectedBuilding(NULL)
selectedBuilding(nullptr)
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
@ -575,7 +575,7 @@ const CGHeroInstance* CCastleBuildings::getHero()
return town->visitingHero;
if (town->garrisonHero)
return town->garrisonHero;
return NULL;
return nullptr;
}
void CCastleBuildings::buildingClicked(BuildingID building)
@ -753,7 +753,7 @@ void CCastleBuildings::enterCastleGate()
for(size_t i=0;i<Towns.size();i++)
{
const CGTownInstance *t = Towns[i];
if (t->id != this->town->id && t->visitingHero == NULL && //another town, empty and this is
if (t->id != this->town->id && t->visitingHero == nullptr && //another town, empty and this is
t->hasBuilt(BuildingID::CASTLE_GATE, ETownType::INFERNO))
{
availableTowns.push_back(t->id.getNum());//add to the list
@ -761,7 +761,7 @@ void CCastleBuildings::enterCastleGate()
}
CPicture *titlePic = new CPicture (LOCPLINT->castleInt->bicons->ourImages[BuildingID::CASTLE_GATE].bitmap, 0,0, false);//will be deleted by selection window
GH.pushInt (new CObjectListWindow(availableTowns, titlePic, CGI->generaltexth->jktexts[40],
CGI->generaltexth->jktexts[41], boost::bind (&CCastleInterface::castleTeleport, LOCPLINT->castleInt, _1)));
CGI->generaltexth->jktexts[41], std::bind (&CCastleInterface::castleTeleport, LOCPLINT->castleInt, _1)));
}
void CCastleBuildings::enterDwelling(int level)
@ -833,7 +833,7 @@ void CCastleBuildings::enterTownHall()
else
{
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[673]);
(dynamic_cast<CInfoWindow*>(GH.topInt()))->buttons[0]->callback += boost::bind(&CCastleBuildings::openTownHall, this);
(dynamic_cast<CInfoWindow*>(GH.topInt()))->buttons[0]->callback += std::bind(&CCastleBuildings::openTownHall, this);
}
}
else
@ -854,8 +854,8 @@ void CCastleBuildings::openTownHall()
CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInstance * from):
CWindowObject(PLAYER_COLORED | BORDERED),
hall(NULL),
fort(NULL),
hall(nullptr),
fort(nullptr),
town(Town)
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
@ -876,12 +876,12 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst
income = new CLabel(195, 443, FONT_SMALL, CENTER);
icon = new CAnimImage("ITPT", 0, 0, 15, 387);
exit = new CAdventureMapButton(CGI->generaltexth->tcommands[8], "", boost::bind(&CCastleInterface::close,this), 744, 544, "TSBTNS", SDLK_RETURN);
exit = new CAdventureMapButton(CGI->generaltexth->tcommands[8], "", std::bind(&CCastleInterface::close,this), 744, 544, "TSBTNS", SDLK_RETURN);
exit->assignedKeys.insert(SDLK_ESCAPE);
exit->setOffset(4);
split = new CAdventureMapButton(CGI->generaltexth->tcommands[3], "", boost::bind(&CGarrisonInt::splitClick,garr), 744, 382, "TSBTNS.DEF");
split->callback += boost::bind(&HeroSlots::splitClicked, heroes);
split = new CAdventureMapButton(CGI->generaltexth->tcommands[3], "", std::bind(&CGarrisonInt::splitClick,garr), 744, 382, "TSBTNS.DEF");
split->callback += std::bind(&HeroSlots::splitClicked, heroes);
garr->addSplitBtn(split);
Rect barRect(9, 182, 732, 18);
@ -893,7 +893,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst
townlist->select(from);
townlist->select(town); //this will scroll list to select current town
townlist->onSelect = boost::bind(&CCastleInterface::townChange, this);
townlist->onSelect = std::bind(&CCastleInterface::townChange, this);
recreateIcons();
CCS->musich->playMusic(town->town->clientInfo.musicTheme, true);
@ -903,7 +903,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst
CCastleInterface::~CCastleInterface()
{
LOCPLINT->castleInt = NULL;
LOCPLINT->castleInt = nullptr;
delete bicons;
}
@ -987,8 +987,8 @@ CCreaInfo::CCreaInfo(Point position, const CGTownInstance *Town, int Level, bool
if ( town->creatures.size() <= level || town->creatures[level].second.empty())
{
level = -1;
label = NULL;
picture = NULL;
label = nullptr;
picture = nullptr;
return;//No creature
}
addUsedEvents(LCLICK | RCLICK | HOVER);
@ -1092,7 +1092,7 @@ void CCreaInfo::clickRight(tribool down, bool previousState)
CTownInfo::CTownInfo(int posX, int posY, const CGTownInstance* Town, bool townHall):
town(Town),
building(NULL)
building(nullptr)
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
addUsedEvents(RCLICK | HOVER);
@ -1298,7 +1298,7 @@ CHallInterface::CHallInterface(const CGTownInstance *Town):
title = new CLabel(399, 12, FONT_MEDIUM, CENTER, Colors::WHITE, town->town->buildings[BuildingID(town->hallLevel()+BuildingID::VILLAGE_HALL)]->Name());
exit = new CAdventureMapButton(CGI->generaltexth->hcommands[8], "",
boost::bind(&CHallInterface::close,this), 748, 556, "TPMAGE1.DEF", SDLK_RETURN);
std::bind(&CHallInterface::close,this), 748, 556, "TPMAGE1.DEF", SDLK_RETURN);
exit->assignedKeys.insert(SDLK_ESCAPE);
auto & boxList = town->town->clientInfo.hallSlots;
@ -1307,7 +1307,7 @@ CHallInterface::CHallInterface(const CGTownInstance *Town):
{
for(size_t col=0; col<boxList[row].size(); col++) //for each box
{
const CBuilding *building = NULL;
const CBuilding *building = nullptr;
for(size_t item=0; item<boxList[row][col].size(); item++)//we are looking for the first not build structure
{
auto buildingID = boxList[row][col][item];
@ -1391,12 +1391,12 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
if(!rightClick)
{ //normal window
buy = new CAdventureMapButton(boost::str(boost::format(CGI->generaltexth->allTexts[595]) % building->Name()),
"", boost::bind(&CBuildWindow::buyFunc,this), 45, 446,"IBUY30", SDLK_RETURN);
"", std::bind(&CBuildWindow::buyFunc,this), 45, 446,"IBUY30", SDLK_RETURN);
buy->borderColor = Colors::METALLIC_GOLD;
buy->borderEnabled = true;
cancel = new CAdventureMapButton(boost::str(boost::format(CGI->generaltexth->allTexts[596]) % building->Name()),
"", boost::bind(&CBuildWindow::close,this), 290, 445, "ICANCEL", SDLK_ESCAPE);
"", std::bind(&CBuildWindow::close,this), 290, 445, "ICANCEL", SDLK_ESCAPE);
cancel->borderColor = Colors::METALLIC_GOLD;
cancel->borderEnabled = true;
buy->block(state!=7 || LOCPLINT->playerID != town->tempOwner);
@ -1428,7 +1428,7 @@ CFortScreen::CFortScreen(const CGTownInstance * town):
title = new CLabel(400, 12, FONT_BIG, CENTER, Colors::WHITE, fortBuilding->Name());
std::string text = boost::str(boost::format(CGI->generaltexth->fcommands[6]) % fortBuilding->Name());
exit = new CAdventureMapButton(text, "", boost::bind(&CFortScreen::close,this) ,748, 556, "TPMAGE1", SDLK_RETURN);
exit = new CAdventureMapButton(text, "", std::bind(&CFortScreen::close,this) ,748, 556, "TPMAGE1", SDLK_RETURN);
exit->assignedKeys.insert(SDLK_ESCAPE);
std::vector<Point> positions;
@ -1518,7 +1518,7 @@ void LabeledValue::hover(bool on)
CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *Town, BuildingID buildingID, int Level):
town(Town),
level(Level),
availableCount(NULL)
availableCount(nullptr)
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
pos.x +=posX;
@ -1532,7 +1532,7 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
icons = new CPicture("TPCAINFO", 261, 3);
buildingPic = new CAnimImage(town->town->clientInfo.buildingsIcons, buildingID, 0, 4, 21);
const CCreature* creature = NULL;
const CCreature* creature = nullptr;
if (!town->creatures[level].second.empty())
creature = CGI->creh->creatures[town->creatures[level].second.back()];
@ -1608,7 +1608,7 @@ CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner):
Rect barRect(7, 556, 737, 18);
statusBar = new CGStatusBar(new CPicture(*background, barRect, 7, 556, false));
exit = new CAdventureMapButton(CGI->generaltexth->allTexts[593],"",boost::bind(&CMageGuildScreen::close,this), 748, 556,"TPMAGE1.DEF",SDLK_RETURN);
exit = new CAdventureMapButton(CGI->generaltexth->allTexts[593],"",std::bind(&CMageGuildScreen::close,this), 748, 556,"TPMAGE1.DEF",SDLK_RETURN);
exit->assignedKeys.insert(SDLK_ESCAPE);
std::vector<std::vector<Point> > positions;
@ -1685,10 +1685,10 @@ CBlacksmithDialog::CBlacksmithDialog(bool possible, CreatureID creMachineID, Art
boost::lexical_cast<std::string>(CGI->arth->artifacts[aid]->price));
std::string text = boost::str(boost::format(CGI->generaltexth->allTexts[595]) % creature->nameSing);
buy = new CAdventureMapButton(text,"",boost::bind(&CBlacksmithDialog::close, this), 42, 312,"IBUY30.DEF",SDLK_RETURN);
buy = new CAdventureMapButton(text,"",std::bind(&CBlacksmithDialog::close, this), 42, 312,"IBUY30.DEF",SDLK_RETURN);
text = boost::str(boost::format(CGI->generaltexth->allTexts[596]) % creature->nameSing);
cancel = new CAdventureMapButton(text,"",boost::bind(&CBlacksmithDialog::close, this), 224, 312,"ICANCEL.DEF",SDLK_ESCAPE);
cancel = new CAdventureMapButton(text,"",std::bind(&CBlacksmithDialog::close, this), 224, 312,"ICANCEL.DEF",SDLK_ESCAPE);
if(possible)
buy->callback += [=]{ LOCPLINT->cb->buyArtifact(LOCPLINT->cb->getHero(hid),aid); };