2019-05-12 19:54:41 +02:00
|
|
|
/*****************************************************************************
|
2020-07-21 15:04:34 +02:00
|
|
|
* Copyright (c) 2014-2020 OpenRCT2 developers
|
2019-05-12 19:54:41 +02:00
|
|
|
*
|
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
|
|
|
*
|
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../network/network.h"
|
2020-10-03 04:52:53 +02:00
|
|
|
#include "../util/Util.h"
|
2019-05-12 19:54:41 +02:00
|
|
|
#include "GameAction.h"
|
|
|
|
|
|
|
|
enum class ModifyGroupType : uint8_t
|
|
|
|
{
|
|
|
|
AddGroup,
|
|
|
|
RemoveGroup,
|
|
|
|
SetPermissions,
|
|
|
|
SetName,
|
|
|
|
SetDefault,
|
|
|
|
Count
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class PermissionState : uint8_t
|
|
|
|
{
|
|
|
|
Toggle,
|
|
|
|
SetAll,
|
|
|
|
ClearAll,
|
|
|
|
Count
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_GAME_ACTION(NetworkModifyGroupAction, GAME_COMMAND_MODIFY_GROUPS, GameActionResult)
|
|
|
|
{
|
|
|
|
private:
|
2020-10-03 05:13:06 +02:00
|
|
|
ModifyGroupType _type{ ModifyGroupType::Count };
|
2019-05-12 19:54:41 +02:00
|
|
|
uint8_t _groupId{ std::numeric_limits<uint8_t>::max() };
|
|
|
|
std::string _name;
|
|
|
|
uint32_t _permissionIndex{ std::numeric_limits<uint32_t>::max() };
|
2020-10-03 05:13:06 +02:00
|
|
|
PermissionState _permissionState{ PermissionState::Count };
|
2019-05-12 19:54:41 +02:00
|
|
|
|
|
|
|
public:
|
2019-05-13 20:49:06 +02:00
|
|
|
NetworkModifyGroupAction() = default;
|
2019-05-12 19:54:41 +02:00
|
|
|
|
2019-05-13 20:53:33 +02:00
|
|
|
NetworkModifyGroupAction(
|
|
|
|
ModifyGroupType type, uint8_t groupId = std::numeric_limits<uint8_t>::max(), const std::string name = "",
|
|
|
|
uint32_t permissionIndex = 0, PermissionState permissionState = PermissionState::Count)
|
2020-10-03 05:13:06 +02:00
|
|
|
: _type(type)
|
2019-05-12 19:54:41 +02:00
|
|
|
, _groupId(groupId)
|
|
|
|
, _name(name)
|
|
|
|
, _permissionIndex(permissionIndex)
|
2020-10-03 05:13:06 +02:00
|
|
|
, _permissionState(permissionState)
|
2019-05-12 19:54:41 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t GetActionFlags() const override
|
|
|
|
{
|
|
|
|
return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Serialise(DataSerialiser & stream) override
|
|
|
|
{
|
|
|
|
GameAction::Serialise(stream);
|
|
|
|
|
|
|
|
stream << DS_TAG(_type) << DS_TAG(_groupId) << DS_TAG(_name) << DS_TAG(_permissionIndex) << DS_TAG(_permissionState);
|
|
|
|
}
|
|
|
|
|
|
|
|
GameActionResult::Ptr Query() const override
|
|
|
|
{
|
2020-10-03 05:13:06 +02:00
|
|
|
return network_modify_groups(GetPlayer(), _type, _groupId, _name, _permissionIndex, _permissionState, false);
|
2019-05-12 19:54:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GameActionResult::Ptr Execute() const override
|
|
|
|
{
|
2020-10-03 05:13:06 +02:00
|
|
|
return network_modify_groups(GetPlayer(), _type, _groupId, _name, _permissionIndex, _permissionState, true);
|
2019-05-12 19:54:41 +02:00
|
|
|
}
|
|
|
|
};
|