1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Split off some netpack structures into separate files

This commit is contained in:
Ivan Savenko
2023-10-23 13:59:15 +03:00
parent d1d4db26e0
commit b88a8da4e8
134 changed files with 1844 additions and 1619 deletions

View File

@@ -9,11 +9,8 @@
*/
#pragma once
#include <vcmi/Metatype.h>
#include "ConstTransitivePtr.h"
#include "GameConstants.h"
#include "JsonNode.h"
#include "../ConstTransitivePtr.h"
#include "../GameConstants.h"
class CClient;
class CGameHandler;
@@ -35,27 +32,6 @@ struct ArtSlotInfo;
class ICPackVisitor;
enum class EInfoWindowMode : uint8_t
{
AUTO,
MODAL,
INFO
};
enum class EOpenWindowMode : uint8_t
{
EXCHANGE_WINDOW,
RECRUITMENT_FIRST,
RECRUITMENT_ALL,
SHIPYARD_WINDOW,
THIEVES_GUILD,
UNIVERSITY_WINDOW,
HILL_FORT_WINDOW,
MARKET_WINDOW,
PUZZLE_MAP,
TAVERN_WINDOW
};
struct DLL_LINKAGE CPack
{
std::shared_ptr<CConnection> c; // Pointer to connection that pack received from
@@ -92,6 +68,11 @@ protected:
virtual void visitBasic(ICPackVisitor & cpackVisitor) override;
};
struct DLL_LINKAGE Query : public CPackForClient
{
QueryID queryID; // equals to -1 if it is not an actual query (and should not be answered)
};
struct DLL_LINKAGE CPackForServer : public CPack
{
mutable PlayerColor player = PlayerColor::NEUTRAL;
@@ -115,44 +96,6 @@ protected:
virtual void visitBasic(ICPackVisitor & cpackVisitor) override;
};
struct Component
{
enum class EComponentType : uint8_t
{
PRIM_SKILL,
SEC_SKILL,
RESOURCE,
CREATURE,
ARTIFACT,
EXPERIENCE,
SPELL,
MORALE,
LUCK,
BUILDING,
HERO_PORTRAIT,
FLAG,
INVALID //should be last
};
EComponentType id = EComponentType::INVALID;
ui16 subtype = 0; //id==EXPPERIENCE subtype==0 means exp points and subtype==1 levels
si32 val = 0; // + give; - take
si16 when = 0; // 0 - now; +x - within x days; -x - per x days
template <typename Handler> void serialize(Handler &h, const int version)
{
h & id;
h & subtype;
h & val;
h & when;
}
Component() = default;
DLL_LINKAGE explicit Component(const CStackBasicDescriptor &stack);
Component(Component::EComponentType Type, ui16 Subtype, si32 Val, si16 When)
:id(Type),subtype(Subtype),val(Val),when(When)
{
}
};
using TArtHolder = std::variant<ConstTransitivePtr<CGHeroInstance>, ConstTransitivePtr<CStackInstance>>;
struct ArtifactLocation
@@ -205,82 +148,4 @@ struct ArtifactLocation
}
};
class EntityChanges
{
public:
Metatype metatype = Metatype::UNKNOWN;
int32_t entityIndex = 0;
JsonNode data;
template <typename Handler> void serialize(Handler & h, const int version)
{
h & metatype;
h & entityIndex;
h & data;
}
};
class BattleChanges
{
public:
enum class EOperation : si8
{
ADD,
RESET_STATE,
UPDATE,
REMOVE,
};
JsonNode data;
EOperation operation = EOperation::RESET_STATE;
BattleChanges() = default;
BattleChanges(EOperation operation_)
: operation(operation_)
{
}
};
class UnitChanges : public BattleChanges
{
public:
uint32_t id = 0;
int64_t healthDelta = 0;
UnitChanges() = default;
UnitChanges(uint32_t id_, EOperation operation_)
: BattleChanges(operation_)
, id(id_)
{
}
template <typename Handler> void serialize(Handler & h, const int version)
{
h & id;
h & healthDelta;
h & data;
h & operation;
}
};
class ObstacleChanges : public BattleChanges
{
public:
uint32_t id = 0;
ObstacleChanges() = default;
ObstacleChanges(uint32_t id_, EOperation operation_)
: BattleChanges(operation_),
id(id_)
{
}
template <typename Handler> void serialize(Handler & h, const int version)
{
h & id;
h & data;
h & operation;
}
};
VCMI_LIB_NAMESPACE_END