/* ================= ConsoleCommand ================= */ qboolean ConsoleCommand( void ) { char cmd[MAX_TOKEN_CHARS]; trap_Argv( 0, cmd, sizeof( cmd ) ); #ifdef SAVEGAME_SUPPORT if (Q_stricmp (cmd, "savegame") == 0) { if( g_gametype.integer != GT_SINGLE_PLAYER ) return qtrue; // don't allow a manual savegame command while we are waiting for the game to start/exit if (g_reloading.integer) return qtrue; if (saveGamePending) return qtrue; trap_Argv( 1, cmd, sizeof( cmd ) ); if (strlen(cmd) > 0) { // strip the extension if provided if (strrchr(cmd, '.')) { cmd[strrchr(cmd,'.')-cmd] = '\0'; } if ( !Q_stricmp( cmd, "current") ) { // beginning of map Com_Printf("sorry, '%s' is a reserved savegame name. please use another name.\n", cmd); return qtrue; } if (G_SaveGame( cmd )) trap_SendServerCommand(-1, "cp \"Game Saved\n\""); // deletedgame else G_Printf( "Unable to save game.\n" ); } else { // need a name G_Printf( "syntax: savegame <name>\n" ); } return qtrue; } #endif // SAVEGAME_SUPPORT if ( Q_stricmp (cmd, "entitylist") == 0 ) { Svcmd_EntityList_f(); return qtrue; } // omnibot: waypoint tool only, not for mods if ( Q_stricmp (cmd, "oidlist") == 0 ) { Svcmd_OIDList_f(); return qtrue; } if ( Q_stricmp (cmd, "forceteam") == 0 ) { Svcmd_ForceTeam_f(); return qtrue; } if (Q_stricmp (cmd, "game_memory") == 0) { Svcmd_GameMem_f(); return qtrue; } // omnibot /*if (Q_stricmp (cmd, "addbot") == 0) { Svcmd_AddBot_f(); return qtrue; } if (Q_stricmp (cmd, "removebot") == 0) { Svcmd_AddBot_f(); return qtrue; }*/ // end omnibot if (Q_stricmp (cmd, "addip") == 0) { Svcmd_AddIP_f(); return qtrue; } if (Q_stricmp (cmd, "removeip") == 0) { Svcmd_RemoveIP_f(); return qtrue; } if (Q_stricmp (cmd, "listip") == 0) { trap_SendConsoleCommand( EXEC_INSERT, "g_banIPs\n" ); return qtrue; } if (Q_stricmp (cmd, "listmaxlivesip") == 0) { PrintMaxLivesGUID(); return qtrue; } // NERVE - SMF if (Q_stricmp (cmd, "start_match") == 0) { Svcmd_StartMatch_f(); return qtrue; } if (Q_stricmp (cmd, "reset_match") == 0) { Svcmd_ResetMatch_f(qtrue, qtrue); return qtrue; } if (Q_stricmp (cmd, "swap_teams") == 0) { Svcmd_SwapTeams_f(); return qtrue; } if (Q_stricmp (cmd, "shuffle_teams") == 0) { Svcmd_ShuffleTeams_f(); return qtrue; } // -NERVE - SMF if (Q_stricmp (cmd, "makeReferee") == 0) { G_MakeReferee(); return qtrue; } if (Q_stricmp (cmd, "removeReferee") == 0) { G_RemoveReferee(); return qtrue; } /*if (Q_stricmp (cmd, "mute") == 0) { G_MuteClient(); return qtrue; } if (Q_stricmp (cmd, "unmute") == 0) { G_UnMuteClient(); return qtrue; }*/ if (Q_stricmp (cmd, "ban") == 0) { G_PlayerBan(); return qtrue; } if( Q_stricmp( cmd, "campaign" ) == 0 ) { Svcmd_Campaign_f(); return qtrue; } if( Q_stricmp( cmd, "listcampaigns" ) == 0 ) { Svcmd_ListCampaigns_f(); return qtrue; } #ifndef NO_BOT_SUPPORT if (Q_stricmp (cmd, "spawnbot") == 0) { Svcmd_SpawnBot(); return qtrue; } #endif // START - Mad Doc - TDF if (Q_stricmp (cmd, "revive") == 0) { trap_Argv( 1, cmd, sizeof( cmd ) ); Svcmd_RevivePlayer( cmd ); return qtrue; } // END - Mad Doc - TDF // omnibot if (Q_stricmp (cmd, "bot") == 0) { Bot_Interface_ConsoleCommand(); return qtrue; } // end omnibot // fretn - moved from engine if (!Q_stricmp(cmd, "kick")) { Svcmd_Kick_f(); return qtrue; } if (!Q_stricmp(cmd, "clientkick")) { Svcmd_KickNum_f(); return qtrue; } // -fretn if( g_dedicated.integer ) { if( !Q_stricmp (cmd, "say")) { trap_SendServerCommand( -1, va("cpm \"server: %s\n\"", ConcatArgs(1) ) ); return qtrue; } // OSP - console also gets ref commands if(!level.fLocalHost && Q_stricmp(cmd, "ref") == 0) { if(!G_refCommandCheck(NULL, cmd)) { G_refHelp_cmd(NULL); } return(qtrue); } // everything else will also be printed as a say command // trap_SendServerCommand( -1, va("cpm \"server: %s\n\"", ConcatArgs(0) ) ); // prints to the console instead now return qfalse; } return qfalse; }
qboolean ConsoleCommand(void) { char cmd[MAX_TOKEN_CHARS]; trap_Argv(0, cmd, sizeof(cmd)); #ifdef FEATURE_LUA if (!Q_stricmp(cmd, "lua_status")) { G_LuaStatus(NULL); return qtrue; } if (Q_stricmp(cmd, "lua_api") == 0) { G_LuaStackDump(); return qtrue; } // *LUA* API callbacks if (G_LuaHook_ConsoleCommand(cmd)) { return qtrue; } #endif if (Q_stricmp(cmd, "entitylist") == 0) { Svcmd_EntityList_f(); return qtrue; } if (Q_stricmp(cmd, "csinfo") == 0) { Svcmd_CSInfo_f(); return qtrue; } if (Q_stricmp(cmd, "forceteam") == 0) { Svcmd_ForceTeam_f(); return qtrue; } if (Q_stricmp(cmd, "game_memory") == 0) { Svcmd_GameMem_f(); return qtrue; } if (Q_stricmp(cmd, "addip") == 0) { Svcmd_AddIP_f(); return qtrue; } if (Q_stricmp(cmd, "removeip") == 0) { Svcmd_RemoveIP_f(); return qtrue; } if (Q_stricmp(cmd, "listip") == 0) { trap_SendConsoleCommand(EXEC_INSERT, "g_banIPs\n"); return qtrue; } if (Q_stricmp(cmd, "listmaxlivesip") == 0) { PrintMaxLivesGUID(); return qtrue; } if (Q_stricmp(cmd, "start_match") == 0) { Svcmd_StartMatch_f(); return qtrue; } if (Q_stricmp(cmd, "reset_match") == 0) { Svcmd_ResetMatch_f(qtrue, qtrue); return qtrue; } if (Q_stricmp(cmd, "swap_teams") == 0) { Svcmd_SwapTeams_f(); return qtrue; } if (Q_stricmp(cmd, "shuffle_teams") == 0) { Svcmd_ShuffleTeams_f(qtrue); return qtrue; } if (Q_stricmp(cmd, "shuffle_teams_norestart") == 0) { Svcmd_ShuffleTeams_f(qfalse); return qtrue; } if (Q_stricmp(cmd, "makeReferee") == 0) { G_MakeReferee(); return qtrue; } if (Q_stricmp(cmd, "removeReferee") == 0) { G_RemoveReferee(); return qtrue; } if (Q_stricmp(cmd, "mute") == 0) { G_MuteClient(); return qtrue; } if (Q_stricmp(cmd, "unmute") == 0) { G_UnMuteClient(); return qtrue; } if (Q_stricmp(cmd, "ban") == 0) { G_PlayerBan(); return qtrue; } if (Q_stricmp(cmd, "campaign") == 0) { Svcmd_Campaign_f(); return qtrue; } if (Q_stricmp(cmd, "listcampaigns") == 0) { Svcmd_ListCampaigns_f(); return qtrue; } if (Q_stricmp(cmd, "revive") == 0) { trap_Argv(1, cmd, sizeof(cmd)); Svcmd_RevivePlayer(cmd); return qtrue; } // moved from engine if (!Q_stricmp(cmd, "kick")) { Svcmd_Kick_f(); return qtrue; } if (!Q_stricmp(cmd, "clientkick")) { Svcmd_KickNum_f(); return qtrue; } #ifdef FEATURE_OMNIBOT if (!Q_stricmp(cmd, "bot")) { Bot_Interface_ConsoleCommand(); return qtrue; } #endif if (!Q_stricmp(cmd, "cp")) { trap_SendServerCommand(-1, va("cp \"%s\"", Q_AddCR(ConcatArgs(1)))); return qtrue; } if (!Q_stricmp(cmd, "reloadConfig")) { trap_SetConfigstring(CS_CONFIGNAME, ""); memset(&level.config, 0, sizeof(config_t)); G_configSet(g_customConfig.string); return qtrue; } if (!Q_stricmp(cmd, "loadConfig")) { CC_loadconfig(); return qtrue; } if (!Q_stricmp(cmd, "sv_cvarempty")) { memset(level.svCvars, 0, sizeof(level.svCvars)); level.svCvarsCount = 0; G_UpdateSvCvars(); return qtrue; } if (!Q_stricmp(cmd, "sv_cvar")) { CC_svcvar(); return qtrue; } if (!Q_stricmp(cmd, "playsound") || !Q_stricmp(cmd, "playsound_env")) { G_PlaySound_Cmd(); return qtrue; } //if (g_cheats.integer) //{ if (!Q_stricmp(cmd, "gib")) { Svcmd_Gib(); return qtrue; } if (!Q_stricmp(cmd, "die")) { Svcmd_Die(); return qtrue; } if (!Q_stricmp(cmd, "freeze")) { Svcmd_Freeze(); return qtrue; } if (!Q_stricmp(cmd, "unfreeze")) { Svcmd_Unfreeze(); return qtrue; } if (!Q_stricmp(cmd, "burn")) { Svcmd_Burn(); return qtrue; } if (!Q_stricmp(cmd, "pip")) { Svcmd_Pip(); return qtrue; } if (!Q_stricmp(cmd, "throw")) { Svcmd_Fling(1); return qtrue; } //} if (g_dedicated.integer) { // FIXME // this 'say' condition is never reached?! if (!Q_stricmp(cmd, "say")) { trap_SendServerCommand(-1, va("cpm \"server: %s\n\"", Q_AddCR(ConcatArgs(1)))); return qtrue; } // added for rcon/Lua chat if (!Q_stricmp(cmd, "chat")) { trap_SendServerCommand(-1, va("chat \"console: %s\"", Q_AddCR(ConcatArgs(1)))); return qtrue; } // console also gets ref commands if (!level.fLocalHost && Q_stricmp(cmd, "ref") == 0) { //G_refCommandCheck expects the next argument (warn, pause, lock,..) trap_Argv(1, cmd, sizeof(cmd)); if (!G_refCommandCheck(NULL, cmd)) { G_refHelp_cmd(NULL); } return qtrue; } // everything else will also be printed as a say command //trap_SendServerCommand( -1, va("cpm \"server: %s\n\"", ConcatArgs(0) ) ); // prints to the console instead now return qfalse; } return qfalse; }
/* ================= ConsoleCommand ================= */ qboolean ConsoleCommand(void) { char cmd[MAX_TOKEN_CHARS]; trap_Argv(0, cmd, sizeof(cmd)); #ifdef FEATURE_LUA if (!Q_stricmp(cmd, "lua_status")) { G_LuaStatus(NULL); return qtrue; } // *LUA* API callbacks if (G_LuaHook_ConsoleCommand(cmd)) { return qtrue; } #endif if (Q_stricmp(cmd, "entitylist") == 0) { Svcmd_EntityList_f(); return qtrue; } if (Q_stricmp(cmd, "forceteam") == 0) { Svcmd_ForceTeam_f(); return qtrue; } if (Q_stricmp(cmd, "game_memory") == 0) { Svcmd_GameMem_f(); return qtrue; } if (Q_stricmp(cmd, "addip") == 0) { Svcmd_AddIP_f(); return qtrue; } if (Q_stricmp(cmd, "removeip") == 0) { Svcmd_RemoveIP_f(); return qtrue; } if (Q_stricmp(cmd, "listip") == 0) { trap_SendConsoleCommand(EXEC_INSERT, "g_banIPs\n"); return qtrue; } if (Q_stricmp(cmd, "listmaxlivesip") == 0) { PrintMaxLivesGUID(); return qtrue; } if (Q_stricmp(cmd, "start_match") == 0) { Svcmd_StartMatch_f(); return qtrue; } if (Q_stricmp(cmd, "reset_match") == 0) { Svcmd_ResetMatch_f(qtrue, qtrue); return qtrue; } if (Q_stricmp(cmd, "swap_teams") == 0) { Svcmd_SwapTeams_f(); return qtrue; } if (Q_stricmp(cmd, "shuffle_teams") == 0) { Svcmd_ShuffleTeams_f(); return qtrue; } if (Q_stricmp(cmd, "makeReferee") == 0) { G_MakeReferee(); return qtrue; } if (Q_stricmp(cmd, "removeReferee") == 0) { G_RemoveReferee(); return qtrue; } /*if (Q_stricmp (cmd, "mute") == 0) { G_MuteClient(); return qtrue; } if (Q_stricmp (cmd, "unmute") == 0) { G_UnMuteClient(); return qtrue; }*/ if (Q_stricmp(cmd, "ban") == 0) { G_PlayerBan(); return qtrue; } if (Q_stricmp(cmd, "campaign") == 0) { Svcmd_Campaign_f(); return qtrue; } if (Q_stricmp(cmd, "listcampaigns") == 0) { Svcmd_ListCampaigns_f(); return qtrue; } if (Q_stricmp(cmd, "revive") == 0) { trap_Argv(1, cmd, sizeof(cmd)); Svcmd_RevivePlayer(cmd); return qtrue; } // fretn - moved from engine if (!Q_stricmp(cmd, "kick")) { Svcmd_Kick_f(); return qtrue; } if (!Q_stricmp(cmd, "clientkick")) { Svcmd_KickNum_f(); return qtrue; } #ifdef FEATURE_OMNIBOT if (!Q_stricmp(cmd, "bot")) { Bot_Interface_ConsoleCommand(); return qtrue; } #endif if (!Q_stricmp(cmd, "sv_cvarempty")) { memset(level.svCvars, 0, sizeof(level.svCvars)); level.svCvarsCount = 0; G_UpdateSvCvars(); return qtrue; } if (!Q_stricmp(cmd, "sv_cvar")) { CC_svcvar(); return qtrue; } if (!Q_stricmp(cmd, "playsound") || !Q_stricmp(cmd, "playsound_env")) { G_PlaySound_Cmd(); return qtrue; } if (g_dedicated.integer) { if (!Q_stricmp(cmd, "say")) { trap_SendServerCommand(-1, va("cpm \"server: %s\n\"", ConcatArgs(1))); return qtrue; } // OSP - console also gets ref commands if (!level.fLocalHost && Q_stricmp(cmd, "ref") == 0) { // G_refCommandCheck expects the next argument (warn, pause, lock,..) trap_Argv(1, cmd, sizeof(cmd)); if (!G_refCommandCheck(NULL, cmd)) { G_refHelp_cmd(NULL); } return qtrue; } // everything else will also be printed as a say command // trap_SendServerCommand( -1, va("cpm \"server: %s\n\"", ConcatArgs(0) ) ); // prints to the console instead now return qfalse; } return qfalse; }
/* ================= ConsoleCommand ================= */ qboolean ConsoleCommand( void ) { char cmd[MAX_TOKEN_CHARS]; trap_Argv( 0, cmd, sizeof( cmd ) ); #ifdef SAVEGAME_SUPPORT if (Q_stricmp (cmd, "savegame") == 0) { if( g_gametype.integer != GT_SINGLE_PLAYER ) return qtrue; // don't allow a manual savegame command while we are waiting for the game to start/exit if (g_reloading.integer) return qtrue; if (saveGamePending) return qtrue; trap_Argv( 1, cmd, sizeof( cmd ) ); if (strlen(cmd) > 0) { // strip the extension if provided if (strrchr(cmd, '.')) { cmd[strrchr(cmd,'.')-cmd] = '\0'; } if ( !Q_stricmp( cmd, "current") ) { // beginning of map Com_Printf("sorry, '%s' is a reserved savegame name. please use another name.\n", cmd); return qtrue; } if (G_SaveGame( cmd )) trap_SendServerCommand(-1, "cp \"Game Saved\n\""); // deletedgame else G_Printf( "Unable to save game.\n" ); } else { // need a name G_Printf( "syntax: savegame <name>\n" ); } return qtrue; } #endif // SAVEGAME_SUPPORT if ( Q_stricmp (cmd, "entitylist") == 0 ) { Svcmd_EntityList_f(); return qtrue; } if ( Q_stricmp (cmd, "forceteam") == 0 ) { Svcmd_ForceTeam_f(); return qtrue; } if (Q_stricmp (cmd, "game_memory") == 0) { Svcmd_GameMem_f(); return qtrue; } /*if (Q_stricmp (cmd, "addbot") == 0) { Svcmd_AddBot_f(); return qtrue; } if (Q_stricmp (cmd, "removebot") == 0) { Svcmd_AddBot_f(); return qtrue; }*/ if (Q_stricmp (cmd, "addip") == 0) { Svcmd_AddIP_f(); return qtrue; } if (Q_stricmp (cmd, "removeip") == 0) { Svcmd_RemoveIP_f(); return qtrue; } if (Q_stricmp (cmd, "listip") == 0) { trap_SendConsoleCommand( EXEC_INSERT, "g_banIPs\n" ); return qtrue; } if (Q_stricmp (cmd, "listmaxlivesip") == 0) { PrintMaxLivesGUID(); return qtrue; } if (Q_stricmp (cmd, "reset_match") == 0) { Svcmd_ResetMatch_f(qtrue, qtrue); return qtrue; } if (Q_stricmp (cmd, "swap_teams") == 0) { Svcmd_SwapTeams_f(); return qtrue; } if (Q_stricmp (cmd, "shuffle_teams") == 0) { Svcmd_ShuffleTeams_f(); return qtrue; } // -NERVE - SMF if (Q_stricmp (cmd, "makeReferee") == 0) { G_MakeReferee(); return qtrue; } if (Q_stricmp (cmd, "removeReferee") == 0) { G_RemoveReferee(); return qtrue; } /*if (Q_stricmp (cmd, "mute") == 0) { G_MuteClient(); return qtrue; } if (Q_stricmp (cmd, "unmute") == 0) { G_UnMuteClient(); return qtrue; }*/ if (Q_stricmp (cmd, "ban") == 0) { G_PlayerBan(); return qtrue; } if( Q_stricmp( cmd, "campaign" ) == 0 ) { Svcmd_Campaign_f(); return qtrue; } if( Q_stricmp( cmd, "listcampaigns" ) == 0 ) { Svcmd_ListCampaigns_f(); return qtrue; } // fretn - moved from engine if (!Q_stricmp(cmd, "kick")) { Svcmd_Kick_f(); return qtrue; } if (!Q_stricmp(cmd, "clientkick")) { Svcmd_KickNum_f(); return qtrue; } if (!Q_stricmp(cmd, "noVoteLimit")) { Svcmd_noVoteLimit(); return qtrue; } if (!Q_stricmp(cmd, "cp")) { AP(va("cp \"%s\n\"", ConcatArgs(1))); return qtrue; } if (!Q_stricmp(cmd, "qsay")) { AP(va("chat \"%s\"", ConcatArgs(1))); G_LogPrintf("qsay: \"%s\n\"", ConcatArgs(1)); return qtrue; } if (!Q_stricmp(cmd, "bp")) { AP(va("bp \"%s\"", ConcatArgs(1))); G_LogPrintf("banner: \"%s\n\"", ConcatArgs(1)); return qtrue; } if (!Q_stricmp(cmd, "cpm")) { AP(va("cpm \"%s\n\"", ConcatArgs(1))); return qtrue; } if (!Q_stricmp(cmd, "freespec")) { gclient_t *cl; char num[MAX_TOKEN_CHARS]; int clientnum; trap_Argv(1, num, sizeof(num)); clientnum = atoi(num); cl = G_GetPlayerByNum( clientnum ); if ( !cl ) { return; } cl->sess.freeSpec = qtrue; return qtrue; } if (!Q_stricmp(cmd, "pcmd")) { gclient_t *cl; char name[MAX_TOKEN_CHARS]; int clientNum; trap_Argv(1, name, sizeof(name)); clientNum = atoi(name); cl = G_GetPlayerByNum( clientNum ); if ( !cl ) { return; } trap_SendServerCommand(cl - level.clients, va("pcmd %s", ConcatArgs(2))); return qtrue; } if (!Q_stricmp(cmd, "blockmap")) { char map[MAX_STRING_TOKENS]; char blocklist[MAX_CVAR_VALUE_STRING]; trap_Argv(1, map, sizeof(map)); if (strlen(tjg_blockedMaps.string) + strlen(map) > sizeof(tjg_blockedMaps.string)) { AP("print \"tjg_blockedMaps is full.\n\""); } else { Com_sprintf(blocklist, sizeof(blocklist), "%s %s", tjg_blockedMaps.string, map); trap_Cvar_Set("tjg_blockedMaps", va("%s", blocklist)); } return qtrue; } if (!tjg_recordMode.integer) { if (!Q_stricmp(cmd, "forcecvar")) { char cvar_name[MAX_TOKEN_CHARS]; char cvar_val[MAX_TOKEN_CHARS]; trap_Argv(1, cvar_name, sizeof(cvar_name)); trap_Argv(2, cvar_val, sizeof(cvar_val)); trap_Cvar_Set(cvar_name, va("%d", atoi(cvar_val))); AP(va("print \"Forced %s to %s.\n\"", cvar_name, va("%d", atoi(cvar_val)) ) ); return qtrue; } } if( g_dedicated.integer ) { if( !Q_stricmp (cmd, "say")) { trap_SendServerCommand( -1, va("cpm \"server: %s\n\"", ConcatArgs(1) ) ); return qtrue; } // OSP - console also gets ref commands if(!level.fLocalHost && Q_stricmp(cmd, "ref") == 0) { // CHRUKER: b005 - G_refCommandCheck expects the next argument (warn, pause, lock etc). trap_Argv(1, cmd, sizeof(cmd)); if(!G_refCommandCheck(NULL, cmd)) { G_refHelp_cmd(NULL); } return(qtrue); } // everything else will also be printed as a say command // trap_SendServerCommand( -1, va("cpm \"server: %s\n\"", ConcatArgs(0) ) ); // prints to the console instead now return qfalse; } return qfalse; }