mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
Remove type registration from library pack applying
This commit is contained in:
parent
b84af1a6de
commit
232a759db7
@ -349,7 +349,7 @@ void CClient::installNewBattleInterface(std::shared_ptr<CBattleGameInterface> ba
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::handlePack(CPack * pack)
|
||||
void CClient::handlePack(CPackForClient * pack)
|
||||
{
|
||||
ApplyClientNetPackVisitor afterVisitor(*this, *gameState());
|
||||
ApplyFirstClientNetPackVisitor beforeVisitor(*this, *gameState());
|
||||
|
@ -147,7 +147,7 @@ public:
|
||||
|
||||
static ThreadSafeVector<int> waitingRequest; //FIXME: make this normal field (need to join all threads before client destruction)
|
||||
|
||||
void handlePack(CPack * pack); //applies the given pack and deletes it
|
||||
void handlePack(CPackForClient * pack); //applies the given pack and deletes it
|
||||
int sendRequest(const CPackForServer * request, PlayerColor player); //returns ID given to that request
|
||||
|
||||
void battleStarted(const BattleInfo * info);
|
||||
|
@ -45,12 +45,11 @@
|
||||
#include "../mapping/CMapService.h"
|
||||
#include "../modding/IdentifierStorage.h"
|
||||
#include "../modding/ModScope.h"
|
||||
#include "../networkPacks/NetPacksBase.h"
|
||||
#include "../pathfinder/CPathfinder.h"
|
||||
#include "../pathfinder/PathfinderOptions.h"
|
||||
#include "../registerTypes/RegisterTypesClientPacks.h"
|
||||
#include "../rmg/CMapGenerator.h"
|
||||
#include "../serializer/CMemorySerializer.h"
|
||||
#include "../serializer/CTypeList.h"
|
||||
#include "../spells/CSpellHandler.h"
|
||||
|
||||
#include <vstd/RNG.h>
|
||||
@ -59,29 +58,6 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
boost::shared_mutex CGameState::mutex;
|
||||
|
||||
template <typename T> class CApplyOnGS;
|
||||
|
||||
class CBaseForGSApply
|
||||
{
|
||||
public:
|
||||
virtual void applyOnGS(CGameState *gs, CPack * pack) const =0;
|
||||
virtual ~CBaseForGSApply() = default;
|
||||
template<typename U> static CBaseForGSApply *getApplier(const U * t=nullptr)
|
||||
{
|
||||
return new CApplyOnGS<U>();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> class CApplyOnGS : public CBaseForGSApply
|
||||
{
|
||||
public:
|
||||
void applyOnGS(CGameState *gs, CPack * pack) const override
|
||||
{
|
||||
T *ptr = static_cast<T*>(pack);
|
||||
ptr->applyGs(gs);
|
||||
}
|
||||
};
|
||||
|
||||
HeroTypeID CGameState::pickNextHeroType(const PlayerColor & owner)
|
||||
{
|
||||
const PlayerSettings &ps = scenarioOps->getIthPlayersSettings(owner);
|
||||
@ -165,8 +141,6 @@ CGameState::CGameState()
|
||||
{
|
||||
gs = this;
|
||||
heroesPool = std::make_unique<TavernHeroesPool>();
|
||||
applier = std::make_shared<CApplier<CBaseForGSApply>>();
|
||||
registerTypesClientPacks(*applier);
|
||||
globalEffects.setNodeType(CBonusSystemNode::GLOBAL_EFFECTS);
|
||||
}
|
||||
|
||||
@ -1146,10 +1120,9 @@ PlayerRelations CGameState::getPlayerRelations( PlayerColor color1, PlayerColor
|
||||
return PlayerRelations::ENEMIES;
|
||||
}
|
||||
|
||||
void CGameState::apply(CPack *pack)
|
||||
void CGameState::apply(CPackForClient *pack)
|
||||
{
|
||||
ui16 typ = CTypeList::getInstance().getTypeID(pack);
|
||||
applier->getApplier(typ)->applyOnGS(this, pack);
|
||||
pack->applyGs(this);
|
||||
}
|
||||
|
||||
void CGameState::calculatePaths(const CGHeroInstance *hero, CPathsInfo &out)
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
/// picks next free hero type of the H3 hero init sequence -> chosen starting hero, then unused hero type randomly
|
||||
HeroTypeID pickNextHeroType(const PlayerColor & owner);
|
||||
|
||||
void apply(CPack *pack);
|
||||
void apply(CPackForClient *pack);
|
||||
BattleField battleGetBattlefieldType(int3 tile, vstd::RNG & rand);
|
||||
|
||||
void fillUpgradeInfo(const CArmedInstance *obj, SlotID stackPos, UpgradeInfo &out) const override;
|
||||
@ -215,7 +215,6 @@ private:
|
||||
UpgradeInfo fillUpgradeInfo(const CStackInstance &stack) const;
|
||||
|
||||
// ---- data -----
|
||||
std::shared_ptr<CApplier<CBaseForGSApply>> applier;
|
||||
Services * services;
|
||||
|
||||
/// Pointer to campaign state manager. Nullptr for single scenarios
|
||||
|
@ -34,9 +34,6 @@ struct DLL_LINKAGE CPack : public Serializeable
|
||||
throw std::runtime_error("CPack serialized... this should not happen!");
|
||||
}
|
||||
|
||||
void applyGs(CGameState * gs)
|
||||
{}
|
||||
|
||||
void visit(ICPackVisitor & cpackVisitor);
|
||||
|
||||
protected:
|
||||
@ -53,6 +50,8 @@ protected:
|
||||
|
||||
struct DLL_LINKAGE CPackForClient : public CPack
|
||||
{
|
||||
virtual void applyGs(CGameState * gs) = 0;
|
||||
|
||||
protected:
|
||||
void visitBasic(ICPackVisitor & cpackVisitor) override;
|
||||
};
|
||||
|
@ -826,7 +826,7 @@ void LobbyPvPAction::visitTyped(ICPackVisitor & visitor)
|
||||
visitor.visitLobbyPvPAction(*this);
|
||||
}
|
||||
|
||||
void SetResources::applyGs(CGameState * gs) const
|
||||
void SetResources::applyGs(CGameState *gs)
|
||||
{
|
||||
assert(player.isValidPlayer());
|
||||
if(abs)
|
||||
@ -841,14 +841,14 @@ void SetResources::applyGs(CGameState * gs) const
|
||||
gs->getPlayerState(player)->resources.positive();
|
||||
}
|
||||
|
||||
void SetPrimSkill::applyGs(CGameState * gs) const
|
||||
void SetPrimSkill::applyGs(CGameState *gs)
|
||||
{
|
||||
CGHeroInstance * hero = gs->getHero(id);
|
||||
assert(hero);
|
||||
hero->setPrimarySkill(which, val, abs);
|
||||
}
|
||||
|
||||
void SetSecSkill::applyGs(CGameState * gs) const
|
||||
void SetSecSkill::applyGs(CGameState *gs)
|
||||
{
|
||||
CGHeroInstance *hero = gs->getHero(id);
|
||||
hero->setSecSkillLevel(which, val, abs);
|
||||
@ -883,7 +883,7 @@ void SetCommanderProperty::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
|
||||
void AddQuest::applyGs(CGameState * gs) const
|
||||
void AddQuest::applyGs(CGameState *gs)
|
||||
{
|
||||
assert (vstd::contains(gs->players, player));
|
||||
auto * vec = &gs->players[player].quests;
|
||||
@ -893,17 +893,17 @@ void AddQuest::applyGs(CGameState * gs) const
|
||||
logNetwork->warn("Warning! Attempt to add duplicated quest");
|
||||
}
|
||||
|
||||
void UpdateArtHandlerLists::applyGs(CGameState * gs) const
|
||||
void UpdateArtHandlerLists::applyGs(CGameState *gs)
|
||||
{
|
||||
gs->allocatedArtifacts = allocatedArtifacts;
|
||||
}
|
||||
|
||||
void ChangeFormation::applyGs(CGameState * gs) const
|
||||
void ChangeFormation::applyGs(CGameState *gs)
|
||||
{
|
||||
gs->getHero(hid)->setFormation(formation);
|
||||
}
|
||||
|
||||
void HeroVisitCastle::applyGs(CGameState * gs) const
|
||||
void HeroVisitCastle::applyGs(CGameState *gs)
|
||||
{
|
||||
CGHeroInstance *h = gs->getHero(hid);
|
||||
CGTownInstance *t = gs->getTown(tid);
|
||||
@ -929,7 +929,7 @@ void ChangeSpells::applyGs(CGameState *gs)
|
||||
hero->removeSpellFromSpellbook(sid);
|
||||
}
|
||||
|
||||
void SetMana::applyGs(CGameState * gs) const
|
||||
void SetMana::applyGs(CGameState *gs)
|
||||
{
|
||||
CGHeroInstance * hero = gs->getHero(hid);
|
||||
|
||||
@ -943,7 +943,7 @@ void SetMana::applyGs(CGameState * gs) const
|
||||
vstd::amax(hero->mana, 0); //not less than 0
|
||||
}
|
||||
|
||||
void SetMovePoints::applyGs(CGameState * gs) const
|
||||
void SetMovePoints::applyGs(CGameState *gs)
|
||||
{
|
||||
CGHeroInstance *hero = gs->getHero(hid);
|
||||
|
||||
@ -1031,7 +1031,7 @@ void ChangeObjPos::applyGs(CGameState *gs)
|
||||
gs->map->addBlockVisTiles(obj);
|
||||
}
|
||||
|
||||
void ChangeObjectVisitors::applyGs(CGameState * gs) const
|
||||
void ChangeObjectVisitors::applyGs(CGameState *gs)
|
||||
{
|
||||
switch (mode) {
|
||||
case VISITOR_ADD:
|
||||
@ -1074,7 +1074,7 @@ void ChangeObjectVisitors::applyGs(CGameState * gs) const
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeArtifactsCostume::applyGs(CGameState * gs) const
|
||||
void ChangeArtifactsCostume::applyGs(CGameState *gs)
|
||||
{
|
||||
auto & allCostumes = gs->getPlayerState(player)->costumesArtifacts;
|
||||
if(const auto & costume = allCostumes.find(costumeIdx); costume != allCostumes.end())
|
||||
@ -1083,7 +1083,7 @@ void ChangeArtifactsCostume::applyGs(CGameState * gs) const
|
||||
allCostumes.try_emplace(costumeIdx, costumeSet);
|
||||
}
|
||||
|
||||
void PlayerEndsGame::applyGs(CGameState * gs) const
|
||||
void PlayerEndsGame::applyGs(CGameState *gs)
|
||||
{
|
||||
PlayerState *p = gs->getPlayerState(player);
|
||||
if(victoryLossCheckResult.victory())
|
||||
@ -1352,14 +1352,14 @@ void RazeStructures::applyGs(CGameState *gs)
|
||||
t->recreateBuildingsBonuses();
|
||||
}
|
||||
|
||||
void SetAvailableCreatures::applyGs(CGameState * gs) const
|
||||
void SetAvailableCreatures::applyGs(CGameState *gs)
|
||||
{
|
||||
auto * dw = dynamic_cast<CGDwelling *>(gs->getObjInstance(tid));
|
||||
assert(dw);
|
||||
dw->creatures = creatures;
|
||||
}
|
||||
|
||||
void SetHeroesInTown::applyGs(CGameState * gs) const
|
||||
void SetHeroesInTown::applyGs(CGameState *gs)
|
||||
{
|
||||
CGTownInstance *t = gs->getTown(tid);
|
||||
|
||||
@ -1388,7 +1388,7 @@ void SetHeroesInTown::applyGs(CGameState * gs) const
|
||||
}
|
||||
}
|
||||
|
||||
void HeroRecruited::applyGs(CGameState * gs) const
|
||||
void HeroRecruited::applyGs(CGameState *gs)
|
||||
{
|
||||
CGHeroInstance *h = gs->heroesPool->takeHeroFromPool(hid);
|
||||
CGTownInstance *t = gs->getTown(tid);
|
||||
@ -1425,7 +1425,7 @@ void HeroRecruited::applyGs(CGameState * gs) const
|
||||
t->setVisitingHero(h);
|
||||
}
|
||||
|
||||
void GiveHero::applyGs(CGameState * gs) const
|
||||
void GiveHero::applyGs(CGameState *gs)
|
||||
{
|
||||
CGHeroInstance *h = gs->getHero(id);
|
||||
|
||||
@ -1515,7 +1515,7 @@ struct GetBase
|
||||
}
|
||||
};
|
||||
|
||||
void ChangeStackCount::applyGs(CGameState * gs)
|
||||
void ChangeStackCount::applyGs(CGameState *gs)
|
||||
{
|
||||
auto * srcObj = gs->getArmyInstance(army);
|
||||
if(!srcObj)
|
||||
@ -1527,7 +1527,7 @@ void ChangeStackCount::applyGs(CGameState * gs)
|
||||
srcObj->changeStackCount(slot, count);
|
||||
}
|
||||
|
||||
void SetStackType::applyGs(CGameState * gs)
|
||||
void SetStackType::applyGs(CGameState *gs)
|
||||
{
|
||||
auto * srcObj = gs->getArmyInstance(army);
|
||||
if(!srcObj)
|
||||
@ -1536,7 +1536,7 @@ void SetStackType::applyGs(CGameState * gs)
|
||||
srcObj->setStackType(slot, type);
|
||||
}
|
||||
|
||||
void EraseStack::applyGs(CGameState * gs)
|
||||
void EraseStack::applyGs(CGameState *gs)
|
||||
{
|
||||
auto * srcObj = gs->getArmyInstance(army);
|
||||
if(!srcObj)
|
||||
@ -1545,7 +1545,7 @@ void EraseStack::applyGs(CGameState * gs)
|
||||
srcObj->eraseStack(slot);
|
||||
}
|
||||
|
||||
void SwapStacks::applyGs(CGameState * gs)
|
||||
void SwapStacks::applyGs(CGameState *gs)
|
||||
{
|
||||
auto * srcObj = gs->getArmyInstance(srcArmy);
|
||||
if(!srcObj)
|
||||
@ -1570,7 +1570,7 @@ void InsertNewStack::applyGs(CGameState *gs)
|
||||
throw std::runtime_error("InsertNewStack: invalid army object " + std::to_string(army.getNum()) + ", possible game state corruption.");
|
||||
}
|
||||
|
||||
void RebalanceStacks::applyGs(CGameState * gs)
|
||||
void RebalanceStacks::applyGs(CGameState *gs)
|
||||
{
|
||||
auto * srcObj = gs->getArmyInstance(srcArmy);
|
||||
if(!srcObj)
|
||||
@ -1675,13 +1675,13 @@ void RebalanceStacks::applyGs(CGameState * gs)
|
||||
CBonusSystemNode::treeHasChanged();
|
||||
}
|
||||
|
||||
void BulkRebalanceStacks::applyGs(CGameState * gs)
|
||||
void BulkRebalanceStacks::applyGs(CGameState *gs)
|
||||
{
|
||||
for(auto & move : moves)
|
||||
move.applyGs(gs);
|
||||
}
|
||||
|
||||
void BulkSmartRebalanceStacks::applyGs(CGameState * gs)
|
||||
void BulkSmartRebalanceStacks::applyGs(CGameState *gs)
|
||||
{
|
||||
for(auto & move : moves)
|
||||
move.applyGs(gs);
|
||||
@ -1734,7 +1734,7 @@ void EraseArtifact::applyGs(CGameState *gs)
|
||||
art->removeFrom(*artSet, al.slot);
|
||||
}
|
||||
|
||||
void BulkMoveArtifacts::applyGs(CGameState * gs)
|
||||
void BulkMoveArtifacts::applyGs(CGameState *gs)
|
||||
{
|
||||
const auto bulkArtsRemove = [](std::vector<LinkedSlots> & artsPack, CArtifactSet & artSet)
|
||||
{
|
||||
@ -1872,7 +1872,7 @@ void HeroVisit::applyGs(CGameState *gs)
|
||||
{
|
||||
}
|
||||
|
||||
void SetAvailableArtifacts::applyGs(CGameState * gs) const
|
||||
void SetAvailableArtifacts::applyGs(CGameState *gs)
|
||||
{
|
||||
if(id != ObjectInstanceID::NONE)
|
||||
{
|
||||
@ -1923,7 +1923,7 @@ void NewTurn::applyGs(CGameState *gs)
|
||||
gs->getPlayerState(re.first)->resources.amin(GameConstants::PLAYER_RESOURCES_CAP);
|
||||
}
|
||||
|
||||
for(const auto & creatureSet : cres) //set available creatures in towns
|
||||
for(auto & creatureSet : cres) //set available creatures in towns
|
||||
creatureSet.second.applyGs(gs);
|
||||
|
||||
for(CGTownInstance* t : gs->map->towns)
|
||||
@ -1933,7 +1933,7 @@ void NewTurn::applyGs(CGameState *gs)
|
||||
gs->currentRumor = *newRumor;
|
||||
}
|
||||
|
||||
void SetObjectProperty::applyGs(CGameState * gs) const
|
||||
void SetObjectProperty::applyGs(CGameState *gs)
|
||||
{
|
||||
CGObjectInstance *obj = gs->getObjInstance(id);
|
||||
if(!obj)
|
||||
@ -1981,14 +1981,14 @@ void SetObjectProperty::applyGs(CGameState * gs) const
|
||||
}
|
||||
}
|
||||
|
||||
void HeroLevelUp::applyGs(CGameState * gs) const
|
||||
void HeroLevelUp::applyGs(CGameState *gs)
|
||||
{
|
||||
auto * hero = gs->getHero(heroId);
|
||||
assert(hero);
|
||||
hero->levelUp(skills);
|
||||
}
|
||||
|
||||
void CommanderLevelUp::applyGs(CGameState * gs) const
|
||||
void CommanderLevelUp::applyGs(CGameState *gs)
|
||||
{
|
||||
auto * hero = gs->getHero(heroId);
|
||||
assert(hero);
|
||||
@ -1997,7 +1997,7 @@ void CommanderLevelUp::applyGs(CGameState * gs) const
|
||||
commander->levelUp();
|
||||
}
|
||||
|
||||
void BattleStart::applyGs(CGameState * gs) const
|
||||
void BattleStart::applyGs(CGameState *gs)
|
||||
{
|
||||
assert(battleID == gs->nextBattleID);
|
||||
|
||||
@ -2009,17 +2009,17 @@ void BattleStart::applyGs(CGameState * gs) const
|
||||
gs->nextBattleID = BattleID(gs->nextBattleID.getNum() + 1);
|
||||
}
|
||||
|
||||
void BattleNextRound::applyGs(CGameState * gs) const
|
||||
void BattleNextRound::applyGs(CGameState *gs)
|
||||
{
|
||||
gs->getBattle(battleID)->nextRound();
|
||||
}
|
||||
|
||||
void BattleSetActiveStack::applyGs(CGameState * gs) const
|
||||
void BattleSetActiveStack::applyGs(CGameState *gs)
|
||||
{
|
||||
gs->getBattle(battleID)->nextTurn(stack);
|
||||
}
|
||||
|
||||
void BattleTriggerEffect::applyGs(CGameState * gs) const
|
||||
void BattleTriggerEffect::applyGs(CGameState *gs)
|
||||
{
|
||||
CStack * st = gs->getBattle(battleID)->getStack(stackID);
|
||||
assert(st);
|
||||
@ -2058,13 +2058,13 @@ void BattleTriggerEffect::applyGs(CGameState * gs) const
|
||||
}
|
||||
}
|
||||
|
||||
void BattleUpdateGateState::applyGs(CGameState * gs) const
|
||||
void BattleUpdateGateState::applyGs(CGameState *gs)
|
||||
{
|
||||
if(gs->getBattle(battleID))
|
||||
gs->getBattle(battleID)->si.gateState = state;
|
||||
}
|
||||
|
||||
void BattleCancelled::applyGs(CGameState * gs) const
|
||||
void BattleCancelled::applyGs(CGameState *gs)
|
||||
{
|
||||
auto currentBattle = boost::range::find_if(gs->currentBattles, [&](const auto & battle)
|
||||
{
|
||||
@ -2075,7 +2075,7 @@ void BattleCancelled::applyGs(CGameState * gs) const
|
||||
gs->currentBattles.erase(currentBattle);
|
||||
}
|
||||
|
||||
void BattleResultAccepted::applyGs(CGameState * gs) const
|
||||
void BattleResultAccepted::applyGs(CGameState *gs)
|
||||
{
|
||||
// Remove any "until next battle" bonuses
|
||||
for(auto & res : heroResult)
|
||||
@ -2141,7 +2141,7 @@ void BattleStackMoved::applyBattle(IBattleState * battleState)
|
||||
battleState->moveUnit(stack, tilesToMove.back());
|
||||
}
|
||||
|
||||
void BattleStackAttacked::applyGs(CGameState * gs)
|
||||
void BattleStackAttacked::applyGs(CGameState *gs)
|
||||
{
|
||||
applyBattle(gs->getBattle(battleID));
|
||||
}
|
||||
@ -2151,7 +2151,7 @@ void BattleStackAttacked::applyBattle(IBattleState * battleState)
|
||||
battleState->setUnitState(newState.id, newState.data, newState.healthDelta);
|
||||
}
|
||||
|
||||
void BattleAttack::applyGs(CGameState * gs)
|
||||
void BattleAttack::applyGs(CGameState *gs)
|
||||
{
|
||||
CStack * attacker = gs->getBattle(battleID)->getStack(stackAttacking);
|
||||
assert(attacker);
|
||||
@ -2216,7 +2216,7 @@ void StartAction::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
|
||||
void BattleSpellCast::applyGs(CGameState * gs) const
|
||||
void BattleSpellCast::applyGs(CGameState *gs)
|
||||
{
|
||||
if(castByHero && side != BattleSide::NONE)
|
||||
gs->getBattle(battleID)->getSide(side).castSpellsCount++;
|
||||
@ -2281,7 +2281,7 @@ void BattleUnitsChanged::applyBattle(IBattleState * battleState)
|
||||
}
|
||||
}
|
||||
|
||||
void BattleObstaclesChanged::applyGs(CGameState * gs)
|
||||
void BattleObstaclesChanged::applyGs(CGameState *gs)
|
||||
{
|
||||
applyBattle(gs->getBattle(battleID));
|
||||
}
|
||||
@ -2312,7 +2312,7 @@ CatapultAttack::CatapultAttack() = default;
|
||||
|
||||
CatapultAttack::~CatapultAttack() = default;
|
||||
|
||||
void CatapultAttack::applyGs(CGameState * gs)
|
||||
void CatapultAttack::applyGs(CGameState *gs)
|
||||
{
|
||||
applyBattle(gs->getBattle(battleID));
|
||||
}
|
||||
@ -2338,7 +2338,7 @@ void CatapultAttack::applyBattle(IBattleState * battleState)
|
||||
}
|
||||
}
|
||||
|
||||
void BattleSetStackProperty::applyGs(CGameState * gs) const
|
||||
void BattleSetStackProperty::applyGs(CGameState *gs)
|
||||
{
|
||||
CStack * stack = gs->getBattle(battleID)->getStack(stackID, false);
|
||||
switch(which)
|
||||
@ -2379,7 +2379,7 @@ void BattleSetStackProperty::applyGs(CGameState * gs) const
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerCheated::applyGs(CGameState * gs) const
|
||||
void PlayerCheated::applyGs(CGameState *gs)
|
||||
{
|
||||
if(!player.isValidPlayer())
|
||||
return;
|
||||
@ -2389,37 +2389,37 @@ void PlayerCheated::applyGs(CGameState * gs) const
|
||||
gs->getPlayerState(player)->cheated = true;
|
||||
}
|
||||
|
||||
void PlayerStartsTurn::applyGs(CGameState * gs) const
|
||||
void PlayerStartsTurn::applyGs(CGameState *gs)
|
||||
{
|
||||
//assert(gs->actingPlayers.count(player) == 0);//Legal - may happen after loading of deserialized map state
|
||||
gs->actingPlayers.insert(player);
|
||||
}
|
||||
|
||||
void PlayerEndsTurn::applyGs(CGameState * gs) const
|
||||
void PlayerEndsTurn::applyGs(CGameState *gs)
|
||||
{
|
||||
assert(gs->actingPlayers.count(player) == 1);
|
||||
gs->actingPlayers.erase(player);
|
||||
}
|
||||
|
||||
void DaysWithoutTown::applyGs(CGameState * gs) const
|
||||
void DaysWithoutTown::applyGs(CGameState *gs)
|
||||
{
|
||||
auto & playerState = gs->players[player];
|
||||
playerState.daysWithoutCastle = daysWithoutCastle;
|
||||
}
|
||||
|
||||
void TurnTimeUpdate::applyGs(CGameState *gs) const
|
||||
void TurnTimeUpdate::applyGs(CGameState *gs)
|
||||
{
|
||||
auto & playerState = gs->players[player];
|
||||
playerState.turnTimer = turnTimer;
|
||||
}
|
||||
|
||||
void EntitiesChanged::applyGs(CGameState * gs)
|
||||
void EntitiesChanged::applyGs(CGameState *gs)
|
||||
{
|
||||
for(const auto & change : changes)
|
||||
gs->updateEntity(change.metatype, change.entityIndex, change.data);
|
||||
}
|
||||
|
||||
void SetRewardableConfiguration::applyGs(CGameState * gs)
|
||||
void SetRewardableConfiguration::applyGs(CGameState *gs)
|
||||
{
|
||||
auto * objectPtr = gs->getObjInstance(objectID);
|
||||
|
||||
@ -2444,7 +2444,7 @@ void SetRewardableConfiguration::applyGs(CGameState * gs)
|
||||
}
|
||||
}
|
||||
|
||||
void SetBankConfiguration::applyGs(CGameState * gs)
|
||||
void SetBankConfiguration::applyGs(CGameState *gs)
|
||||
{
|
||||
auto * objectPtr = gs->getObjInstance(objectID);
|
||||
auto * bankPtr = dynamic_cast<CBank *>(objectPtr);
|
||||
|
@ -57,6 +57,7 @@ struct DLL_LINKAGE PackageApplied : public CPackForClient
|
||||
{
|
||||
}
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState *gs) override {}
|
||||
|
||||
ui8 result = 0; //0 - something went wrong, request hasn't been realized; 1 - OK
|
||||
ui32 packType = 0; //type id of applied package
|
||||
@ -81,6 +82,7 @@ struct DLL_LINKAGE SystemMessage : public CPackForClient
|
||||
SystemMessage() = default;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState *gs) override {}
|
||||
|
||||
MetaString text;
|
||||
|
||||
@ -100,6 +102,7 @@ struct DLL_LINKAGE PlayerBlocked : public CPackForClient
|
||||
PlayerColor player;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState *gs) override {}
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
@ -111,7 +114,7 @@ struct DLL_LINKAGE PlayerBlocked : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE PlayerCheated : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
PlayerColor player;
|
||||
bool losingCheatCode = false;
|
||||
@ -129,7 +132,7 @@ struct DLL_LINKAGE PlayerCheated : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE TurnTimeUpdate : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
PlayerColor player;
|
||||
TurnTimerInfo turnTimer;
|
||||
@ -143,7 +146,7 @@ struct DLL_LINKAGE TurnTimeUpdate : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE PlayerStartsTurn : public Query
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
PlayerColor player;
|
||||
|
||||
@ -158,7 +161,7 @@ struct DLL_LINKAGE PlayerStartsTurn : public Query
|
||||
|
||||
struct DLL_LINKAGE DaysWithoutTown : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
PlayerColor player;
|
||||
std::optional<int32_t> daysWithoutCastle;
|
||||
@ -176,7 +179,7 @@ struct DLL_LINKAGE EntitiesChanged : public CPackForClient
|
||||
{
|
||||
std::vector<EntityChanges> changes;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -188,7 +191,7 @@ struct DLL_LINKAGE EntitiesChanged : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE SetResources : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -206,7 +209,7 @@ struct DLL_LINKAGE SetResources : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE SetPrimSkill : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -226,7 +229,7 @@ struct DLL_LINKAGE SetPrimSkill : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE SetSecSkill : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -246,7 +249,7 @@ struct DLL_LINKAGE SetSecSkill : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE HeroVisitCastle : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -269,7 +272,7 @@ struct DLL_LINKAGE HeroVisitCastle : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE ChangeSpells : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -287,7 +290,7 @@ struct DLL_LINKAGE ChangeSpells : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE SetMana : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -305,7 +308,7 @@ struct DLL_LINKAGE SetMana : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE SetMovePoints : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
ObjectInstanceID hid;
|
||||
si32 val = 0;
|
||||
@ -323,7 +326,7 @@ struct DLL_LINKAGE SetMovePoints : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE FoWChange : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
std::unordered_set<int3> tiles;
|
||||
PlayerColor player;
|
||||
@ -347,7 +350,7 @@ struct DLL_LINKAGE SetAvailableHero : public CPackForClient
|
||||
{
|
||||
army.clearSlots();
|
||||
}
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
TavernHeroSlot slotID;
|
||||
TavernSlotRole roleID;
|
||||
@ -378,7 +381,7 @@ struct DLL_LINKAGE GiveBonus : public CPackForClient
|
||||
{
|
||||
}
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
ETarget who = ETarget::OBJECT;
|
||||
VariantIdentifier<ObjectInstanceID, PlayerColor, BattleID> id;
|
||||
@ -397,7 +400,7 @@ struct DLL_LINKAGE GiveBonus : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE ChangeObjPos : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
/// Object to move
|
||||
ObjectInstanceID objid;
|
||||
@ -418,7 +421,7 @@ struct DLL_LINKAGE ChangeObjPos : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE PlayerEndsTurn : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
PlayerColor player;
|
||||
|
||||
@ -432,7 +435,7 @@ struct DLL_LINKAGE PlayerEndsTurn : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE PlayerEndsGame : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
PlayerColor player;
|
||||
EVictoryLossCheckResult victoryLossCheckResult;
|
||||
@ -451,7 +454,7 @@ struct DLL_LINKAGE PlayerEndsGame : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE PlayerReinitInterface : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
std::vector<PlayerColor> players;
|
||||
ui8 playerConnectionId; //PLAYER_AI for AI player
|
||||
@ -472,7 +475,7 @@ struct DLL_LINKAGE RemoveBonus : public CPackForClient
|
||||
{
|
||||
}
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
GiveBonus::ETarget who; //who receives bonus
|
||||
VariantIdentifier<HeroTypeID, PlayerColor, BattleID, ObjectInstanceID> whoID;
|
||||
@ -499,7 +502,7 @@ struct DLL_LINKAGE SetCommanderProperty : public CPackForClient
|
||||
{
|
||||
enum ECommanderProperty { ALIVE, BONUS, SECONDARY_SKILL, EXPERIENCE, SPECIAL_SKILL };
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
ObjectInstanceID heroid;
|
||||
|
||||
@ -522,7 +525,7 @@ struct DLL_LINKAGE SetCommanderProperty : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE AddQuest : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
PlayerColor player;
|
||||
QuestInfo quest;
|
||||
@ -540,7 +543,7 @@ struct DLL_LINKAGE UpdateArtHandlerLists : public CPackForClient
|
||||
{
|
||||
std::map<ArtifactID, int> allocatedArtifacts;
|
||||
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
@ -554,7 +557,7 @@ struct DLL_LINKAGE ChangeFormation : public CPackForClient
|
||||
ObjectInstanceID hid;
|
||||
EArmyFormation formation{};
|
||||
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
@ -573,7 +576,7 @@ struct DLL_LINKAGE RemoveObject : public CPackForClient
|
||||
{
|
||||
}
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
/// ID of removed object
|
||||
@ -591,7 +594,7 @@ struct DLL_LINKAGE RemoveObject : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE TryMoveHero : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
enum EResult
|
||||
{
|
||||
@ -632,7 +635,7 @@ struct DLL_LINKAGE TryMoveHero : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE NewStructures : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
ObjectInstanceID tid;
|
||||
std::set<BuildingID> bid;
|
||||
@ -650,7 +653,7 @@ struct DLL_LINKAGE NewStructures : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE RazeStructures : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
ObjectInstanceID tid;
|
||||
std::set<BuildingID> bid;
|
||||
@ -668,7 +671,7 @@ struct DLL_LINKAGE RazeStructures : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE SetAvailableCreatures : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
ObjectInstanceID tid;
|
||||
std::vector<std::pair<ui32, std::vector<CreatureID> > > creatures;
|
||||
@ -684,7 +687,7 @@ struct DLL_LINKAGE SetAvailableCreatures : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE SetHeroesInTown : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
ObjectInstanceID tid; //id of town
|
||||
ObjectInstanceID visiting; //id of visiting hero
|
||||
@ -702,7 +705,7 @@ struct DLL_LINKAGE SetHeroesInTown : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE HeroRecruited : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
HeroTypeID hid; //subID of hero
|
||||
ObjectInstanceID tid;
|
||||
@ -724,7 +727,7 @@ struct DLL_LINKAGE HeroRecruited : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE GiveHero : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
ObjectInstanceID id; //object id
|
||||
ObjectInstanceID boatId;
|
||||
@ -747,6 +750,7 @@ struct DLL_LINKAGE OpenWindow : public Query
|
||||
ObjectInstanceID visitor;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState *gs) override {}
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
@ -759,7 +763,7 @@ struct DLL_LINKAGE OpenWindow : public Query
|
||||
|
||||
struct DLL_LINKAGE NewObject : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
/// Object ID to create
|
||||
CGObjectInstance * newObject;
|
||||
@ -777,7 +781,7 @@ struct DLL_LINKAGE NewObject : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE SetAvailableArtifacts : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
//two variants: id < 0: set artifact pool for Artifact Merchants in towns; id >= 0: set pool for adv. map Black Market (id is the id of Black Market instance then)
|
||||
ObjectInstanceID id;
|
||||
@ -803,7 +807,7 @@ struct DLL_LINKAGE ChangeStackCount : CGarrisonOperationPack
|
||||
TQuantity count;
|
||||
bool absoluteValue; //if not -> count will be added (or subtracted if negative)
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -822,7 +826,7 @@ struct DLL_LINKAGE SetStackType : CGarrisonOperationPack
|
||||
SlotID slot;
|
||||
CreatureID type;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -839,7 +843,7 @@ struct DLL_LINKAGE EraseStack : CGarrisonOperationPack
|
||||
ObjectInstanceID army;
|
||||
SlotID slot;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
@ -856,7 +860,7 @@ struct DLL_LINKAGE SwapStacks : CGarrisonOperationPack
|
||||
SlotID srcSlot;
|
||||
SlotID dstSlot;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
@ -875,7 +879,7 @@ struct DLL_LINKAGE InsertNewStack : CGarrisonOperationPack
|
||||
CreatureID type;
|
||||
TQuantity count = 0;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
@ -897,7 +901,7 @@ struct DLL_LINKAGE RebalanceStacks : CGarrisonOperationPack
|
||||
|
||||
TQuantity count;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
@ -914,7 +918,7 @@ struct DLL_LINKAGE BulkRebalanceStacks : CGarrisonOperationPack
|
||||
{
|
||||
std::vector<RebalanceStacks> moves;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler>
|
||||
@ -929,7 +933,7 @@ struct DLL_LINKAGE BulkSmartRebalanceStacks : CGarrisonOperationPack
|
||||
std::vector<RebalanceStacks> moves;
|
||||
std::vector<ChangeStackCount> changes;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler>
|
||||
@ -956,7 +960,7 @@ struct DLL_LINKAGE PutArtifact : CArtifactOperationPack
|
||||
bool askAssemble;
|
||||
ConstTransitivePtr<CArtifactInstance> art;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
@ -971,7 +975,7 @@ struct DLL_LINKAGE NewArtifact : public CArtifactOperationPack
|
||||
{
|
||||
ConstTransitivePtr<CArtifactInstance> art;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
@ -984,7 +988,7 @@ struct DLL_LINKAGE EraseArtifact : CArtifactOperationPack
|
||||
{
|
||||
ArtifactLocation al;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
@ -1039,7 +1043,7 @@ struct DLL_LINKAGE BulkMoveArtifacts : CArtifactOperationPack
|
||||
{
|
||||
}
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
std::vector<LinkedSlots> artsPack0;
|
||||
std::vector<LinkedSlots> artsPack1;
|
||||
@ -1063,7 +1067,7 @@ struct DLL_LINKAGE AssembledArtifact : CArtifactOperationPack
|
||||
ArtifactLocation al; //where assembly will be put
|
||||
const CArtifact * builtArt;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -1078,7 +1082,7 @@ struct DLL_LINKAGE DisassembledArtifact : CArtifactOperationPack
|
||||
{
|
||||
ArtifactLocation al;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -1096,7 +1100,7 @@ struct DLL_LINKAGE HeroVisit : public CPackForClient
|
||||
|
||||
bool starting; //false -> ending
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -1113,7 +1117,7 @@ struct DLL_LINKAGE NewTurn : public CPackForClient
|
||||
{
|
||||
enum weekType { NORMAL, DOUBLE_GROWTH, BONUS_GROWTH, DEITYOFFIRE, PLAGUE, NO_ACTION };
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -1162,6 +1166,7 @@ struct DLL_LINKAGE InfoWindow : public CPackForClient //103 - displays simple i
|
||||
ui16 soundID = 0;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState * gs) override {}
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
@ -1176,7 +1181,7 @@ struct DLL_LINKAGE InfoWindow : public CPackForClient //103 - displays simple i
|
||||
|
||||
struct DLL_LINKAGE SetObjectProperty : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
ObjectInstanceID id;
|
||||
ObjProperty what{};
|
||||
|
||||
@ -1208,7 +1213,7 @@ struct DLL_LINKAGE ChangeObjectVisitors : public CPackForClient
|
||||
ObjectInstanceID object;
|
||||
ObjectInstanceID hero; // note: hero owner will be also marked as "visited" this object
|
||||
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -1235,7 +1240,7 @@ struct DLL_LINKAGE ChangeArtifactsCostume : public CPackForClient
|
||||
uint32_t costumeIdx = 0;
|
||||
const PlayerColor player = PlayerColor::NEUTRAL;
|
||||
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
ChangeArtifactsCostume() = default;
|
||||
@ -1261,7 +1266,7 @@ struct DLL_LINKAGE HeroLevelUp : public Query
|
||||
PrimarySkill primskill = PrimarySkill::ATTACK;
|
||||
std::vector<SecondarySkill> skills;
|
||||
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -1282,7 +1287,7 @@ struct DLL_LINKAGE CommanderLevelUp : public Query
|
||||
|
||||
std::vector<ui32> skills; //0-5 - secondary skills, val-100 - special skill
|
||||
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -1329,6 +1334,7 @@ struct DLL_LINKAGE BlockingDialog : public Query
|
||||
BlockingDialog() = default;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState * gs) override {}
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
@ -1348,6 +1354,7 @@ struct DLL_LINKAGE GarrisonDialog : public Query
|
||||
bool removableUnits = false;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState * gs) override {}
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
@ -1366,6 +1373,7 @@ struct DLL_LINKAGE ExchangeDialog : public Query
|
||||
ObjectInstanceID hero2;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState * gs) override {}
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
@ -1391,6 +1399,7 @@ struct DLL_LINKAGE TeleportDialog : public Query
|
||||
bool impassable = false;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState * gs) override {}
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
@ -1411,6 +1420,7 @@ struct DLL_LINKAGE MapObjectSelectDialog : public Query
|
||||
std::vector<ObjectInstanceID> objects;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState * gs) override {}
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
@ -1435,6 +1445,7 @@ struct DLL_LINKAGE AdvmapSpellCast : public CPackForClient
|
||||
|
||||
protected:
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState * gs) override {}
|
||||
};
|
||||
|
||||
struct DLL_LINKAGE ShowWorldViewEx : public CPackForClient
|
||||
@ -1444,6 +1455,8 @@ struct DLL_LINKAGE ShowWorldViewEx : public CPackForClient
|
||||
|
||||
std::vector<ObjectPosInfo> objectPositions;
|
||||
|
||||
void applyGs(CGameState * gs) override {}
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
h & player;
|
||||
@ -1464,6 +1477,7 @@ struct DLL_LINKAGE PlayerMessageClient : public CPackForClient
|
||||
{
|
||||
}
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState * gs) override {}
|
||||
|
||||
PlayerColor player;
|
||||
std::string text;
|
||||
@ -1482,6 +1496,7 @@ struct DLL_LINKAGE CenterView : public CPackForClient
|
||||
ui32 focusTime = 0; //ms
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState * gs) override {}
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ class BattleInfo;
|
||||
|
||||
struct DLL_LINKAGE BattleStart : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
BattleInfo * info = nullptr;
|
||||
@ -42,7 +42,7 @@ struct DLL_LINKAGE BattleStart : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE BattleNextRound : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
|
||||
@ -57,7 +57,7 @@ struct DLL_LINKAGE BattleNextRound : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE BattleSetActiveStack : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
ui32 stack = 0;
|
||||
@ -76,7 +76,7 @@ struct DLL_LINKAGE BattleSetActiveStack : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE BattleCancelled: public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
|
||||
@ -89,7 +89,7 @@ struct DLL_LINKAGE BattleCancelled: public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE BattleResultAccepted : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
struct HeroBattleResults
|
||||
{
|
||||
@ -133,6 +133,7 @@ struct DLL_LINKAGE BattleResult : public Query
|
||||
std::set<ArtifactInstanceID> artifacts; //artifacts taken from loser to winner - currently unused
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState *gs) override {}
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
@ -152,7 +153,7 @@ struct DLL_LINKAGE BattleLogMessage : public CPackForClient
|
||||
BattleID battleID = BattleID::NONE;
|
||||
std::vector<MetaString> lines;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void applyBattle(IBattleState * battleState);
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
@ -173,7 +174,7 @@ struct DLL_LINKAGE BattleStackMoved : public CPackForClient
|
||||
int distance = 0;
|
||||
bool teleporting = false;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void applyBattle(IBattleState * battleState);
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
@ -191,7 +192,7 @@ struct DLL_LINKAGE BattleStackMoved : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE BattleUnitsChanged : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void applyBattle(IBattleState * battleState);
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
@ -267,7 +268,7 @@ struct BattleStackAttacked
|
||||
|
||||
struct DLL_LINKAGE BattleAttack : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
BattleUnitsChanged attackerChanges;
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
@ -335,7 +336,7 @@ struct DLL_LINKAGE StartAction : public CPackForClient
|
||||
{
|
||||
}
|
||||
void applyFirstCl(CClient * cl);
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
BattleAction ba;
|
||||
@ -353,6 +354,7 @@ struct DLL_LINKAGE StartAction : public CPackForClient
|
||||
struct DLL_LINKAGE EndAction : public CPackForClient
|
||||
{
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState *gs) override {}
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
|
||||
@ -364,7 +366,7 @@ struct DLL_LINKAGE EndAction : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE BattleSpellCast : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
bool activeCast = true;
|
||||
@ -399,7 +401,7 @@ struct DLL_LINKAGE BattleSpellCast : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE StacksInjured : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void applyBattle(IBattleState * battleState);
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
@ -420,6 +422,7 @@ struct DLL_LINKAGE BattleResultsApplied : public CPackForClient
|
||||
BattleID battleID = BattleID::NONE;
|
||||
PlayerColor player1, player2;
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
void applyGs(CGameState *gs) override {}
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
@ -432,7 +435,7 @@ struct DLL_LINKAGE BattleResultsApplied : public CPackForClient
|
||||
|
||||
struct DLL_LINKAGE BattleObstaclesChanged : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void applyBattle(IBattleState * battleState);
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
@ -467,7 +470,7 @@ struct DLL_LINKAGE CatapultAttack : public CPackForClient
|
||||
CatapultAttack();
|
||||
~CatapultAttack() override;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void applyGs(CGameState * gs) override;
|
||||
void applyBattle(IBattleState * battleState);
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
@ -489,7 +492,7 @@ struct DLL_LINKAGE BattleSetStackProperty : public CPackForClient
|
||||
{
|
||||
enum BattleStackProperty { CASTS, ENCHANTER_COUNTER, UNBIND, CLONED, HAS_CLONE };
|
||||
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
int stackID = 0;
|
||||
@ -514,7 +517,7 @@ protected:
|
||||
///activated at the beginning of turn
|
||||
struct DLL_LINKAGE BattleTriggerEffect : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const; //effect
|
||||
void applyGs(CGameState * gs) override; //effect
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
int stackID = 0;
|
||||
@ -538,7 +541,7 @@ protected:
|
||||
|
||||
struct DLL_LINKAGE BattleUpdateGateState : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
void applyGs(CGameState * gs) override;
|
||||
|
||||
BattleID battleID = BattleID::NONE;
|
||||
EGateState state = EGateState::NONE;
|
||||
|
@ -18,7 +18,7 @@ BinaryDeserializer::BinaryDeserializer(IBinaryReader * r): CLoaderBase(r)
|
||||
version = Version::NONE;
|
||||
reverseEndianness = false;
|
||||
|
||||
registerTypes(*this);
|
||||
registerTypes(applier);
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
@ -388,11 +388,6 @@ public:
|
||||
loadedPointers[pid] = const_cast<Serializeable*>(dynamic_cast<const Serializeable*>(ptr)); //add loaded pointer to our lookup map; cast is to avoid errors with const T* pt
|
||||
}
|
||||
|
||||
template<typename Base, typename Derived> void registerType(const Base * b = nullptr, const Derived * d = nullptr)
|
||||
{
|
||||
applier.registerType(b, d);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void load(std::shared_ptr<T> &data)
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
BinarySerializer::BinarySerializer(IBinaryWriter * w): CSaverBase(w)
|
||||
{
|
||||
registerTypes(*this);
|
||||
registerTypes(applier);
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
@ -129,12 +129,6 @@ public:
|
||||
|
||||
DLL_LINKAGE BinarySerializer(IBinaryWriter * w);
|
||||
|
||||
template<typename Base, typename Derived>
|
||||
void registerType(const Base * b = nullptr, const Derived * d = nullptr)
|
||||
{
|
||||
applier.registerType(b, d);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
BinarySerializer & operator&(const T & t)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user