2018-01-05 19:21:07 +02:00
|
|
|
/*
|
|
|
|
* NetPacksLobby.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "NetPacksBase.h"
|
|
|
|
|
|
|
|
#include "StartInfo.h"
|
|
|
|
|
|
|
|
class CServerHandler;
|
2022-07-26 15:07:42 +02:00
|
|
|
class CVCMIServer;
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-06-25 20:16:03 +02:00
|
|
|
class CampaignState;
|
2018-01-05 19:21:07 +02:00
|
|
|
class CMapInfo;
|
|
|
|
struct StartInfo;
|
|
|
|
class CMapGenOptions;
|
|
|
|
struct ClientPlayer;
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE CLobbyPackToPropagate : public CPackForLobby
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE CLobbyPackToServer : public CPackForLobby
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual bool isForServer() const override;
|
2018-01-05 19:21:07 +02:00
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbyClientConnected : public CLobbyPackToPropagate
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
|
|
|
// Set by client before sending pack to server
|
|
|
|
std::string uuid;
|
|
|
|
std::vector<std::string> names;
|
2023-02-09 18:06:02 +02:00
|
|
|
StartInfo::EMode mode = StartInfo::INVALID;
|
2018-01-05 19:21:07 +02:00
|
|
|
// Changed by server before announcing pack
|
2023-02-09 18:06:02 +02:00
|
|
|
int clientId = -1;
|
|
|
|
int hostClientId = -1;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler & h, const int version)
|
|
|
|
{
|
|
|
|
h & uuid;
|
|
|
|
h & names;
|
|
|
|
h & mode;
|
|
|
|
|
|
|
|
h & clientId;
|
|
|
|
h & hostClientId;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbyClientDisconnected : public CLobbyPackToPropagate
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
|
|
|
int clientId;
|
2023-02-09 18:06:02 +02:00
|
|
|
bool shutdownServer = false;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
|
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & clientId;
|
|
|
|
h & shutdownServer;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbyChatMessage : public CLobbyPackToPropagate
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
|
|
|
std::string playerName, message;
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & playerName;
|
|
|
|
h & message;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbyGuiAction : public CLobbyPackToPropagate
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
|
|
|
enum EAction : ui8 {
|
|
|
|
NONE, NO_TAB, OPEN_OPTIONS, OPEN_SCENARIO_LIST, OPEN_RANDOM_MAP_OPTIONS
|
2023-02-09 18:06:02 +02:00
|
|
|
} action = NONE;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
|
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & action;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-08-21 03:06:58 +02:00
|
|
|
struct DLL_LINKAGE LobbyLoadProgress : public CLobbyPackToPropagate
|
|
|
|
{
|
|
|
|
unsigned char progress;
|
|
|
|
|
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & progress;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbyEndGame : public CLobbyPackToPropagate
|
2022-09-29 19:08:05 +02:00
|
|
|
{
|
|
|
|
bool closeConnection = false, restart = false;
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2022-09-29 19:08:05 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & closeConnection;
|
|
|
|
h & restart;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbyStartGame : public CLobbyPackToPropagate
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
|
|
|
// Set by server
|
2023-02-09 18:06:02 +02:00
|
|
|
std::shared_ptr<StartInfo> initializedStartInfo = nullptr;
|
|
|
|
CGameState * initializedGameState = nullptr;
|
|
|
|
int clientId = -1; //-1 means to all clients
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2022-10-01 16:28:45 +02:00
|
|
|
h & clientId;
|
2018-01-05 19:21:07 +02:00
|
|
|
h & initializedStartInfo;
|
2022-09-28 21:15:05 +02:00
|
|
|
bool sps = h.smartPointerSerialization;
|
|
|
|
h.smartPointerSerialization = true;
|
|
|
|
h & initializedGameState;
|
|
|
|
h.smartPointerSerialization = sps;
|
2018-01-05 19:21:07 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbyChangeHost : public CLobbyPackToPropagate
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
int newHostConnectionId = -1;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler & h, const int version)
|
|
|
|
{
|
|
|
|
h & newHostConnectionId;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbyUpdateState : public CLobbyPackToPropagate
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
|
|
|
LobbyState state;
|
2023-02-09 18:06:02 +02:00
|
|
|
bool hostChanged = false; // Used on client-side only
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & state;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbySetMap : public CLobbyPackToServer
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
|
|
|
std::shared_ptr<CMapInfo> mapInfo;
|
|
|
|
std::shared_ptr<CMapGenOptions> mapGenOpts;
|
|
|
|
|
|
|
|
LobbySetMap() : mapInfo(nullptr), mapGenOpts(nullptr) {}
|
2023-02-12 09:23:39 +02:00
|
|
|
|
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & mapInfo;
|
|
|
|
h & mapGenOpts;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbySetCampaign : public CLobbyPackToServer
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2023-06-25 20:16:03 +02:00
|
|
|
std::shared_ptr<CampaignState> ourCampaign;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & ourCampaign;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbySetCampaignMap : public CLobbyPackToServer
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2023-06-25 20:16:03 +02:00
|
|
|
CampaignScenarioID mapId = CampaignScenarioID::NONE;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & mapId;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbySetCampaignBonus : public CLobbyPackToServer
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
int bonusId = -1;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & bonusId;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbyChangePlayerOption : public CLobbyPackToServer
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2023-08-14 00:08:48 +02:00
|
|
|
enum EWhat : ui8 {UNKNOWN, TOWN, HERO, BONUS, TOWN_ID, HERO_ID, BONUS_ID};
|
2023-02-09 18:06:02 +02:00
|
|
|
ui8 what = UNKNOWN;
|
2023-08-17 17:29:31 +02:00
|
|
|
int32_t value = 0;
|
2023-02-09 18:06:02 +02:00
|
|
|
PlayerColor color = PlayerColor::CANNOT_DETERMINE;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & what;
|
2023-08-14 00:08:48 +02:00
|
|
|
h & value;
|
2018-01-05 19:21:07 +02:00
|
|
|
h & color;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbySetPlayer : public CLobbyPackToServer
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
PlayerColor clickedColor = PlayerColor::CANNOT_DETERMINE;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & clickedColor;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-09-22 18:57:43 +02:00
|
|
|
struct DLL_LINKAGE LobbySetSimturns : public CLobbyPackToServer
|
|
|
|
{
|
|
|
|
SimturnsInfo simturnsInfo;
|
|
|
|
|
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & simturnsInfo;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbySetTurnTime : public CLobbyPackToServer
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2023-08-14 00:16:25 +02:00
|
|
|
TurnTimerInfo turnTimerInfo;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2023-08-14 00:16:25 +02:00
|
|
|
h & turnTimerInfo;
|
2018-01-05 19:21:07 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbySetDifficulty : public CLobbyPackToServer
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
ui8 difficulty = 0;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & difficulty;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbyForceSetPlayer : public CLobbyPackToServer
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
ui8 targetConnectedPlayer = -1;
|
|
|
|
PlayerColor targetPlayerColor = PlayerColor::CANNOT_DETERMINE;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler & h, const int version)
|
|
|
|
{
|
|
|
|
h & targetConnectedPlayer;
|
|
|
|
h & targetPlayerColor;
|
|
|
|
}
|
|
|
|
};
|
2022-09-23 13:02:19 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
struct DLL_LINKAGE LobbyShowMessage : public CLobbyPackToPropagate
|
2022-09-23 13:02:19 +02:00
|
|
|
{
|
|
|
|
std::string message;
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
virtual void visitTyped(ICPackVisitor & visitor) override;
|
2022-09-23 13:02:19 +02:00
|
|
|
|
2022-09-24 11:03:46 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h, const int version)
|
2022-09-23 13:02:19 +02:00
|
|
|
{
|
|
|
|
h & message;
|
|
|
|
}
|
|
|
|
};
|
2022-09-25 11:26:07 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|