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::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->m_Active = pResult->GetInteger(0) != 0; } }
void CSpectator::ConSpectatePrevious(IConsole::IResult *pResult, void *pUserData) { CSpectator *pSelf = (CSpectator *)pUserData; int NewSpectatorID; bool GotNewSpectatorID = false; int CurPos = -1; for (int i = 0; i < MAX_CLIENTS; i++) if (pSelf->m_pClient->m_Snap.m_paInfoByDDTeam[i] && pSelf->m_pClient->m_Snap.m_paInfoByDDTeam[i]->m_ClientID == pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID) CurPos = i; if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW) { for(int i = MAX_CLIENTS -1; i > -1; i--) { if(!pSelf->m_pClient->m_Snap.m_paInfoByDDTeam[i] || pSelf->m_pClient->m_Snap.m_paInfoByDDTeam[i]->m_Team == TEAM_SPECTATORS) continue; NewSpectatorID = pSelf->m_pClient->m_Snap.m_paInfoByDDTeam[i]->m_ClientID; GotNewSpectatorID = true; break; } } else { for(int i = CurPos - 1; i > -1; i--) { if(!pSelf->m_pClient->m_Snap.m_paInfoByDDTeam[i] || pSelf->m_pClient->m_Snap.m_paInfoByDDTeam[i]->m_Team == TEAM_SPECTATORS) continue; NewSpectatorID = pSelf->m_pClient->m_Snap.m_paInfoByDDTeam[i]->m_ClientID; GotNewSpectatorID = true; break; } if(!GotNewSpectatorID) { for(int i = MAX_CLIENTS - 1; i > CurPos; i--) { if(!pSelf->m_pClient->m_Snap.m_paInfoByDDTeam[i] || pSelf->m_pClient->m_Snap.m_paInfoByDDTeam[i]->m_Team == TEAM_SPECTATORS) continue; NewSpectatorID = pSelf->m_pClient->m_Snap.m_paInfoByDDTeam[i]->m_ClientID; GotNewSpectatorID = true; break; } } } if(GotNewSpectatorID) pSelf->Spectate(NewSpectatorID); }
void CSpectator::ConSpectatePrevious(IConsole::IResult *pResult, void *pUserData) { CSpectator *pSelf = (CSpectator *)pUserData; int NewSpectatorID; bool GotNewSpectatorID = false; if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW) { for(int i = MAX_CLIENTS -1; i > -1; i--) { if(!pSelf->m_pClient->m_Snap.m_paPlayerInfos[i] || pSelf->m_pClient->m_Snap.m_paPlayerInfos[i]->m_Team == TEAM_SPECTATORS) continue; NewSpectatorID = i; GotNewSpectatorID = true; break; } } else { for(int i = pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID - 1; i > -1; i--) { if(!pSelf->m_pClient->m_Snap.m_paPlayerInfos[i] || pSelf->m_pClient->m_Snap.m_paPlayerInfos[i]->m_Team == TEAM_SPECTATORS) continue; NewSpectatorID = i; GotNewSpectatorID = true; break; } if(!GotNewSpectatorID) { for(int i = MAX_CLIENTS - 1; i > pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID; i--) { if(!pSelf->m_pClient->m_Snap.m_paPlayerInfos[i] || pSelf->m_pClient->m_Snap.m_paPlayerInfos[i]->m_Team == TEAM_SPECTATORS) continue; NewSpectatorID = i; GotNewSpectatorID = true; break; } } } if(GotNewSpectatorID) pSelf->Spectate(NewSpectatorID); }
void CSpectator::ConSpectateNext(IConsole::IResult *pResult, void *pUserData) { CSpectator *pSelf = (CSpectator *)pUserData; int NewSpectatorID; bool GotNewSpectatorID = false; if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW) { for(int i = 0; i < MAX_CLIENTS; i++) { if(!pSelf->m_pClient->m_aClients[i].m_Active || pSelf->m_pClient->m_aClients[i].m_Team == TEAM_SPECTATORS) continue; NewSpectatorID = i; GotNewSpectatorID = true; break; } } else { for(int i = pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID + 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; NewSpectatorID = i; GotNewSpectatorID = true; break; } if(!GotNewSpectatorID) { 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; NewSpectatorID = i; GotNewSpectatorID = true; break; } } } if(GotNewSpectatorID) pSelf->Spectate(NewSpectatorID); }
void game_cl_Deathmatch::shedule_Update (u32 dt) { CStringTable st; inherited::shedule_Update(dt); if(g_dedicated_server) return; //fake if(m_game_ui) { m_game_ui->SetTimeMsgCaption (NULL); m_game_ui->SetRoundResultCaption (NULL); m_game_ui->SetSpectatorMsgCaption (NULL); m_game_ui->SetPressJumpMsgCaption (NULL); m_game_ui->SetPressBuyMsgCaption (NULL); m_game_ui->SetForceRespawnTimeCaption(NULL); m_game_ui->SetWarmUpCaption (NULL); }; // if (CurrentGameUI() && CurrentGameUI()->UIMainIngameWnd) // CurrentGameUI()->UIMainIngameWnd->ZoneCounter().SetText(""); switch (Phase()) { case GAME_PHASE_INPROGRESS: { //m_game_ui->ShowPlayersList(false); Check_Invincible_Players(); if (!m_game_ui) break; if (m_s32TimeLimit && m_cl_dwWarmUp_Time == 0) { if (Level().timeServer()<(m_start_time + m_s32TimeLimit)) { u32 lts = Level().timeServer(); u32 Rest = (m_start_time + m_s32TimeLimit) - lts; string64 S; ConvertTime2String(&S, Rest); m_game_ui->SetTimeMsgCaption(S); } else { m_game_ui->SetTimeMsgCaption("00:00:00"); } }; game_PlayerState* lookat_player = Game().lookat_player(); if(local_player && !local_player->IsSkip()) { if (m_bFirstRun) { m_bFirstRun = FALSE; if (!Level().IsDemoPlayStarted() && Level().CurrentEntity()) { VERIFY( m_game_ui ); m_bFirstRun = m_game_ui->ShowServerInfo() ? FALSE : TRUE; } GetActiveVoting(); }; if (lookat_player) { string256 MoneyStr; xr_sprintf(MoneyStr, "%d", lookat_player->money_for_round); m_game_ui->ChangeTotalMoneyIndicator(MoneyStr); } m_game_ui->SetPressJumpMsgCaption(NULL); m_game_ui->SetPressBuyMsgCaption(NULL); if (m_cl_dwWarmUp_Time > Level().timeServer()) { u32 TimeRemains = m_cl_dwWarmUp_Time - Level().timeServer(); string64 S; ConvertTime2String(&S, TimeRemains); string1024 tmpStr = ""; if (TimeRemains > 10000) strconcat(sizeof(tmpStr),tmpStr, *st.translate("mp_time2start"), " ", S); else { if (TimeRemains < 1000) strconcat(sizeof(tmpStr),tmpStr, *st.translate("mp_go"), ""); else { static u32 dwLastTimeRemains = 10; u32 dwCurTimeRemains = TimeRemains/1000; if (dwLastTimeRemains != dwCurTimeRemains) { if (dwCurTimeRemains > 0 && dwCurTimeRemains <= 5) PlaySndMessage(ID_COUNTDOWN_1 + dwCurTimeRemains - 1); } dwLastTimeRemains = dwCurTimeRemains; _itoa(dwCurTimeRemains, S, 10); strconcat(sizeof(tmpStr),tmpStr, *st.translate("mp_ready"), "...", S); } }; m_game_ui->SetWarmUpCaption(tmpStr); } if (Level().CurrentEntity() && smart_cast<CSpectator*>(Level().CurrentEntity())) { if (!(pCurBuyMenu && pCurBuyMenu->IsShown()) && !(pCurSkinMenu && pCurSkinMenu->IsShown()) && !m_game_ui->IsServerInfoShown() && (CurrentGameUI() && CurrentGameUI()->GameIndicatorsShown()) ) { if (!m_bSkinSelected) m_game_ui->SetPressJumpMsgCaption("mp_press_jump2select_skin"); else m_game_ui->SetPressJumpMsgCaption("mp_press_jump2start"); if (CanCallBuyMenu()) m_game_ui->SetPressBuyMsgCaption("mp_press_to_buy"); }; }; if (Level().CurrentControlEntity() && smart_cast<CSpectator*>(Level().CurrentControlEntity()) && (CurrentGameUI()->GameIndicatorsShown()) ) { CSpectator* pSpectator = smart_cast<CSpectator*>(Level().CurrentControlEntity()); if (pSpectator) { string1024 SpectatorStr = ""; pSpectator->GetSpectatorString(SpectatorStr); m_game_ui->SetSpectatorMsgCaption(SpectatorStr); } } u32 CurTime = Level().timeServer(); if (IsVotingEnabled() && IsVotingActive() && m_dwVoteEndTime>=CurTime) { u32 TimeLeft = m_dwVoteEndTime - Level().timeServer(); string1024 VoteTimeResStr; u32 SecsLeft = (TimeLeft % 60000) / 1000; u32 MinitsLeft = (TimeLeft - SecsLeft) / 60000; u32 NumAgreed = 0; PLAYERS_MAP_IT I; I = players.begin(); for(;I!=players.end(); ++I) { game_PlayerState* ps = I->second; if (ps->m_bCurrentVoteAgreed == 1) NumAgreed++; } xr_sprintf (VoteTimeResStr, st.translate("mp_timeleft").c_str(), MinitsLeft, SecsLeft, float(NumAgreed)/players.size()); m_game_ui->SetVoteTimeResultMsg(VoteTimeResStr); }; if ( local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD) && m_u32ForceRespawn && !local_player->testFlag(GAME_PLAYER_FLAG_SPECTATOR) ) { u32 Rest = m_u32ForceRespawn - local_player->DeathTime; string64 S; ConvertTime2String (&S, Rest); string128 FullS; xr_sprintf (FullS, "%s : %s", *st.translate("mp_time2respawn"), S); m_game_ui->SetForceRespawnTimeCaption(FullS); }; if (Level().CurrentViewEntity()) { game_PlayerState* ps = GetPlayerByGameID(Level().CurrentViewEntity()->ID()); if (ps && m_game_ui) m_game_ui->SetRank(ps->team, ps->rank); if (ps && m_game_ui) m_game_ui->SetFraglimit(ps->frags(), m_s32FragLimit); } }; }break; case GAME_PHASE_PENDING: { if (!m_game_ui) break; m_game_ui->UpdateTeamPanels(); m_game_ui->ShowPlayersList(true); }break; case GAME_PHASE_PLAYER_SCORES: { if (!m_game_ui) break; string128 resstring; xr_sprintf(resstring, st.translate("mp_player_wins").c_str(), WinnerName); m_game_ui->SetRoundResultCaption(resstring); SetScore(); m_game_ui->UpdateTeamPanels(); m_game_ui->ShowPlayersList(true); }break; }; //----------------------------------------- if (!CanCallBuyMenu()) HideBuyMenu(); if (pCurSkinMenu && pCurSkinMenu->IsShown() && !CanCallSkinMenu()) pCurSkinMenu->HideDialog(); //----------------------------------------------- //----------------------------------------------- //if (m_game_ui->m_pInventoryMenu && m_game_ui->m_pInventoryMenu->IsShown() && !CanCallInventoryMenu()) // StartStopMenu(m_game_ui->m_pInventoryMenu,true); if ( m_game_ui && m_game_ui->ActorMenu().IsShown() && !CanCallInventoryMenu() ) { m_game_ui->HideActorMenu(); } //----------------------------------------- u32 cur_game_state = Phase(); //if(m_game_ui->m_pMapDesc && m_game_ui->m_pMapDesc->IsShown() && cur_game_state!=GAME_PHASE_INPROGRESS) //{ // m_game_ui->m_pMapDesc->HideDialog(); //} if(pCurSkinMenu && pCurSkinMenu->IsShown() && cur_game_state!=GAME_PHASE_INPROGRESS) { pCurSkinMenu->HideDialog(); } }
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); }