void CSpectator::ConKeySpectator(IConsole::IResult *pResult, void *pUserData) { CSpectator *pSelf = (CSpectator *)pUserData; if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_Active && (pSelf->Client()->State() != IClient::STATE_DEMOPLAYBACK || pSelf->DemoPlayer()->GetDemoType() == IDemoPlayer::DEMOTYPE_SERVER)) pSelf->m_Active = pResult->GetInteger(0) != 0; }
void CSpectator::ConSpectateNext(IConsole::IResult *pResult, void *pUserData) { CSpectator *pSelf = (CSpectator *)pUserData; if(!pSelf->m_pClient->m_Snap.m_SpecInfo.m_Active || (pSelf->Client()->State() == IClient::STATE_DEMOPLAYBACK && pSelf->DemoPlayer()->GetDemoType() != IDemoPlayer::DEMOTYPE_SERVER)) return; int NewSpecMode = pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpecMode; int NewSpectatorID = -1; bool GotNewSpectatorID = false; if(NewSpecMode != SPEC_PLAYER) NewSpecMode = (NewSpecMode + 1) % NUM_SPECMODES; else NewSpectatorID = pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID; switch(NewSpecMode) { // drop through case SPEC_PLAYER: for(int i = NewSpectatorID + 1; i < MAX_CLIENTS; i++) { if(!pSelf->m_pClient->m_aClients[i].m_Active || pSelf->m_pClient->m_aClients[i].m_Team == TEAM_SPECTATORS) continue; if(pSelf->m_pClient->m_aClients[pSelf->m_pClient->m_LocalClientID].m_Team != TEAM_SPECTATORS && (i == pSelf->m_pClient->m_LocalClientID || pSelf->m_pClient->m_aClients[pSelf->m_pClient->m_LocalClientID].m_Team != pSelf->m_pClient->m_aClients[i].m_Team || (pSelf->m_pClient->m_Snap.m_paPlayerInfos[i] && (pSelf->m_pClient->m_Snap.m_paPlayerInfos[i]->m_PlayerFlags&PLAYERFLAG_DEAD)))) continue; NewSpectatorID = i; GotNewSpectatorID = true; break; } if(GotNewSpectatorID) break; NewSpecMode = SPEC_FLAGRED; NewSpectatorID = -1; case SPEC_FLAGRED: case SPEC_FLAGBLUE: if(pSelf->m_pClient->m_GameInfo.m_GameFlags&GAMEFLAG_FLAGS) { GotNewSpectatorID = true; break; } NewSpecMode = SPEC_FREEVIEW; case SPEC_FREEVIEW: if(pSelf->m_pClient->m_aClients[pSelf->m_pClient->m_LocalClientID].m_Team == TEAM_SPECTATORS) GotNewSpectatorID = true; else { // start again on the beginning in survival for(int i = 0; i < pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID; i++) { if(!pSelf->m_pClient->m_aClients[i].m_Active || pSelf->m_pClient->m_aClients[i].m_Team == TEAM_SPECTATORS) continue; if(pSelf->m_pClient->m_aClients[pSelf->m_pClient->m_LocalClientID].m_Team != TEAM_SPECTATORS && (i == pSelf->m_pClient->m_LocalClientID || pSelf->m_pClient->m_aClients[pSelf->m_pClient->m_LocalClientID].m_Team != pSelf->m_pClient->m_aClients[i].m_Team || (pSelf->m_pClient->m_Snap.m_paPlayerInfos[i] && (pSelf->m_pClient->m_Snap.m_paPlayerInfos[i]->m_PlayerFlags&PLAYERFLAG_DEAD)))) continue; NewSpecMode = SPEC_PLAYER; NewSpectatorID = i; GotNewSpectatorID = true; break; } } } if(GotNewSpectatorID) pSelf->Spectate(NewSpecMode, NewSpectatorID); }