1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-02 00:10:22 +02:00

Reduced usage of CPack, replaced with CPackForServer where applicable

This commit is contained in:
Ivan Savenko 2024-10-04 13:41:53 +00:00
parent c1c552d394
commit ee831c06e7
12 changed files with 21 additions and 24 deletions

View File

@ -25,7 +25,6 @@ struct TurnTimerInfo;
class CMapInfo;
class CGameState;
struct ClientPlayer;
struct CPack;
struct CPackForLobby;
struct CPackForClient;

View File

@ -16,7 +16,6 @@
VCMI_LIB_NAMESPACE_BEGIN
struct CPack;
struct CPackForServer;
class IBattleEventsReceiver;
class CBattleGameInterface;

View File

@ -4008,7 +4008,7 @@ bool CGameHandler::isValidObject(const CGObjectInstance *obj) const
return vstd::contains(gs->map->objects, obj);
}
bool CGameHandler::isBlockedByQueries(const CPack *pack, PlayerColor player)
bool CGameHandler::isBlockedByQueries(const CPackForServer *pack, PlayerColor player)
{
if (dynamic_cast<const PlayerMessage *>(pack) != nullptr)
return false;

View File

@ -27,7 +27,6 @@ class CCommanderInstance;
class EVictoryLossCheckResult;
class CRandomGenerator;
struct CPack;
struct CPackForServer;
struct NewTurn;
struct CGarrisonOperationPack;
@ -89,7 +88,7 @@ public:
CVCMIServer * gameLobby() const;
bool isValidObject(const CGObjectInstance *obj) const;
bool isBlockedByQueries(const CPack *pack, PlayerColor player);
bool isBlockedByQueries(const CPackForServer *pack, PlayerColor player);
bool isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2);
void giveSpells(const CGTownInstance *t, const CGHeroInstance *h);

View File

@ -49,7 +49,7 @@ CBattleQuery::CBattleQuery(CGameHandler * owner):
belligerents[BattleSide::DEFENDER] = nullptr;
}
bool CBattleQuery::blocksPack(const CPack * pack) const
bool CBattleQuery::blocksPack(const CPackForServer * pack) const
{
if(dynamic_cast<const MakeAction*>(pack) != nullptr)
return false;

View File

@ -30,7 +30,7 @@ public:
CBattleQuery(CGameHandler * owner);
CBattleQuery(CGameHandler * owner, const IBattleInfo * Bi); //TODO
void notifyObjectAboutRemoval(const CGObjectInstance * visitedObject, const CGHeroInstance * visitingHero) const override;
bool blocksPack(const CPack *pack) const override;
bool blocksPack(const CPackForServer *pack) const override;
void onRemoval(PlayerColor color) override;
void onExposure(QueryPtr topQuery) override;
};

View File

@ -81,7 +81,7 @@ void CQuery::onRemoval(PlayerColor color)
}
bool CQuery::blocksPack(const CPack * pack) const
bool CQuery::blocksPack(const CPackForServer * pack) const
{
return false;
}
@ -112,7 +112,7 @@ void CQuery::setReply(std::optional<int32_t> reply)
}
bool CQuery::blockAllButReply(const CPack * pack) const
bool CQuery::blockAllButReply(const CPackForServer * pack) const
{
//We accept only query replies from correct player
if(auto reply = dynamic_cast<const QueryReply*>(pack))
@ -132,7 +132,7 @@ bool CDialogQuery::endsByPlayerAnswer() const
return true;
}
bool CDialogQuery::blocksPack(const CPack * pack) const
bool CDialogQuery::blocksPack(const CPackForServer * pack) const
{
return blockAllButReply(pack);
}
@ -149,7 +149,7 @@ CGenericQuery::CGenericQuery(CGameHandler * gh, PlayerColor color, std::function
addPlayer(color);
}
bool CGenericQuery::blocksPack(const CPack * pack) const
bool CGenericQuery::blocksPack(const CPackForServer * pack) const
{
return blockAllButReply(pack);
}

View File

@ -13,7 +13,7 @@
VCMI_LIB_NAMESPACE_BEGIN
struct CPack;
struct CPackForServer;
class CGObjectInstance;
class CGHeroInstance;
@ -43,7 +43,7 @@ public:
CQuery(CGameHandler * gh);
/// query can block attempting actions by player. Eg. he can't move hero during the battle.
virtual bool blocksPack(const CPack *pack) const;
virtual bool blocksPack(const CPackForServer *pack) const;
/// query is removed after player gives answer (like dialogs)
virtual bool endsByPlayerAnswer() const;
@ -71,7 +71,7 @@ protected:
QueriesProcessor * owner;
CGameHandler * gh;
void addPlayer(PlayerColor color);
bool blockAllButReply(const CPack * pack) const;
bool blockAllButReply(const CPackForServer * pack) const;
};
std::ostream &operator<<(std::ostream &out, const CQuery &query);
@ -82,7 +82,7 @@ class CDialogQuery : public CQuery
public:
CDialogQuery(CGameHandler * owner);
bool endsByPlayerAnswer() const override;
bool blocksPack(const CPack *pack) const override;
bool blocksPack(const CPackForServer *pack) const override;
void setReply(std::optional<int32_t> reply) override;
protected:
std::optional<ui32> answer;
@ -93,7 +93,7 @@ class CGenericQuery : public CQuery
public:
CGenericQuery(CGameHandler * gh, PlayerColor color, std::function<void(std::optional<int32_t>)> Callback);
bool blocksPack(const CPack * pack) const override;
bool blocksPack(const CPackForServer * pack) const override;
bool endsByPlayerAnswer() const override;
void onExposure(QueryPtr topQuery) override;
void setReply(std::optional<int32_t> reply) override;

View File

@ -23,7 +23,7 @@ TimerPauseQuery::TimerPauseQuery(CGameHandler * owner, PlayerColor player):
addPlayer(player);
}
bool TimerPauseQuery::blocksPack(const CPack *pack) const
bool TimerPauseQuery::blocksPack(const CPackForServer *pack) const
{
return blockAllButReply(pack);
}
@ -58,7 +58,7 @@ CGarrisonDialogQuery::CGarrisonDialogQuery(CGameHandler * owner, const CArmedIns
addPlayer(down->tempOwner);
}
bool CGarrisonDialogQuery::blocksPack(const CPack * pack) const
bool CGarrisonDialogQuery::blocksPack(const CPackForServer * pack) const
{
std::set<ObjectInstanceID> ourIds;
ourIds.insert(this->exchangingArmies[0]->id);
@ -143,7 +143,7 @@ void OpenWindowQuery::onExposure(QueryPtr topQuery)
//do nothing - wait for reply
}
bool OpenWindowQuery::blocksPack(const CPack *pack) const
bool OpenWindowQuery::blocksPack(const CPackForServer *pack) const
{
if (mode == EOpenWindowMode::RECRUITMENT_FIRST || mode == EOpenWindowMode::RECRUITMENT_ALL)
{

View File

@ -25,7 +25,7 @@ class TimerPauseQuery : public CQuery
public:
TimerPauseQuery(CGameHandler * owner, PlayerColor player);
bool blocksPack(const CPack *pack) const override;
bool blocksPack(const CPackForServer *pack) const override;
void onAdding(PlayerColor color) override;
void onRemoval(PlayerColor color) override;
bool endsByPlayerAnswer() const override;
@ -54,7 +54,7 @@ public:
CGarrisonDialogQuery(CGameHandler * owner, const CArmedInstance *up, const CArmedInstance *down);
void notifyObjectAboutRemoval(const CGObjectInstance * visitedObject, const CGHeroInstance * visitingHero) const override;
bool blocksPack(const CPack *pack) const override;
bool blocksPack(const CPackForServer *pack) const override;
};
//yes/no and component selection dialogs
@ -75,7 +75,7 @@ class OpenWindowQuery : public CDialogQuery
public:
OpenWindowQuery(CGameHandler * owner, const CGHeroInstance *hero, EOpenWindowMode mode);
bool blocksPack(const CPack *pack) const override;
bool blocksPack(const CPackForServer *pack) const override;
void onExposure(QueryPtr topQuery) override;
};

View File

@ -24,7 +24,7 @@ VisitQuery::VisitQuery(CGameHandler * owner, const CGObjectInstance * Obj, const
addPlayer(Hero->tempOwner);
}
bool VisitQuery::blocksPack(const CPack * pack) const
bool VisitQuery::blocksPack(const CPackForServer * pack) const
{
//During the visit itself ALL actions are blocked.
//(However, the visit may trigger a query above that'll pass some.)

View File

@ -26,7 +26,7 @@ public:
const CGObjectInstance * visitedObject;
const CGHeroInstance * visitingHero;
bool blocksPack(const CPack * pack) const final;
bool blocksPack(const CPackForServer * pack) const final;
};
class MapObjectVisitQuery final : public VisitQuery