1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Rewritten many parts of query handling. Fixed several scenarios leading to a hang (including #1012). Purged boost::function from player interface (handy but impossible to serialize). VCAI will keep description for each unanswered query, so the further debugging will be easier.

This commit is contained in:
Michał W. Urbańczyk
2012-07-15 15:34:00 +00:00
parent ab0a384d31
commit edccbd4809
21 changed files with 219 additions and 104 deletions

View File

@@ -528,13 +528,14 @@ void SetObjectProperty::applyCl( CClient *cl )
void HeroLevelUp::applyCl( CClient *cl )
{
CGHeroInstance *h = GS(cl)->getHero(heroid);
const CGHeroInstance *h = cl->getHero(heroid);
//INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroGotLevel, h, primskill, skills, id);
if(vstd::contains(cl->playerint,h->tempOwner))
{
boost::function<void(ui32)> callback = boost::function<void(ui32)>(boost::bind(&CCallback::selectionMade,cl->callbacks[h->tempOwner].get(),_1,id));
cl->playerint[h->tempOwner]->heroGotLevel(const_cast<const CGHeroInstance*>(h),static_cast<int>(primskill),skills, callback);
cl->playerint[h->tempOwner]->heroGotLevel(h, static_cast<int>(primskill), skills, queryID);
}
}
void CommanderLevelUp::applyCl( CClient *cl )
{
CCommanderInstance * commander = GS(cl)->getHero(heroid)->commander;
@@ -542,8 +543,7 @@ void CommanderLevelUp::applyCl( CClient *cl )
ui8 player = commander->armyObj->tempOwner;
if (commander->armyObj && vstd::contains(cl->playerint, player)) //is it possible for Commander to exist beyond armed instance?
{
auto callback = boost::function<void(ui32)>(boost::bind(&CCallback::selectionMade,cl->callbacks[player].get(),_1,id));
cl->playerint[player]->commanderGotLevel(commander, skills, callback);
cl->playerint[player]->commanderGotLevel(commander, skills, queryID);
}
}
@@ -553,7 +553,7 @@ void BlockingDialog::applyCl( CClient *cl )
text.toString(str);
if(vstd::contains(cl->playerint,player))
cl->playerint[player]->showBlockingDialog(str,components,id,(soundBase::soundID)soundID,selection(),cancel());
cl->playerint[player]->showBlockingDialog(str,components,queryID,(soundBase::soundID)soundID,selection(),cancel());
else
tlog2 << "We received YesNoDialog for not our player...\n";
}
@@ -566,8 +566,7 @@ void GarrisonDialog::applyCl(CClient *cl)
if(!vstd::contains(cl->playerint,h->getOwner()))
return;
boost::function<void()> callback = boost::bind(&CCallback::selectionMade,cl->callbacks[h->getOwner()].get(),0,id);
cl->playerint[h->getOwner()]->showGarrisonDialog(obj,h,removableUnits,callback);
cl->playerint[h->getOwner()]->showGarrisonDialog(obj,h,removableUnits,queryID);
}
void BattleStart::applyCl( CClient *cl )