mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
- Refactoring for checking victory/loss conditions (use enum class instead of magic numbers)
- Improved showing player lost message for one special case
This commit is contained in:
@@ -292,7 +292,7 @@ void ChangeObjPos::applyCl( CClient *cl )
|
||||
|
||||
void PlayerEndsGame::applyCl( CClient *cl )
|
||||
{
|
||||
CALL_IN_ALL_INTERFACES(gameOver, player, victory);
|
||||
CALL_IN_ALL_INTERFACES(gameOver, player, victoryLossCheckResult);
|
||||
}
|
||||
|
||||
void RemoveBonus::applyCl( CClient *cl )
|
||||
@@ -409,30 +409,30 @@ void NewStructures::applyCl( CClient *cl )
|
||||
{
|
||||
CGTownInstance *town = GS(cl)->getTown(tid);
|
||||
for(const auto & id : bid)
|
||||
{
|
||||
if(id == BuildingID::CAPITOL) //fort or capitol
|
||||
{
|
||||
town->defInfo = const_cast<CGDefInfo*>(CGI->dobjinfo->capitols.at(town->subID).get());
|
||||
}
|
||||
if(id == BuildingID::FORT)
|
||||
{
|
||||
town->defInfo = const_cast<CGDefInfo*>(CGI->dobjinfo->gobjs.at(Obj::TOWN).at(town->subID).get());
|
||||
}
|
||||
if(vstd::contains(cl->playerint,town->tempOwner))
|
||||
cl->playerint[town->tempOwner]->buildChanged(town,id,1);
|
||||
{
|
||||
if(id == BuildingID::CAPITOL) //fort or capitol
|
||||
{
|
||||
town->defInfo = const_cast<CGDefInfo*>(CGI->dobjinfo->capitols.at(town->subID).get());
|
||||
}
|
||||
if(id == BuildingID::FORT)
|
||||
{
|
||||
town->defInfo = const_cast<CGDefInfo*>(CGI->dobjinfo->gobjs.at(Obj::TOWN).at(town->subID).get());
|
||||
}
|
||||
if(vstd::contains(cl->playerint,town->tempOwner))
|
||||
cl->playerint[town->tempOwner]->buildChanged(town,id,1);
|
||||
}
|
||||
}
|
||||
void RazeStructures::applyCl (CClient *cl)
|
||||
{
|
||||
CGTownInstance *town = GS(cl)->getTown(tid);
|
||||
for(const auto & id : bid)
|
||||
{
|
||||
if (id == BuildingID::CAPITOL) //fort or capitol
|
||||
{
|
||||
town->defInfo = const_cast<CGDefInfo*>(CGI->dobjinfo->gobjs.at(Obj::TOWN).at(town->subID).get());
|
||||
}
|
||||
if(vstd::contains (cl->playerint,town->tempOwner))
|
||||
cl->playerint[town->tempOwner]->buildChanged (town,id,2);
|
||||
{
|
||||
if (id == BuildingID::CAPITOL) //fort or capitol
|
||||
{
|
||||
town->defInfo = const_cast<CGDefInfo*>(CGI->dobjinfo->gobjs.at(Obj::TOWN).at(town->subID).get());
|
||||
}
|
||||
if(vstd::contains (cl->playerint,town->tempOwner))
|
||||
cl->playerint[town->tempOwner]->buildChanged (town,id,2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,13 +532,13 @@ void InfoWindow::applyCl( CClient *cl )
|
||||
comps.push_back(&elem);
|
||||
}
|
||||
std::string str;
|
||||
text.toString(str);
|
||||
|
||||
if(vstd::contains(cl->playerint,player))
|
||||
cl->playerint.at(player)->showInfoDialog(str,comps,(soundBase::soundID)soundID);
|
||||
else
|
||||
logNetwork->warnStream() << "We received InfoWindow for not our player...";
|
||||
}
|
||||
text.toString(str);
|
||||
|
||||
if(vstd::contains(cl->playerint,player))
|
||||
cl->playerint.at(player)->showInfoDialog(str,comps,(soundBase::soundID)soundID);
|
||||
else
|
||||
logNetwork->warnStream() << "We received InfoWindow for not our player...";
|
||||
}
|
||||
|
||||
void SetObjectProperty::applyCl( CClient *cl )
|
||||
{
|
||||
@@ -575,26 +575,26 @@ void CommanderLevelUp::applyCl( CClient *cl )
|
||||
void BlockingDialog::applyCl( CClient *cl )
|
||||
{
|
||||
std::string str;
|
||||
text.toString(str);
|
||||
|
||||
if(vstd::contains(cl->playerint,player))
|
||||
cl->playerint.at(player)->showBlockingDialog(str,components,queryID,(soundBase::soundID)soundID,selection(),cancel());
|
||||
else
|
||||
logNetwork->warnStream() << "We received YesNoDialog for not our player...";
|
||||
}
|
||||
text.toString(str);
|
||||
|
||||
if(vstd::contains(cl->playerint,player))
|
||||
cl->playerint.at(player)->showBlockingDialog(str,components,queryID,(soundBase::soundID)soundID,selection(),cancel());
|
||||
else
|
||||
logNetwork->warnStream() << "We received YesNoDialog for not our player...";
|
||||
}
|
||||
|
||||
void GarrisonDialog::applyCl(CClient *cl)
|
||||
{
|
||||
const CGHeroInstance *h = cl->getHero(hid);
|
||||
const CArmedInstance *obj = static_cast<const CArmedInstance*>(cl->getObj(objid));
|
||||
|
||||
if(!vstd::contains(cl->playerint,h->getOwner()))
|
||||
return;
|
||||
|
||||
cl->playerint.at(h->getOwner())->showGarrisonDialog(obj,h,removableUnits,queryID);
|
||||
}
|
||||
|
||||
void ExchangeDialog::applyCl(CClient *cl)
|
||||
if(!vstd::contains(cl->playerint,h->getOwner()))
|
||||
return;
|
||||
|
||||
cl->playerint.at(h->getOwner())->showGarrisonDialog(obj,h,removableUnits,queryID);
|
||||
}
|
||||
|
||||
void ExchangeDialog::applyCl(CClient *cl)
|
||||
{
|
||||
assert(heroes[0] && heroes[1]);
|
||||
INTERFACE_CALL_IF_PRESENT(heroes[0]->tempOwner, heroExchangeStarted, heroes[0]->id, heroes[1]->id, queryID);
|
||||
@@ -945,13 +945,13 @@ void SetAvailableArtifacts::applyCl(CClient *cl)
|
||||
INTERFACE_CALL_IF_PRESENT(cl->getTile(bm->visitablePos())->visitableObjects.back()->tempOwner, availableArtifactsChanged, bm);
|
||||
}
|
||||
}
|
||||
|
||||
void TradeComponents::applyCl(CClient *cl)
|
||||
{///Shop handler
|
||||
switch (CGI->mh->map->objects.at(objectid)->ID)
|
||||
{
|
||||
case Obj::BLACK_MARKET:
|
||||
break;
|
||||
|
||||
void TradeComponents::applyCl(CClient *cl)
|
||||
{///Shop handler
|
||||
switch (CGI->mh->map->objects.at(objectid)->ID)
|
||||
{
|
||||
case Obj::BLACK_MARKET:
|
||||
break;
|
||||
case Obj::TAVERN:
|
||||
break;
|
||||
case Obj::DEN_OF_THIEVES:
|
||||
|
||||
Reference in New Issue
Block a user