Index: code/game/g_local.h =================================================================== --- code/game/g_local.h (révision 229) +++ code/game/g_local.h (copie de travail) @@ -388,6 +388,7 @@ int latched_buttons; #ifdef SMOKINGUNS int oldupmove; // smokinguns + char lastcmd[MAX_TOKEN_CHARS]; #endif vec3_t oldOrigin; @@ -638,6 +639,21 @@ void ChaseCam_Start( gentity_t *ent, int dir ); void ChaseCam_Stop( gentity_t *ent ); void ChaseCam_Change( gentity_t *ent ); + +typedef struct command_s +{ + char *name; + int flags; + void ( *cmdHandler )( gentity_t *ent ); +} command_t; + +#define CMD_CHEAT 0x0001 +#define CMD_CHEAT_TEAM 0x0002 +#define CMD_MESSAGE 0x0004 +#define CMD_TEAM 0x0008 +#define CMD_SPEC 0x0010 +#define CMD_LIVING 0x0020 +#define CMD_INTERMISSION 0x0040 #endif // @@ -1037,6 +1053,7 @@ extern vmCvar_t g_allowVote; #ifdef SMOKINGUNS extern vmCvar_t g_allowVoteKick; +extern vmCvar_t g_noMessages; #endif extern vmCvar_t g_teamAutoJoin; extern vmCvar_t g_teamForceBalance; Index: code/game/g_main.c =================================================================== --- code/game/g_main.c (révision 229) +++ code/game/g_main.c (copie de travail) @@ -102,6 +102,7 @@ vmCvar_t g_capturelimit; #else vmCvar_t g_scorelimit; +vmCvar_t g_noMessages; #endif vmCvar_t g_friendlyFire; vmCvar_t g_password; @@ -215,6 +216,7 @@ { &g_capturelimit, "capturelimit", "8", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue }, #else { &g_scorelimit, "scorelimit", "10", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue }, + { &g_noMessages, "g_noMessages", "0", CVAR_ARCHIVE, 0, qtrue }, { &g_duellimit, "duellimit", "3", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue }, { &du_enabletrio, "du_enabletrio", "0", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue }, @@ -255,8 +257,8 @@ { &g_speed, "g_speed", "320", 0, 0, qtrue }, { &g_gravity, "g_gravity", "800", 0, 0, qtrue }, #else - { &g_speed, "g_speed", "200", 0, 0, qtrue }, - { &g_gravity, "g_gravity", "900", 0, 0, qtrue }, + { &g_speed, "g_speed", G_SPEED_DEF, 0, 0, qtrue }, + { &g_gravity, "g_gravity", G_GRAVITY_DEF, 0, 0, qtrue }, #endif { &g_knockback, "g_knockback", "1000", 0, 0, qtrue }, { &g_quadfactor, "g_quadfactor", "3", 0, 0, qtrue }, Index: code/game/g_cmds.c =================================================================== --- code/game/g_cmds.c (révision 229) +++ code/game/g_cmds.c (copie de travail) @@ -2519,17 +2519,131 @@ } #endif +#ifdef SMOKINGUNS +void Cmd_GeneralSay_f( gentity_t *ent ) +{ + if( !Q_stricmp( ent->client->lastcmd, "say" ) ) + Cmd_Say_f( ent, SAY_ALL, qfalse ); + else if( !Q_stricmp( ent->client->lastcmd, "say_team" ) ) + Cmd_Say_f( ent, SAY_TEAM, qfalse ); +} +void Cmd_Buy_f( gentity_t *ent ) +{ + if( !Q_stricmp( ent->client->lastcmd, "buy" ) ) + Cmd_BuyItem_f( ent, qfalse ); + else if( !Q_stricmp( ent->client->lastcmd, "cg_buy" ) ) + Cmd_BuyItem_f( ent, qtrue ); +} + +void Cmd_DevJoin_f( gentity_t *ent ) +{ + if( !Q_stricmp( ent->client->lastcmd, "dev_join_r" ) ) + { + if( CheatsOk( ent ) ) + SetTeam( ent, "r" ); + } + else if( !Q_stricmp( ent->client->lastcmd, "dev_join_b" ) ) + { + if( CheatsOk( ent ) ) + SetTeam( ent, "b" ); + } +} + +void Cmd_GeneralFollow_f( gentity_t *ent ) +{ + if( !Q_stricmp( ent->client->lastcmd, "follownext" ) ) + ChaseCam_Start( ent, 1 ); + else if( !Q_stricmp( ent->client->lastcmd, "followprev" ) ) + ChaseCam_Start( ent, -1 ); +} + +void Cmd_GeneralDropWeapon_f( gentity_t *ent ) +{ + if( !Q_stricmp( ent->client->lastcmd, "dropweapon" ) ) + Cmd_DropWeapon_f( ent, 0 ); +} + + +command_t cmds[ ] = { + { "say", CMD_MESSAGE, Cmd_GeneralSay_f }, + { "say_team", CMD_MESSAGE, Cmd_GeneralSay_f }, + { "tell", CMD_MESSAGE, Cmd_Tell_f }, + { "score", 0, Cmd_Score_f }, + { "give", CMD_CHEAT|CMD_TEAM|CMD_LIVING|CMD_INTERMISSION, Cmd_Give_f }, + { "god", CMD_CHEAT|CMD_TEAM|CMD_LIVING|CMD_INTERMISSION, Cmd_God_f }, + { "notarget", CMD_CHEAT|CMD_TEAM|CMD_LIVING|CMD_INTERMISSION, Cmd_Notarget_f }, + { "noclip", CMD_CHEAT|CMD_TEAM|CMD_LIVING|CMD_INTERMISSION, Cmd_Noclip_f }, + { "kill", CMD_TEAM|CMD_LIVING|CMD_INTERMISSION, Cmd_Kill_f }, + { "teamtask", CMD_TEAM|CMD_LIVING|CMD_INTERMISSION, Cmd_TeamTask_f }, + { "levelshot", CMD_CHEAT|CMD_INTERMISSION, Cmd_LevelShot_f }, + { "follow", CMD_INTERMISSION, Cmd_Follow_f }, + { "follownext", CMD_INTERMISSION, Cmd_GeneralFollow_f }, + { "followprev", CMD_INTERMISSION, Cmd_GeneralFollow_f }, + { "team", CMD_INTERMISSION, Cmd_Team_f }, + { "where", CMD_INTERMISSION, Cmd_Where_f }, + { "callvote", CMD_MESSAGE|CMD_INTERMISSION, Cmd_CallVote_f }, + { "vote", CMD_INTERMISSION, Cmd_Vote_f }, + { "callteamvote", CMD_MESSAGE|CMD_INTERMISSION, Cmd_CallTeamVote_f }, + { "teamvote", CMD_INTERMISSION, Cmd_TeamVote_f }, + { "gc", CMD_MESSAGE|CMD_INTERMISSION, Cmd_GameCommand_f }, + { "setviewpos", CMD_CHEAT_TEAM|CMD_INTERMISSION, Cmd_SetViewpos_f }, + { "stats", CMD_INTERMISSION, Cmd_Stats_f }, + { "dropweapon", CMD_TEAM|CMD_LIVING|CMD_INTERMISSION, Cmd_GeneralDropWeapon_f }, + { "buy", CMD_TEAM|CMD_LIVING|CMD_INTERMISSION, Cmd_Buy_f }, + { "cg_buy", CMD_TEAM|CMD_LIVING|CMD_INTERMISSION, Cmd_Buy_f }, + { "dev_join_r", CMD_INTERMISSION, Cmd_DevJoin_f }, + { "dev_join_b", CMD_INTERMISSION, Cmd_DevJoin_f }, +}; +static int numCmds = ARRAY_SIZE( cmds ); +#endif + /* ================= ClientCommand ================= */ void ClientCommand( int clientNum ) { - gentity_t *ent; + gentity_t *ent = g_entities + clientNum; char cmd[MAX_TOKEN_CHARS]; +#ifdef SMOKINGUNS + int i; - ent = g_entities + clientNum; + if ( !ent->client ) + return; // not fully in game yet + + trap_Argv( 0, cmd, sizeof( cmd ) ); + Q_strncpyz( ent->client->lastcmd, cmd, sizeof( ent->client->lastcmd ) ); + + for( i = 0; i < numCmds; i++ ) + { + if( !Q_stricmp( cmd, cmds[ i ].name ) ) + break; + } + + if( !( cmds[ i ].flags & CMD_INTERMISSION ) && level.intermissiontime ) + return; + + if( cmds[ i ].flags & CMD_CHEAT && !g_cheats.integer ) + return; + + if( cmds[ i ].flags & CMD_MESSAGE && g_noMessages.integer ) + return; + + if( cmds[ i ].flags & CMD_TEAM && ent->client->sess.sessionTeam == TEAM_FREE ) + return; + + if( cmds[ i ].flags & CMD_CHEAT_TEAM && !g_cheats.integer && ent->client->sess.sessionTeam != TEAM_FREE ) + return; + + if( cmds[ i ].flags & CMD_LIVING && + ( ent->client->ps.stats[ STAT_HEALTH ] <= 0 || + ent->client->sess.spectatorState != SPECTATOR_NOT ) ) + return; + + cmds[ i ].cmdHandler( ent ); +#else + if ( !ent->client ) { return; // not fully in game yet } @@ -2549,7 +2663,6 @@ Cmd_Tell_f ( ent ); return; } -#ifndef SMOKINGUNS if (Q_stricmp (cmd, "vsay") == 0) { Cmd_Voice_f (ent, SAY_ALL, qfalse, qfalse); return; @@ -2578,7 +2691,6 @@ Cmd_VoiceTaunt_f ( ent ); return; } -#endif if (Q_stricmp (cmd, "score") == 0) { Cmd_Score_f (ent); return; @@ -2607,17 +2719,9 @@ else if (Q_stricmp (cmd, "follow") == 0) Cmd_Follow_f (ent); else if (Q_stricmp (cmd, "follownext") == 0) -#ifndef SMOKINGUNS Cmd_FollowCycle_f (ent, 1); -#else - ChaseCam_Start(ent, 1); -#endif else if (Q_stricmp (cmd, "followprev") == 0) -#ifndef SMOKINGUNS Cmd_FollowCycle_f (ent, -1); -#else - ChaseCam_Start(ent, -1); -#endif else if (Q_stricmp (cmd, "team") == 0) Cmd_Team_f (ent); else if (Q_stricmp (cmd, "where") == 0) @@ -2636,23 +2740,8 @@ Cmd_SetViewpos_f( ent ); else if (Q_stricmp (cmd, "stats") == 0) Cmd_Stats_f( ent ); -#ifdef SMOKINGUNS - else if (Q_stricmp (cmd, "dropweapon") == 0) - Cmd_DropWeapon_f( ent, 0 ); - else if (Q_stricmp(cmd, "buy" ) == 0) - Cmd_BuyItem_f (ent, qfalse); - else if (Q_stricmp(cmd, "cg_buy" ) == 0) - Cmd_BuyItem_f (ent, qtrue); - //developer cheats by spoon, necessary to join in round based gametypes - else if(!Q_stricmp(cmd, "dev_join_r")){ - if(CheatsOk( ent )) - SetTeam(ent, "r"); - } - else if(!Q_stricmp(cmd, "dev_join_b")){ - if(CheatsOk( ent )) - SetTeam(ent, "b"); - } -#endif else trap_SendServerCommand( clientNum, va("print \"unknown cmd %s\n\"", cmd ) ); +#endif /* #ifdef SMOKINGUNS */ } +