mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
* Refactor to result GameActions::Result as copy instead of unique_ptr * Remove alias GameActions::Result::Ptr * Remove MakeResult wrapper * Remove type forwarder in TileInspector
This commit is contained in:
@@ -3450,7 +3450,7 @@ void network_chat_show_server_greeting()
|
||||
}
|
||||
}
|
||||
|
||||
GameActions::Result::Ptr network_set_player_group(
|
||||
GameActions::Result network_set_player_group(
|
||||
NetworkPlayerId_t actionPlayerId, NetworkPlayerId_t playerId, uint8_t groupId, bool isExecuting)
|
||||
{
|
||||
auto& network = OpenRCT2::GetContext()->GetNetwork();
|
||||
@@ -3459,24 +3459,23 @@ GameActions::Result::Ptr network_set_player_group(
|
||||
NetworkGroup* fromgroup = network.GetGroupByID(actionPlayerId);
|
||||
if (player == nullptr)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(GameActions::Status::InvalidParameters, STR_CANT_DO_THIS, STR_NONE);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_DO_THIS, STR_NONE);
|
||||
}
|
||||
|
||||
if (network.GetGroupByID(groupId) == nullptr)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(GameActions::Status::InvalidParameters, STR_CANT_DO_THIS, STR_NONE);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_DO_THIS, STR_NONE);
|
||||
}
|
||||
|
||||
if (player->Flags & NETWORK_PLAYER_FLAG_ISSERVER)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_CHANGE_GROUP_THAT_THE_HOST_BELONGS_TO, STR_NONE);
|
||||
}
|
||||
|
||||
if (groupId == 0 && fromgroup != nullptr && fromgroup->Id != 0)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_SET_TO_THIS_GROUP, STR_NONE);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_SET_TO_THIS_GROUP, STR_NONE);
|
||||
}
|
||||
|
||||
if (isExecuting)
|
||||
@@ -3507,10 +3506,10 @@ GameActions::Result::Ptr network_set_player_group(
|
||||
format_string(log_msg, 256, STR_LOG_SET_PLAYER_GROUP, args);
|
||||
network_append_server_log(log_msg);
|
||||
}
|
||||
return std::make_unique<GameActions::Result>();
|
||||
return GameActions::Result();
|
||||
}
|
||||
|
||||
GameActions::Result::Ptr network_modify_groups(
|
||||
GameActions::Result network_modify_groups(
|
||||
NetworkPlayerId_t actionPlayerId, ModifyGroupType type, uint8_t groupId, const std::string& name, uint32_t permissionIndex,
|
||||
PermissionState permissionState, bool isExecuting)
|
||||
{
|
||||
@@ -3524,7 +3523,7 @@ GameActions::Result::Ptr network_modify_groups(
|
||||
NetworkGroup* newgroup = network.AddGroup();
|
||||
if (newgroup == nullptr)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(GameActions::Status::Unknown, STR_CANT_DO_THIS, STR_NONE);
|
||||
return GameActions::Result(GameActions::Status::Unknown, STR_CANT_DO_THIS, STR_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3533,14 +3532,13 @@ GameActions::Result::Ptr network_modify_groups(
|
||||
{
|
||||
if (groupId == 0)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(
|
||||
GameActions::Status::Disallowed, STR_THIS_GROUP_CANNOT_BE_MODIFIED, STR_NONE);
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_THIS_GROUP_CANNOT_BE_MODIFIED, STR_NONE);
|
||||
}
|
||||
for (const auto& it : network.player_list)
|
||||
{
|
||||
if ((it.get())->Group == groupId)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(
|
||||
return GameActions::Result(
|
||||
GameActions::Status::Disallowed, STR_CANT_REMOVE_GROUP_THAT_PLAYERS_BELONG_TO, STR_NONE);
|
||||
}
|
||||
}
|
||||
@@ -3554,8 +3552,7 @@ GameActions::Result::Ptr network_modify_groups(
|
||||
{
|
||||
if (groupId == 0)
|
||||
{ // can't change admin group permissions
|
||||
return std::make_unique<GameActions::Result>(
|
||||
GameActions::Status::Disallowed, STR_THIS_GROUP_CANNOT_BE_MODIFIED, STR_NONE);
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_THIS_GROUP_CANNOT_BE_MODIFIED, STR_NONE);
|
||||
}
|
||||
NetworkGroup* mygroup = nullptr;
|
||||
NetworkPlayer* player = network.GetPlayerByID(actionPlayerId);
|
||||
@@ -3565,7 +3562,7 @@ GameActions::Result::Ptr network_modify_groups(
|
||||
mygroup = network.GetGroupByID(player->Group);
|
||||
if (mygroup == nullptr || !mygroup->CanPerformAction(networkPermission))
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(
|
||||
return GameActions::Result(
|
||||
GameActions::Status::Disallowed, STR_CANT_MODIFY_PERMISSION_THAT_YOU_DO_NOT_HAVE_YOURSELF, STR_NONE);
|
||||
}
|
||||
}
|
||||
@@ -3603,12 +3600,12 @@ GameActions::Result::Ptr network_modify_groups(
|
||||
|
||||
if (strcmp(oldName, name.c_str()) == 0)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>();
|
||||
return GameActions::Result();
|
||||
}
|
||||
|
||||
if (name.empty())
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_RENAME_GROUP, STR_INVALID_GROUP_NAME);
|
||||
}
|
||||
|
||||
@@ -3625,8 +3622,7 @@ GameActions::Result::Ptr network_modify_groups(
|
||||
{
|
||||
if (groupId == 0)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(
|
||||
GameActions::Status::Disallowed, STR_CANT_SET_TO_THIS_GROUP, STR_NONE);
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_CANT_SET_TO_THIS_GROUP, STR_NONE);
|
||||
}
|
||||
if (isExecuting)
|
||||
{
|
||||
@@ -3636,15 +3632,15 @@ GameActions::Result::Ptr network_modify_groups(
|
||||
break;
|
||||
default:
|
||||
log_error("Invalid Modify Group Type: %u", static_cast<uint8_t>(type));
|
||||
return std::make_unique<GameActions::Result>(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE);
|
||||
}
|
||||
|
||||
network.SaveGroups();
|
||||
|
||||
return std::make_unique<GameActions::Result>();
|
||||
return GameActions::Result();
|
||||
}
|
||||
|
||||
GameActions::Result::Ptr network_kick_player(NetworkPlayerId_t playerId, bool isExecuting)
|
||||
GameActions::Result network_kick_player(NetworkPlayerId_t playerId, bool isExecuting)
|
||||
{
|
||||
auto& network = OpenRCT2::GetContext()->GetNetwork();
|
||||
NetworkPlayer* player = network.GetPlayerByID(playerId);
|
||||
@@ -3652,12 +3648,12 @@ GameActions::Result::Ptr network_kick_player(NetworkPlayerId_t playerId, bool is
|
||||
{
|
||||
// Player might be already removed by the PLAYERLIST command, need to refactor non-game commands executing too
|
||||
// early.
|
||||
return std::make_unique<GameActions::Result>(GameActions::Status::Unknown, STR_NONE, STR_NONE);
|
||||
return GameActions::Result(GameActions::Status::Unknown, STR_NONE, STR_NONE);
|
||||
}
|
||||
|
||||
if (player->Flags & NETWORK_PLAYER_FLAG_ISSERVER)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(GameActions::Status::Disallowed, STR_CANT_KICK_THE_HOST, STR_NONE);
|
||||
return GameActions::Result(GameActions::Status::Disallowed, STR_CANT_KICK_THE_HOST, STR_NONE);
|
||||
}
|
||||
|
||||
if (isExecuting)
|
||||
@@ -3672,7 +3668,7 @@ GameActions::Result::Ptr network_kick_player(NetworkPlayerId_t playerId, bool is
|
||||
networkUserManager.Save();
|
||||
}
|
||||
}
|
||||
return std::make_unique<GameActions::Result>();
|
||||
return GameActions::Result();
|
||||
}
|
||||
|
||||
uint8_t network_get_default_group()
|
||||
@@ -4094,20 +4090,20 @@ const char* network_get_group_name(uint32_t index)
|
||||
return "";
|
||||
};
|
||||
|
||||
GameActions::Result::Ptr network_set_player_group(
|
||||
GameActions::Result network_set_player_group(
|
||||
NetworkPlayerId_t actionPlayerId, NetworkPlayerId_t playerId, uint8_t groupId, bool isExecuting)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>();
|
||||
return GameActions::Result();
|
||||
}
|
||||
GameActions::Result::Ptr network_modify_groups(
|
||||
GameActions::Result network_modify_groups(
|
||||
NetworkPlayerId_t actionPlayerId, ModifyGroupType type, uint8_t groupId, const std::string& name, uint32_t permissionIndex,
|
||||
PermissionState permissionState, bool isExecuting)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>();
|
||||
return GameActions::Result();
|
||||
}
|
||||
GameActions::Result::Ptr network_kick_player(NetworkPlayerId_t playerId, bool isExecuting)
|
||||
GameActions::Result network_kick_player(NetworkPlayerId_t playerId, bool isExecuting)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>();
|
||||
return GameActions::Result();
|
||||
}
|
||||
uint8_t network_get_default_group()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user