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

Use variant identifier in netpacks where applicable

This commit is contained in:
Ivan Savenko
2023-11-06 18:27:16 +02:00
parent 63e99a32d7
commit 6b81012f31
54 changed files with 391 additions and 304 deletions

View File

@@ -350,15 +350,16 @@ void ApplyClientNetPackVisitor::visitGiveBonus(GiveBonus & pack)
cl.invalidatePaths();
switch(pack.who)
{
case GiveBonus::ETarget::HERO:
case GiveBonus::ETarget::OBJECT:
{
const CGHeroInstance *h = gs.getHero(ObjectInstanceID(pack.id));
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroBonusChanged, h, pack.bonus, true);
const CGHeroInstance *h = gs.getHero(pack.id.as<ObjectInstanceID>());
if (h)
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroBonusChanged, h, pack.bonus, true);
}
break;
case GiveBonus::ETarget::PLAYER:
{
callInterfaceIfPresent(cl, PlayerColor(pack.id), &IGameEventsReceiver::playerBonusChanged, pack.bonus, true);
callInterfaceIfPresent(cl, pack.id.as<PlayerColor>(), &IGameEventsReceiver::playerBonusChanged, pack.bonus, true);
}
break;
}
@@ -433,16 +434,17 @@ void ApplyClientNetPackVisitor::visitRemoveBonus(RemoveBonus & pack)
cl.invalidatePaths();
switch(pack.who)
{
case GiveBonus::ETarget::HERO:
case GiveBonus::ETarget::OBJECT:
{
const CGHeroInstance *h = gs.getHero(ObjectInstanceID(pack.whoID));
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroBonusChanged, h, pack.bonus, false);
const CGHeroInstance *h = gs.getHero(pack.whoID.as<ObjectInstanceID>());
if (h)
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroBonusChanged, h, pack.bonus, false);
}
break;
case GiveBonus::ETarget::PLAYER:
{
//const PlayerState *p = gs.getPlayerState(pack.id);
callInterfaceIfPresent(cl, PlayerColor(pack.whoID), &IGameEventsReceiver::playerBonusChanged, pack.bonus, false);
callInterfaceIfPresent(cl, pack.whoID.as<PlayerColor>(), &IGameEventsReceiver::playerBonusChanged, pack.bonus, false);
}
break;
}