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

Completely remove IGameCallback class

- CClient now inherits directly from CPrivilegedInfoCallback, like
IGameCallback did before. However CClient no longer needs dummy
implementation of IGameEventCallback
- CGObjectInstance hierarchy now uses CPrivilegedInfoCallback for
callback. Actual events can only be emitted in calls that receive
IGameEventCallback pointer, e.g. heroVisit
- CGameHandler now inherits directly from both CPrivilegedInfoCallback
and IGameEventCallback as it did before via IGameCallback
This commit is contained in:
Ivan Savenko
2025-05-13 15:24:45 +03:00
parent f7d08a7288
commit 716da918f8
109 changed files with 854 additions and 933 deletions

View File

@@ -549,7 +549,7 @@ void CGameHandler::init(StartInfo *si, Load::ProgressAccumulator & progressTrack
gs = std::make_shared<CGameState>(this);
gs->preInit(LIBRARY);
logGlobal->info("Gamestate created!");
gs->init(&mapService, si, progressTracking);
gs->init(&mapService, si, getRandomGenerator(), progressTracking);
logGlobal->info("Gamestate initialized!");
for (const auto & elem : gameState().players)
@@ -703,7 +703,7 @@ void CGameHandler::onNewTurn()
for (auto & elem : gameState().getMap().getObjects())
{
if (elem)
elem->newTurn(getRandomGenerator());
elem->newTurn(*this);
}
synchronizeArtifactHandlerLists(); //new day events may have changed them. TODO better of managing that
@@ -914,7 +914,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, EMovementMode moveme
auto leaveTile = [&]()
{
for(const auto & objID : gameState().getMap().getTile(h->visitablePos()).visitableObjects)
gameState().getObjInstance(objID)->onHeroLeave(h);
gameState().getObjInstance(objID)->onHeroLeave(*this, h);
this->getTilesInRange(tmh.fowRevealed, h->getSightCenter()+(tmh.end-tmh.start), h->getSightRadius(), ETileVisibility::HIDDEN, h->tempOwner);
};
@@ -2539,7 +2539,7 @@ bool CGameHandler::swapGarrisonOnSiege(ObjectInstanceID tid)
else //visiting -> garrison
{
if(town->armedGarrison())
town->mergeGarrisonOnSiege();
town->mergeGarrisonOnSiege(*this);
intown.visiting = ObjectInstanceID();
intown.garrison = town->getVisitingHero()->id;
@@ -3448,7 +3448,7 @@ void CGameHandler::objectVisited(const CGObjectInstance * obj, const CGHeroInsta
hv.starting = true;
sendAndApply(hv);
obj->onHeroVisit(h);
obj->onHeroVisit(*this, h);
};
ObjectVisitStarted::defaultExecute(serverEventBus.get(), startVisit, h->tempOwner, h->id, obj->id);
@@ -4323,7 +4323,7 @@ void CGameHandler::createHole(const int3 & visitablePosition, PlayerColor initia
void CGameHandler::newObject(std::shared_ptr<CGObjectInstance> object, PlayerColor initiator)
{
object->initObj(gameState().getRandomGenerator());
object->initObj(getRandomGenerator());
NewObject no;
no.newObject = object;