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:
parent
c1c552d394
commit
ee831c06e7
@ -25,7 +25,6 @@ struct TurnTimerInfo;
|
|||||||
class CMapInfo;
|
class CMapInfo;
|
||||||
class CGameState;
|
class CGameState;
|
||||||
struct ClientPlayer;
|
struct ClientPlayer;
|
||||||
struct CPack;
|
|
||||||
struct CPackForLobby;
|
struct CPackForLobby;
|
||||||
struct CPackForClient;
|
struct CPackForClient;
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
struct CPack;
|
|
||||||
struct CPackForServer;
|
struct CPackForServer;
|
||||||
class IBattleEventsReceiver;
|
class IBattleEventsReceiver;
|
||||||
class CBattleGameInterface;
|
class CBattleGameInterface;
|
||||||
|
@ -4008,7 +4008,7 @@ bool CGameHandler::isValidObject(const CGObjectInstance *obj) const
|
|||||||
return vstd::contains(gs->map->objects, obj);
|
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)
|
if (dynamic_cast<const PlayerMessage *>(pack) != nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
@ -27,7 +27,6 @@ class CCommanderInstance;
|
|||||||
class EVictoryLossCheckResult;
|
class EVictoryLossCheckResult;
|
||||||
class CRandomGenerator;
|
class CRandomGenerator;
|
||||||
|
|
||||||
struct CPack;
|
|
||||||
struct CPackForServer;
|
struct CPackForServer;
|
||||||
struct NewTurn;
|
struct NewTurn;
|
||||||
struct CGarrisonOperationPack;
|
struct CGarrisonOperationPack;
|
||||||
@ -89,7 +88,7 @@ public:
|
|||||||
CVCMIServer * gameLobby() const;
|
CVCMIServer * gameLobby() const;
|
||||||
|
|
||||||
bool isValidObject(const CGObjectInstance *obj) 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);
|
bool isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2);
|
||||||
void giveSpells(const CGTownInstance *t, const CGHeroInstance *h);
|
void giveSpells(const CGTownInstance *t, const CGHeroInstance *h);
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ CBattleQuery::CBattleQuery(CGameHandler * owner):
|
|||||||
belligerents[BattleSide::DEFENDER] = nullptr;
|
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)
|
if(dynamic_cast<const MakeAction*>(pack) != nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
CBattleQuery(CGameHandler * owner);
|
CBattleQuery(CGameHandler * owner);
|
||||||
CBattleQuery(CGameHandler * owner, const IBattleInfo * Bi); //TODO
|
CBattleQuery(CGameHandler * owner, const IBattleInfo * Bi); //TODO
|
||||||
void notifyObjectAboutRemoval(const CGObjectInstance * visitedObject, const CGHeroInstance * visitingHero) const override;
|
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 onRemoval(PlayerColor color) override;
|
||||||
void onExposure(QueryPtr topQuery) override;
|
void onExposure(QueryPtr topQuery) override;
|
||||||
};
|
};
|
||||||
|
@ -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;
|
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
|
//We accept only query replies from correct player
|
||||||
if(auto reply = dynamic_cast<const QueryReply*>(pack))
|
if(auto reply = dynamic_cast<const QueryReply*>(pack))
|
||||||
@ -132,7 +132,7 @@ bool CDialogQuery::endsByPlayerAnswer() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDialogQuery::blocksPack(const CPack * pack) const
|
bool CDialogQuery::blocksPack(const CPackForServer * pack) const
|
||||||
{
|
{
|
||||||
return blockAllButReply(pack);
|
return blockAllButReply(pack);
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ CGenericQuery::CGenericQuery(CGameHandler * gh, PlayerColor color, std::function
|
|||||||
addPlayer(color);
|
addPlayer(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGenericQuery::blocksPack(const CPack * pack) const
|
bool CGenericQuery::blocksPack(const CPackForServer * pack) const
|
||||||
{
|
{
|
||||||
return blockAllButReply(pack);
|
return blockAllButReply(pack);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
struct CPack;
|
struct CPackForServer;
|
||||||
class CGObjectInstance;
|
class CGObjectInstance;
|
||||||
class CGHeroInstance;
|
class CGHeroInstance;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public:
|
|||||||
CQuery(CGameHandler * gh);
|
CQuery(CGameHandler * gh);
|
||||||
|
|
||||||
/// query can block attempting actions by player. Eg. he can't move hero during the battle.
|
/// 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)
|
/// query is removed after player gives answer (like dialogs)
|
||||||
virtual bool endsByPlayerAnswer() const;
|
virtual bool endsByPlayerAnswer() const;
|
||||||
@ -71,7 +71,7 @@ protected:
|
|||||||
QueriesProcessor * owner;
|
QueriesProcessor * owner;
|
||||||
CGameHandler * gh;
|
CGameHandler * gh;
|
||||||
void addPlayer(PlayerColor color);
|
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);
|
std::ostream &operator<<(std::ostream &out, const CQuery &query);
|
||||||
@ -82,7 +82,7 @@ class CDialogQuery : public CQuery
|
|||||||
public:
|
public:
|
||||||
CDialogQuery(CGameHandler * owner);
|
CDialogQuery(CGameHandler * owner);
|
||||||
bool endsByPlayerAnswer() const override;
|
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;
|
void setReply(std::optional<int32_t> reply) override;
|
||||||
protected:
|
protected:
|
||||||
std::optional<ui32> answer;
|
std::optional<ui32> answer;
|
||||||
@ -93,7 +93,7 @@ class CGenericQuery : public CQuery
|
|||||||
public:
|
public:
|
||||||
CGenericQuery(CGameHandler * gh, PlayerColor color, std::function<void(std::optional<int32_t>)> Callback);
|
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;
|
bool endsByPlayerAnswer() const override;
|
||||||
void onExposure(QueryPtr topQuery) override;
|
void onExposure(QueryPtr topQuery) override;
|
||||||
void setReply(std::optional<int32_t> reply) override;
|
void setReply(std::optional<int32_t> reply) override;
|
||||||
|
@ -23,7 +23,7 @@ TimerPauseQuery::TimerPauseQuery(CGameHandler * owner, PlayerColor player):
|
|||||||
addPlayer(player);
|
addPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TimerPauseQuery::blocksPack(const CPack *pack) const
|
bool TimerPauseQuery::blocksPack(const CPackForServer *pack) const
|
||||||
{
|
{
|
||||||
return blockAllButReply(pack);
|
return blockAllButReply(pack);
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ CGarrisonDialogQuery::CGarrisonDialogQuery(CGameHandler * owner, const CArmedIns
|
|||||||
addPlayer(down->tempOwner);
|
addPlayer(down->tempOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGarrisonDialogQuery::blocksPack(const CPack * pack) const
|
bool CGarrisonDialogQuery::blocksPack(const CPackForServer * pack) const
|
||||||
{
|
{
|
||||||
std::set<ObjectInstanceID> ourIds;
|
std::set<ObjectInstanceID> ourIds;
|
||||||
ourIds.insert(this->exchangingArmies[0]->id);
|
ourIds.insert(this->exchangingArmies[0]->id);
|
||||||
@ -143,7 +143,7 @@ void OpenWindowQuery::onExposure(QueryPtr topQuery)
|
|||||||
//do nothing - wait for reply
|
//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)
|
if (mode == EOpenWindowMode::RECRUITMENT_FIRST || mode == EOpenWindowMode::RECRUITMENT_ALL)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ class TimerPauseQuery : public CQuery
|
|||||||
public:
|
public:
|
||||||
TimerPauseQuery(CGameHandler * owner, PlayerColor player);
|
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 onAdding(PlayerColor color) override;
|
||||||
void onRemoval(PlayerColor color) override;
|
void onRemoval(PlayerColor color) override;
|
||||||
bool endsByPlayerAnswer() const override;
|
bool endsByPlayerAnswer() const override;
|
||||||
@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
CGarrisonDialogQuery(CGameHandler * owner, const CArmedInstance *up, const CArmedInstance *down);
|
CGarrisonDialogQuery(CGameHandler * owner, const CArmedInstance *up, const CArmedInstance *down);
|
||||||
void notifyObjectAboutRemoval(const CGObjectInstance * visitedObject, const CGHeroInstance * visitingHero) const override;
|
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
|
//yes/no and component selection dialogs
|
||||||
@ -75,7 +75,7 @@ class OpenWindowQuery : public CDialogQuery
|
|||||||
public:
|
public:
|
||||||
OpenWindowQuery(CGameHandler * owner, const CGHeroInstance *hero, EOpenWindowMode mode);
|
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;
|
void onExposure(QueryPtr topQuery) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ VisitQuery::VisitQuery(CGameHandler * owner, const CGObjectInstance * Obj, const
|
|||||||
addPlayer(Hero->tempOwner);
|
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.
|
//During the visit itself ALL actions are blocked.
|
||||||
//(However, the visit may trigger a query above that'll pass some.)
|
//(However, the visit may trigger a query above that'll pass some.)
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
const CGObjectInstance * visitedObject;
|
const CGObjectInstance * visitedObject;
|
||||||
const CGHeroInstance * visitingHero;
|
const CGHeroInstance * visitingHero;
|
||||||
|
|
||||||
bool blocksPack(const CPack * pack) const final;
|
bool blocksPack(const CPackForServer * pack) const final;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapObjectVisitQuery final : public VisitQuery
|
class MapObjectVisitQuery final : public VisitQuery
|
||||||
|
Loading…
Reference in New Issue
Block a user