1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-20 20:23:03 +02:00

CGameHandler: rename CPackForClient argument and add network logging

This commit is contained in:
Arseniy Shestakov 2018-02-26 00:16:15 +08:00
parent 674242da54
commit 74e5c5bf05
9 changed files with 36 additions and 35 deletions

View File

@ -203,7 +203,7 @@ public:
void setManaPoints(ObjectInstanceID hid, int val) override {};
void giveHero(ObjectInstanceID id, PlayerColor player) override {};
void changeObjPos(ObjectInstanceID objid, int3 newPos, ui8 flags) override {};
void sendAndApply(CPackForClient * info) override {};
void sendAndApply(CPackForClient * pack) override {};
void heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2) override {};
void changeFogOfWar(int3 center, ui32 radius, PlayerColor player, bool hide) override {}

View File

@ -91,7 +91,7 @@ public:
virtual void setManaPoints(ObjectInstanceID hid, int val)=0;
virtual void giveHero(ObjectInstanceID id, PlayerColor player)=0;
virtual void changeObjPos(ObjectInstanceID objid, int3 newPos, ui8 flags)=0;
virtual void sendAndApply(CPackForClient * info)=0;
virtual void sendAndApply(CPackForClient * pack) = 0;
virtual void heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2)=0; //when two heroes meet on adventure map
virtual void changeFogOfWar(int3 center, ui32 radius, PlayerColor player, bool hide) = 0;
virtual void changeFogOfWar(std::unordered_set<int3, ShashInt3> &tiles, PlayerColor player, bool hide) = 0;

View File

@ -207,7 +207,7 @@ CPack * CConnection::retrievePack()
CPack * pack = nullptr;
boost::unique_lock<boost::mutex> lock(*mutexRead);
iser & pack;
logNetwork->trace("\treceived CPack of type %s", (pack ? typeid(*pack).name() : "nullptr"));
logNetwork->trace("Received CPack of type %s", (pack ? typeid(*pack).name() : "nullptr"));
if(pack == nullptr)
{
logNetwork->error("Received a nullptr CPack! You should check whether client and server ABI matches.");

View File

@ -60,7 +60,7 @@ class DLL_LINKAGE PacketSender
{
public:
virtual ~PacketSender(){};
virtual void sendAndApply(CPackForClient * info) const = 0;
virtual void sendAndApply(CPackForClient * pack) const = 0;
virtual void complain(const std::string & problem) const = 0;
};

View File

@ -61,7 +61,7 @@ class ServerSpellCastEnvironment : public SpellCastEnvironment
public:
ServerSpellCastEnvironment(CGameHandler * gh);
~ServerSpellCastEnvironment() = default;
void sendAndApply(CPackForClient * info) const override;
void sendAndApply(CPackForClient * pack) const override;
CRandomGenerator & getRandomGenerator() const override;
void complain(const std::string & problem) const override;
const CMap * getMap() const override;
@ -2694,46 +2694,47 @@ void CGameHandler::heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2)
}
}
void CGameHandler::sendToAllClients(CPackForClient * info)
void CGameHandler::sendToAllClients(CPackForClient * pack)
{
logNetwork->trace("Sending to all clients a package of type %s", typeid(*info).name());
logNetwork->trace("\tSending to all clients: %s", typeid(*pack).name());
for (auto c : lobby->connections)
{
if(!c->isOpen())
continue;
c->sendPack(info);
c->sendPack(pack);
}
}
void CGameHandler::sendAndApply(CPackForClient * info)
void CGameHandler::sendAndApply(CPackForClient * pack)
{
sendToAllClients(info);
gs->apply(info);
sendToAllClients(pack);
gs->apply(pack);
logNetwork->trace("\tApplied on gs: %s", typeid(*pack).name());
}
void CGameHandler::applyAndSend(CPackForClient * info)
void CGameHandler::applyAndSend(CPackForClient * pack)
{
gs->apply(info);
sendToAllClients(info);
gs->apply(pack);
sendToAllClients(pack);
}
void CGameHandler::sendAndApply(CGarrisonOperationPack * info)
void CGameHandler::sendAndApply(CGarrisonOperationPack * pack)
{
sendAndApply(static_cast<CPackForClient*>(info));
sendAndApply(static_cast<CPackForClient *>(pack));
checkVictoryLossConditionsForAll();
}
void CGameHandler::sendAndApply(SetResources * info)
void CGameHandler::sendAndApply(SetResources * pack)
{
sendAndApply(static_cast<CPackForClient*>(info));
checkVictoryLossConditionsForPlayer(info->player);
sendAndApply(static_cast<CPackForClient *>(pack));
checkVictoryLossConditionsForPlayer(pack->player);
}
void CGameHandler::sendAndApply(NewStructures * info)
void CGameHandler::sendAndApply(NewStructures * pack)
{
sendAndApply(static_cast<CPackForClient*>(info));
checkVictoryLossConditionsForPlayer(getTown(info->tid)->tempOwner);
sendAndApply(static_cast<CPackForClient *>(pack));
checkVictoryLossConditionsForPlayer(getTown(pack->tid)->tempOwner);
}
void CGameHandler::save(const std::string & filename)
@ -6726,9 +6727,9 @@ ServerSpellCastEnvironment::ServerSpellCastEnvironment(CGameHandler * gh): gh(gh
}
void ServerSpellCastEnvironment::sendAndApply(CPackForClient * info) const
void ServerSpellCastEnvironment::sendAndApply(CPackForClient * pack) const
{
gh->sendAndApply(info);
gh->sendAndApply(pack);
}
CRandomGenerator & ServerSpellCastEnvironment::getRandomGenerator() const

View File

@ -254,12 +254,12 @@ public:
void sendMessageToAll(const std::string &message);
void sendMessageTo(std::shared_ptr<CConnection> c, const std::string &message);
void sendToAllClients(CPackForClient * info);
void sendAndApply(CPackForClient * info) override;
void applyAndSend(CPackForClient * info);
void sendAndApply(CGarrisonOperationPack * info);
void sendAndApply(SetResources * info);
void sendAndApply(NewStructures * info);
void sendToAllClients(CPackForClient * pack);
void sendAndApply(CPackForClient * pack) override;
void applyAndSend(CPackForClient * pack);
void sendAndApply(CGarrisonOperationPack * pack);
void sendAndApply(SetResources * pack);
void sendAndApply(NewStructures * pack);
struct FinishingBattleHelper
{

View File

@ -44,9 +44,9 @@ public:
IObjectInterface::cb = nullptr;
}
void sendAndApply(CPackForClient * info) const override
void sendAndApply(CPackForClient * pack) const override
{
gameState->apply(info);
gameState->apply(pack);
}
void complain(const std::string & problem) const

View File

@ -32,7 +32,7 @@ void GameCallbackMock::commitPackage(CPackForClient * pack)
sendAndApply(pack);
}
void GameCallbackMock::sendAndApply(CPackForClient * info)
void GameCallbackMock::sendAndApply(CPackForClient * pack)
{
upperCallback->sendAndApply(info);
upperCallback->sendAndApply(pack);
}

View File

@ -86,7 +86,7 @@ public:
///useful callback methods
void commitPackage(CPackForClient * pack) override;
void sendAndApply(CPackForClient * info) override;
void sendAndApply(CPackForClient * pack) override;
private:
const UpperCallback * upperCallback;
};