mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
Split off some netpack structures into separate files
This commit is contained in:
81
lib/networkPacks/BattleChanges.h
Normal file
81
lib/networkPacks/BattleChanges.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* BattleChanges.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 "JsonNode.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class BattleChanges
|
||||
{
|
||||
public:
|
||||
enum class EOperation : si8
|
||||
{
|
||||
ADD,
|
||||
RESET_STATE,
|
||||
UPDATE,
|
||||
REMOVE,
|
||||
};
|
||||
|
||||
JsonNode data;
|
||||
EOperation operation = EOperation::RESET_STATE;
|
||||
|
||||
BattleChanges() = default;
|
||||
explicit 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
|
||||
|
||||
Reference in New Issue
Block a user