1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-21 05:53:02 +01:00

Create "misc_commands" enum

This commit is contained in:
wolfreak99
2017-01-21 06:43:16 -05:00
committed by Michael Steenbeek
parent 4b0f45a740
commit a15a3fedf7
3 changed files with 13 additions and 7 deletions

View File

@@ -67,7 +67,7 @@ const std::vector<NetworkAction> NetworkActions::Actions =
{
STR_ACTION_CHAT, "PERMISSION_CHAT",
{
-1
MISC_COMMAND_CHAT
}
}, {
STR_ACTION_TERRAFORM, "PERMISSION_TERRAFORM",
@@ -214,12 +214,12 @@ const std::vector<NetworkAction> NetworkActions::Actions =
}, {
STR_ACTION_TOGGLE_SCENERY_CLUSTER, "PERMISSION_TOGGLE_SCENERY_CLUSTER",
{
-2
MISC_COMMAND_TOGGLE_SCENERY_CLUSTER
}
}, {
STR_ACTION_PASSWORDLESS_LOGIN, "PERMISSION_PASSWORDLESS_LOGIN",
{
-3
MISC_COMMAND_PASSWORDLESS_LOGIN
}
},
};

View File

@@ -20,6 +20,13 @@
#include <string>
#include "../common.h"
enum MISC_COMMAND
{
MISC_COMMAND_CHAT = -1,
MISC_COMMAND_TOGGLE_SCENERY_CLUSTER = -2,
MISC_COMMAND_PASSWORDLESS_LOGIN = -3,
};
class NetworkAction final
{
public:

View File

@@ -1567,8 +1567,7 @@ void Network::Server_Handle_AUTH(NetworkConnection& connection, NetworkPacket& p
bool passwordless = false;
if (connection.AuthStatus == NETWORK_AUTH_VERIFIED) {
const NetworkGroup * group = GetGroupByID(GetGroupIDByHash(connection.Key.PublicKeyHash()));
size_t actionIndex = NetworkActions::FindCommandByPermissionName("PERMISSION_PASSWORDLESS_LOGIN");
passwordless = group->CanPerformAction(actionIndex);
passwordless = group->CanPerformCommand(MISC_COMMAND_PASSWORDLESS_LOGIN);
}
if (!gameversion || strcmp(gameversion, NETWORK_STREAM_ID) != 0) {
connection.AuthStatus = NETWORK_AUTH_BADVERSION;
@@ -1677,7 +1676,7 @@ void Network::Server_Handle_CHAT(NetworkConnection& connection, NetworkPacket& p
{
if (connection.Player) {
NetworkGroup* group = GetGroupByID(connection.Player->Group);
if (!group || (group && !group->CanPerformCommand(-1))) {
if (!group || (group && !group->CanPerformCommand(MISC_COMMAND_CHAT))) {
return;
}
}
@@ -1731,7 +1730,7 @@ void Network::Server_Handle_GAMECMD(NetworkConnection& connection, NetworkPacket
// cluster mode is a for loop that runs the place_scenery code multiple times.
if (commandCommand == GAME_COMMAND_PLACE_SCENERY) {
if ((ticks - connection.Player->LastActionTime) < 20) {
if (!(group->CanPerformCommand(-2))) {
if (!(group->CanPerformCommand(MISC_COMMAND_TOGGLE_SCENERY_CLUSTER))) {
Server_Send_SHOWERROR(connection, STR_CANT_DO_THIS, STR_CANT_DO_THIS);
return;
}