return false;
}
-
+// this macro exists only to shorten code lines
+#define MINIGAME_CMD(cmd_id) MINIGAME_COMMON_CMD[MINIGAME_COMMON_CMD_ID_##cmd_id]
void ClientCommand_minigame(entity caller, int request, int argc, string command)
{
if (request == CMD_REQUEST_COMMAND )
{
string minig_cmd = argv(1);
- if ( minig_cmd == "create" && argc > 2 )
+ if ( minig_cmd == MINIGAME_CMD(CREATE) && argc > 2 )
{
entity minig = start_minigame(caller, argv(2));
if ( minig )
sprint(caller,"Cannot start minigame session!\n");
return;
}
- else if ( minig_cmd == "join" && argc > 2 )
+ else if ( minig_cmd == MINIGAME_CMD(JOIN) && argc > 2 )
{
entity minig = join_minigame(caller, argv(2));
if ( minig )
}
return;
}
- else if ( minig_cmd == "list" )
+ else if ( minig_cmd == MINIGAME_CMD(LIST) )
{
FOREACH(Minigames, true, sprint(caller, it.netname, " (", it.message, ") ", "\n"));
return;
}
- else if ( minig_cmd == "list-sessions" )
+ else if ( minig_cmd == MINIGAME_CMD(LIST_SESSIONS) )
{
entity e;
for ( e = minigame_sessions; e != NULL; e = e.list_next )
sprint(caller,e.netname,"\n");
return;
}
- else if ( minig_cmd == "end" || minig_cmd == "part" )
+ else if ( minig_cmd == MINIGAME_CMD(END) || minig_cmd == MINIGAME_CMD(PART) )
{
if ( CS(caller).active_minigame )
{
sprint(caller,"You aren't playing any minigame...\n");
return;
}
- else if ( minig_cmd == "invite" && argc > 2 )
+ else if ( minig_cmd == MINIGAME_CMD(INVITE) && argc > 2 )
{
if ( CS(caller).active_minigame )
{
#pragma once
+enum
+{
+ MINIGAME_COMMON_CMD_ID_CREATE,
+ MINIGAME_COMMON_CMD_ID_JOIN,
+ MINIGAME_COMMON_CMD_ID_LIST,
+ MINIGAME_COMMON_CMD_ID_LIST_SESSIONS,
+ MINIGAME_COMMON_CMD_ID_END,
+ MINIGAME_COMMON_CMD_ID_PART,
+ MINIGAME_COMMON_CMD_ID_INVITE,
+ MINIGAME_COMMON_CMD_COUNT
+};
+string MINIGAME_COMMON_CMD[MINIGAME_COMMON_CMD_COUNT] =
+ {"create", "join", "list", "list-sessions", "end", "part", "invite"};
+
bool autocvar_sv_minigames;
bool autocvar_sv_minigames_observer;
case "sentcvar": break; // handled by server in this file
case "spawn": break; // handled by engine in host_cmd.c
case "say": case "say_team": case "tell": break; // chat has its own flood control in chat.qc
+ case "minigame": // flood control only for common commands
+ string arg = argv(1);
+ if (arg == "")
+ goto flood_control;
+ for (int i = 0; i < MINIGAME_COMMON_CMD_COUNT; ++i)
+ {
+ if (MINIGAME_COMMON_CMD[i] == arg)
+ goto flood_control;
+ }
+ // if we get here we haven't found any common command, so no flood control for other commands
+ // individual minigame commands shouldn't be limited for gameplay reasons
+ // FIXME unknown/wrong minigame commands have no flood control
+ break;
case "color": case "topcolor": case "bottomcolor": // handled by engine in host_cmd.c
if(!IS_CLIENT(this)) // on connection
{
if(!IS_CLIENT(this)) break;
// else fall through to default: flood control
default:
+ LABEL(flood_control)
if (!timeout_status) // not while paused
{
entity store = IS_CLIENT(this) ? CS(this) : this; // unfortunately, we need to store these on the client initially