diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index e70d2e0ed..4029312f5 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -115,6 +115,9 @@ bool CChat::OnInput(IInput::CEvent e) void CChat::EnableMode(int Team) { + if(Client()->State() == IClient::STATE_DEMOPLAYBACK) + return; + if(m_Mode == MODE_NONE) { if(Team) @@ -138,6 +141,9 @@ void CChat::OnMessage(int MsgType, void *pRawMsg) void CChat::AddLine(int ClientId, int Team, const char *pLine) { + if(ClientId != -1 && m_pClient->m_aClients[ClientId].m_aName[0] == '\0') // unknown client + return; + char *p = const_cast(pLine); while(*p) { diff --git a/src/game/client/components/emoticon.cpp b/src/game/client/components/emoticon.cpp index a88988c5f..2a9161864 100644 --- a/src/game/client/components/emoticon.cpp +++ b/src/game/client/components/emoticon.cpp @@ -16,7 +16,9 @@ CEmoticon::CEmoticon() void CEmoticon::ConKeyEmoticon(IConsole::IResult *pResult, void *pUserData, int ClientID) { - ((CEmoticon *)pUserData)->m_Active = pResult->GetInteger(0) != 0; + CEmoticon *pSelf = (CEmoticon *)pUserData; + if(pSelf->Client()->State() != IClient::STATE_DEMOPLAYBACK) + ((CEmoticon *)pUserData)->m_Active = pResult->GetInteger(0) != 0; } void CEmoticon::ConEmote(IConsole::IResult *pResult, void *pUserData, int ClientID) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index ffd21a650..0e8b3a509 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -249,7 +249,7 @@ void CHud::RenderVoting() void CHud::RenderCursor() { - if(!m_pClient->m_Snap.m_pLocalCharacter) + if(!m_pClient->m_Snap.m_pLocalCharacter || Client()->State() == IClient::STATE_DEMOPLAYBACK) return; MapscreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup()); diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 52369e0e4..0bda079e0 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1212,7 +1212,7 @@ bool CMenus::OnInput(IInput::CEvent e) if(e.m_Flags&IInput::FLAG_PRESS) { // special for popups - if(e.m_Key == KEY_RETURN) + if(e.m_Key == KEY_RETURN || e.m_Key == KEY_KP_ENTER) m_EnterPressed = true; else if(e.m_Key == KEY_DELETE) m_DeletePressed = true; diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 6c5dcbe4c..2880da25d 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -546,6 +546,11 @@ void CMenus::RenderDemoList(CUIRect MainView) const char *pError = Client()->DemoPlayer_Play(m_lDemos[s_SelectedItem].m_aFilename); if(pError) PopupMessage(Localize("Error"), str_comp(pError, "error loading demo") ? pError : Localize("error loading demo"), Localize("Ok")); + else + { + UI()->SetActiveItem(0); + return; + } } } } @@ -556,7 +561,10 @@ void CMenus::RenderDemoList(CUIRect MainView) if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &DeleteRect) || m_DeletePressed) { if(s_SelectedItem >= 0 && s_SelectedItem < m_lDemos.size()) + { + UI()->SetActiveItem(0); m_Popup = POPUP_DELETE_DEMO; + } } } } diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index ad7b3bcdc..bb79f5508 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -165,6 +165,14 @@ void CPlayers::RenderHook( HookPos = mix(vec2(m_pClient->m_PredictedPrevChar.m_Pos.x, m_pClient->m_PredictedPrevChar.m_Pos.y), vec2(m_pClient->m_PredictedChar.m_Pos.x, m_pClient->m_PredictedChar.m_Pos.y), Client()->PredIntraGameTick()); } + else if(pInfo.m_Local) + { + HookPos = mix(vec2(m_pClient->m_Snap.m_aCharacters[pPlayerChar->m_HookedPlayer].m_Prev.m_X, + m_pClient->m_Snap.m_aCharacters[pPlayerChar->m_HookedPlayer].m_Prev.m_Y), + vec2(m_pClient->m_Snap.m_aCharacters[pPlayerChar->m_HookedPlayer].m_Cur.m_X, + m_pClient->m_Snap.m_aCharacters[pPlayerChar->m_HookedPlayer].m_Cur.m_Y), + Client()->IntraGameTick()); + } else HookPos = mix(vec2(pPrevChar->m_HookX, pPrevChar->m_HookY), vec2(pPlayerChar->m_HookX, pPlayerChar->m_HookY), Client()->IntraGameTick()); } diff --git a/src/game/server/entities/flag.cpp b/src/game/server/entities/flag.cpp index 641811f66..0b2d5c20c 100644 --- a/src/game/server/entities/flag.cpp +++ b/src/game/server/entities/flag.cpp @@ -1,46 +1,38 @@ -/*#include -#include "character.h" +/* +#include #include "flag.h" -CFlag::CFlag(CGameWorld *pGameWorld, int Team, vec2 Pos, CCharacter *pOwner) +CFlag::CFlag(CGameWorld *pGameWorld, int Team) : CEntity(pGameWorld, NETOBJTYPE_FLAG) { m_Team = Team; - m_Pos = Pos; - m_ProximityRadius = m_PhysSize; - m_pCarryingCCharacter = pOwner; + m_ProximityRadius = ms_PhysSize; + m_pCarryingCharacter = NULL; + m_GrabTick = 0; - GameServer()->m_World.InsertEntity(this); + Reset(); } void CFlag::Reset() { - if(!m_pCarryingCCharacter) - return; - - GameServer()->m_World.DestroyEntity(this); -} - -void CFlag::Tick() -{ - if(m_pCarryingCCharacter) - m_Pos = m_pCarryingCCharacter->m_Pos; + m_pCarryingCharacter = NULL; + m_AtStand = 1; + m_Pos = m_StandPos; + m_Vel = vec2(0,0); + m_GrabTick = 0; } void CFlag::Snap(int SnappingClient) { - if((!m_pCarryingCCharacter && GameServer()->m_apPlayers[SnappingClient]->GetTeam() != m_Team && GameServer()->m_apPlayers[SnappingClient]->GetCharacter() && GameServer()->m_apPlayers[SnappingClient]->GetCharacter()->m_RaceState == CCharacter::RACE_STARTED) - ||(m_pCarryingCCharacter && !GameServer()->m_apPlayers[SnappingClient]->m_ShowOthers && SnappingClient != m_pCarryingCCharacter->GetPlayer()->GetCID())) - return; - - CNetObj_Flag *pFlag = (CNetObj_Flag *)Server()->SnapNewItem(NETOBJTYPE_FLAG, m_Id, sizeof(CNetObj_Flag)); + CNetObj_Flag *pFlag = (CNetObj_Flag *)Server()->SnapNewItem(NETOBJTYPE_FLAG, m_Team, sizeof(CNetObj_Flag)); pFlag->m_X = (int)m_Pos.x; pFlag->m_Y = (int)m_Pos.y; pFlag->m_Team = m_Team; pFlag->m_CarriedBy = -1; - if(!m_pCarryingCCharacter) + if(m_AtStand) pFlag->m_CarriedBy = -2; - else if(m_pCarryingCCharacter && m_pCarryingCCharacter->GetPlayer()) - pFlag->m_CarriedBy = m_pCarryingCCharacter->GetPlayer()->GetCID(); -}*/ + else if(m_pCarryingCharacter && m_pCarryingCharacter->GetPlayer()) + pFlag->m_CarriedBy = m_pCarryingCharacter->GetPlayer()->GetCID(); +} +*/ diff --git a/src/game/server/entities/flag.h b/src/game/server/entities/flag.h index fa62006cc..ea99d94f6 100644 --- a/src/game/server/entities/flag.h +++ b/src/game/server/entities/flag.h @@ -6,16 +6,21 @@ class CFlag : public CEntity { public: - static const int m_PhysSize = 14; - class CCharacter *m_pCarryingCCharacter; + static const int ms_PhysSize = 14; + CCharacter *m_pCarryingCharacter; vec2 m_Vel; + vec2 m_StandPos; int m_Team; + int m_AtStand; + int m_DropTick; + int m_GrabTick; - CFlag(CGameWorld *pGameWorld, int Team, vec2 Pos, class CCharacter *pOwner); + CFlag(CGameWorld *pGameWorld, int Team); virtual void Reset(); - virtual void Tick(); virtual void Snap(int SnappingClient); }; -#endif*/ \ No newline at end of file + +#endif +*/ diff --git a/src/game/server/gamemodes/ctf.cpp b/src/game/server/gamemodes/ctf.cpp index 3f6d4fd6c..623a02cdc 100644 --- a/src/game/server/gamemodes/ctf.cpp +++ b/src/game/server/gamemodes/ctf.cpp @@ -1,6 +1,7 @@ -/* // copyright (c) 2007 magnus auvinen, see licence.txt for more info +// copyright (c) 2007 magnus auvinen, see licence.txt for more info/* #include #include +#include #include #include #include "ctf.h" @@ -120,11 +121,11 @@ void CGameControllerCTF::Tick() float CaptureTime = (Server()->Tick() - F->m_GrabTick)/(float)Server()->TickSpeed(); if(CaptureTime <= 60) { - str_format(aBuf, sizeof(aBuf), "The %s flag was captured by %s (%d.%s%d seconds)", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()), (int)CaptureTime%60, ((int)(CaptureTime*100)%100)<10?"0":"", (int)(CaptureTime*100)%100); + str_format(aBuf, sizeof(aBuf), "The %s flag was captured by \"%s\" (%d.%s%d seconds)", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()), (int)CaptureTime%60, ((int)(CaptureTime*100)%100)<10?"0":"", (int)(CaptureTime*100)%100); } else { - str_format(aBuf, sizeof(aBuf), "The %s flag was captured by %s", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID())); + str_format(aBuf, sizeof(aBuf), "The %s flag was captured by \"%s\"", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID())); } GameServer()->SendChat(-1, -2, aBuf); for(int i = 0; i < 2; i++) @@ -210,40 +211,5 @@ void CGameControllerCTF::Tick() } } } +*/ -// Flag -CFlag::CFlag(CGameWorld *pGameWorld, int Team) -: CEntity(pGameWorld, NETOBJTYPE_FLAG) -{ - m_Team = Team; - m_ProximityRadius = ms_PhysSize; - m_pCarryingCharacter = 0x0; - m_GrabTick = 0; - - Reset(); -} - -void CFlag::Reset() -{ - m_pCarryingCharacter = 0x0; - m_AtStand = 1; - m_Pos = m_StandPos; - m_Vel = vec2(0,0); - m_GrabTick = 0; -} - -void CFlag::Snap(int SnappingClient) -{ - CNetObj_Flag *pFlag = (CNetObj_Flag *)Server()->SnapNewItem(NETOBJTYPE_FLAG, m_Team, sizeof(CNetObj_Flag)); - pFlag->m_X = (int)m_Pos.x; - pFlag->m_Y = (int)m_Pos.y; - pFlag->m_Team = m_Team; - pFlag->m_CarriedBy = -1; - - if(m_AtStand) - pFlag->m_CarriedBy = -2; - else if(m_pCarryingCharacter && m_pCarryingCharacter->GetPlayer()) - pFlag->m_CarriedBy = m_pCarryingCharacter->GetPlayer()->GetCID(); -} - - */ \ No newline at end of file diff --git a/src/game/server/gamemodes/ctf.h b/src/game/server/gamemodes/ctf.h index b6262f54d..b653f37b0 100644 --- a/src/game/server/gamemodes/ctf.h +++ b/src/game/server/gamemodes/ctf.h @@ -16,25 +16,6 @@ public: virtual int OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon); }; -// TODO: move to seperate file -class CFlag : public CEntity -{ -public: - static const int ms_PhysSize = 14; - CCharacter *m_pCarryingCharacter; - vec2 m_Vel; - vec2 m_StandPos; - - int m_Team; - int m_AtStand; - int m_DropTick; - int m_GrabTick; - - CFlag(CGameWorld *pGameWorld, int Team); - - virtual void Reset(); - virtual void Snap(int SnappingClient); -}; #endif */ \ No newline at end of file