/* ================= ClientCommand ================= */ void ClientCommand( int clientNum ) { gentity_t *ent; char cmd[MAX_TOKEN_CHARS]; ent = g_entities + clientNum; if ( !ent->client ) { return; // not fully in game yet } trap_Argv( 0, cmd, sizeof( cmd ) ); if (Q_stricmp (cmd, "say") == 0) { Cmd_Say_f (ent, SAY_ALL, qfalse); return; } if (Q_stricmp (cmd, "say_team") == 0) { Cmd_Say_f (ent, SAY_TEAM, qfalse); return; } if (Q_stricmp (cmd, "tell") == 0) { Cmd_Tell_f ( ent ); return; } if (Q_stricmp (cmd, "vsay") == 0) { Cmd_Voice_f (ent, SAY_ALL, qfalse, qfalse); return; } if (Q_stricmp (cmd, "vsay_team") == 0) { Cmd_Voice_f (ent, SAY_TEAM, qfalse, qfalse); return; } if (Q_stricmp (cmd, "vtell") == 0) { Cmd_VoiceTell_f ( ent, qfalse ); return; } if (Q_stricmp (cmd, "vosay") == 0) { Cmd_Voice_f (ent, SAY_ALL, qfalse, qtrue); return; } if (Q_stricmp (cmd, "vosay_team") == 0) { Cmd_Voice_f (ent, SAY_TEAM, qfalse, qtrue); return; } if (Q_stricmp (cmd, "votell") == 0) { Cmd_VoiceTell_f ( ent, qtrue ); return; } if (Q_stricmp (cmd, "vtaunt") == 0) { Cmd_VoiceTaunt_f ( ent ); return; } if (Q_stricmp (cmd, "score") == 0) { Cmd_Score_f (ent); return; } // ignore all other commands when at intermission if (level.intermissiontime) { Cmd_Say_f (ent, qfalse, qtrue); return; } if (Q_stricmp (cmd, "give") == 0) Cmd_Give_f (ent); else if (Q_stricmp (cmd, "god") == 0) Cmd_God_f (ent); else if (Q_stricmp (cmd, "notarget") == 0) Cmd_Notarget_f (ent); else if (Q_stricmp (cmd, "noclip") == 0) Cmd_Noclip_f (ent); else if (Q_stricmp (cmd, "kill") == 0) Cmd_Kill_f (ent); else if (Q_stricmp (cmd, "teamtask") == 0) Cmd_TeamTask_f (ent); else if (Q_stricmp (cmd, "levelshot") == 0) Cmd_LevelShot_f (ent); else if (Q_stricmp (cmd, "follow") == 0) Cmd_Follow_f (ent); else if (Q_stricmp (cmd, "follownext") == 0) Cmd_FollowCycle_f (ent, 1); else if (Q_stricmp (cmd, "followprev") == 0) Cmd_FollowCycle_f (ent, -1); else if (Q_stricmp (cmd, "team") == 0) Cmd_Team_f (ent); else if (Q_stricmp (cmd, "where") == 0) Cmd_Where_f (ent); else if (Q_stricmp (cmd, "callvote") == 0) Cmd_CallVote_f (ent); else if (Q_stricmp (cmd, "vote") == 0) Cmd_Vote_f (ent); else if (Q_stricmp (cmd, "callteamvote") == 0) Cmd_CallTeamVote_f (ent); else if (Q_stricmp (cmd, "teamvote") == 0) Cmd_TeamVote_f (ent); else if (Q_stricmp (cmd, "gc") == 0) Cmd_GameCommand_f( ent ); else if (Q_stricmp (cmd, "setviewpos") == 0) Cmd_SetViewpos_f( ent ); else if (Q_stricmp (cmd, "stats") == 0) Cmd_Stats_f( ent ); else trap_SendServerCommand( clientNum, va("print \"unknown cmd %s\n\"", cmd ) ); }
/* ================= SpectatorThink ================= */ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) { pmove_t pm; gclient_t *client; client = ent->client; client->oldbuttons = client->buttons; client->buttons = ucmd->buttons; if( client->sess.spectatorState != SPECTATOR_FOLLOW ) { if( client->sess.spectatorState == SPECTATOR_LOCKED ) client->ps.pm_type = PM_FREEZE; else client->ps.pm_type = PM_SPECTATOR; client->ps.speed = BG_FindSpeedForClass( client->ps.stats[ STAT_PCLASS ] ); client->ps.stats[ STAT_STAMINA ] = 0; client->ps.stats[ STAT_MISC ] = 0; client->ps.stats[ STAT_BUILDABLE ] = 0; client->ps.stats[ STAT_PCLASS ] = PCL_NONE; client->ps.weapon = WP_NONE; // set up for pmove memset( &pm, 0, sizeof( pm ) ); pm.ps = &client->ps; pm.cmd = *ucmd; pm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY; // spectators can fly through bodies pm.trace = trap_Trace; pm.pointcontents = trap_PointContents; // perform a pmove Pmove( &pm ); // save results of pmove VectorCopy( client->ps.origin, ent->s.origin ); G_TouchTriggers( ent ); trap_UnlinkEntity( ent ); if( ( client->buttons & BUTTON_ATTACK ) && !( client->oldbuttons & BUTTON_ATTACK ) ) { //if waiting in a queue remove from the queue if( client->ps.pm_flags & PMF_QUEUED ) { if( client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) G_RemoveFromSpawnQueue( &level.alienSpawnQueue, client->ps.clientNum ); else if( client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) G_RemoveFromSpawnQueue( &level.humanSpawnQueue, client->ps.clientNum ); client->pers.classSelection = PCL_NONE; client->ps.stats[ STAT_PCLASS ] = PCL_NONE; } else if( client->pers.classSelection == PCL_NONE ) { if( client->pers.teamSelection == PTE_NONE ) G_TriggerMenu( client->ps.clientNum, MN_TEAM ); else if( client->pers.teamSelection == PTE_ALIENS ) G_TriggerMenu( client->ps.clientNum, MN_A_CLASS ); else if( client->pers.teamSelection == PTE_HUMANS ) G_TriggerMenu( client->ps.clientNum, MN_H_SPAWN ); } } //set the queue position for the client side if( client->ps.pm_flags & PMF_QUEUED ) { if( client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { client->ps.persistant[ PERS_QUEUEPOS ] = G_GetPosInSpawnQueue( &level.alienSpawnQueue, client->ps.clientNum ); } else if( client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { client->ps.persistant[ PERS_QUEUEPOS ] = G_GetPosInSpawnQueue( &level.humanSpawnQueue, client->ps.clientNum ); } } } if( ( client->buttons & BUTTON_USE_HOLDABLE ) && !( client->oldbuttons & BUTTON_USE_HOLDABLE ) ) Cmd_Follow_f( ent, qtrue ); }