From 6299f6518aa8576fa06f62101aa466c3da528fb1 Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 7 Sep 2010 20:01:51 +0200 Subject: [PATCH 1/7] disable emote selector and chat window in the demo player. Closes #126 --- src/game/client/components/chat.cpp | 3 +++ src/game/client/components/emoticon.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 167fe181e..d082bf780 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -100,6 +100,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) diff --git a/src/game/client/components/emoticon.cpp b/src/game/client/components/emoticon.cpp index 6d03f88d8..cb54dbcd6 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) { - ((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) From 532ea85aebc9dc2ce6d87fe484766bf37ab40970 Mon Sep 17 00:00:00 2001 From: Choupom Date: Mon, 6 Sep 2010 12:29:28 +0200 Subject: [PATCH 2/7] separated CFlag from ctf --- src/game/server/entities/flag.cpp | 36 ++++++++++++++++++++++++++++++ src/game/server/entities/flag.h | 25 +++++++++++++++++++++ src/game/server/gamemodes/ctf.cpp | 37 +------------------------------ src/game/server/gamemodes/ctf.h | 19 ---------------- 4 files changed, 62 insertions(+), 55 deletions(-) create mode 100644 src/game/server/entities/flag.cpp create mode 100644 src/game/server/entities/flag.h diff --git a/src/game/server/entities/flag.cpp b/src/game/server/entities/flag.cpp new file mode 100644 index 000000000..4d2e16122 --- /dev/null +++ b/src/game/server/entities/flag.cpp @@ -0,0 +1,36 @@ +#include +#include "flag.h" + +CFlag::CFlag(CGameWorld *pGameWorld, int Team) +: CEntity(pGameWorld, NETOBJTYPE_FLAG) +{ + m_Team = Team; + m_ProximityRadius = ms_PhysSize; + m_pCarryingCharacter = NULL; + m_GrabTick = 0; + + Reset(); +} + +void CFlag::Reset() +{ + m_pCarryingCharacter = NULL; + 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(); +} diff --git a/src/game/server/entities/flag.h b/src/game/server/entities/flag.h new file mode 100644 index 000000000..1406d9827 --- /dev/null +++ b/src/game/server/entities/flag.h @@ -0,0 +1,25 @@ +#ifndef GAME_SERVER_ENTITIES_FLAG_H +#define GAME_SERVER_ENTITIES_FLAG_H + +#include + +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 diff --git a/src/game/server/gamemodes/ctf.cpp b/src/game/server/gamemodes/ctf.cpp index b28191af3..353376e2a 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 #include #include +#include #include #include #include "ctf.h" @@ -210,39 +211,3 @@ 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(); -} - diff --git a/src/game/server/gamemodes/ctf.h b/src/game/server/gamemodes/ctf.h index 16c6097ad..f50509be5 100644 --- a/src/game/server/gamemodes/ctf.h +++ b/src/game/server/gamemodes/ctf.h @@ -16,24 +16,5 @@ 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 From 71109a98fbcb753e8ab064099e4a2d8dc671481b Mon Sep 17 00:00:00 2001 From: Choupom Date: Mon, 6 Sep 2010 12:32:41 +0200 Subject: [PATCH 3/7] fixed chat message with missing name (#110) --- src/game/client/components/chat.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index d082bf780..60b621880 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -126,6 +126,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) { From cbf07ffa57c64a1a6ecc454716a6f3ebc586d7e8 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 8 Sep 2010 02:07:36 +0200 Subject: [PATCH 4/7] added fix for don't show cursor while playing demo by Choupom. Closes #128 --- src/game/client/components/hud.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index 73dfef534..192238e30 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -235,7 +235,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()); From d4b145a8ee201d25e5259aba29b65b84bb444b3a Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 8 Sep 2010 02:27:48 +0200 Subject: [PATCH 5/7] fixed Gui lock while deleting/reading demos. Closes #167 --- src/game/client/components/menus_demo.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) 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; + } } } } From e31b125a0de8b359921807d3b5590e8e20fcfc8e Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 8 Sep 2010 02:32:41 +0200 Subject: [PATCH 6/7] use the numpad enter key as well. Closes #166 --- src/game/client/components/menus.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 78b6b0fca..b1e3e3d0b 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1063,7 +1063,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; From e191b2c59e24eee5bf77b993e9a5dec2a4c7adfa Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 8 Sep 2010 02:54:03 +0200 Subject: [PATCH 7/7] when hooking a player don't use predicted values for rendering the hook. Closes #9 --- src/game/client/components/players.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) 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()); }