From 216967c3bf72ccff9d069327a5531e50f8f88b5a Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 17 Jan 2011 12:28:37 +0100 Subject: [PATCH 01/24] release gameclient components when opening the editor. Closes #429 --- src/engine/client.h | 1 + src/engine/client/client.cpp | 10 ++++++++++ src/engine/client/client.h | 1 + src/game/client/components/controls.cpp | 5 +++++ src/game/client/components/controls.h | 1 + src/game/client/gameclient.cpp | 5 +++++ src/game/client/gameclient.h | 1 + 7 files changed, 24 insertions(+) diff --git a/src/engine/client.h b/src/engine/client.h index 80a0241d8..a0ebb3e74 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -149,6 +149,7 @@ public: virtual void OnConnected() = 0; virtual void OnMessage(int MsgId, CUnpacker *pUnpacker) = 0; virtual void OnPredict() = 0; + virtual void OnActivateEditor() = 0; virtual int OnSnapInput(int *pData) = 0; diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index d67e33320..9b8c41517 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -414,6 +414,7 @@ CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta), m_DemoRecorder(&m_SnapshotD m_WindowMustRefocus = 0; m_SnapCrcErrors = 0; m_AutoScreenshotRecycle = false; + m_EditorActive = false; m_AckGameTick = -1; m_CurrentRecvTick = 0; @@ -1914,12 +1915,21 @@ void CClient::Run() // render if(g_Config.m_ClEditor) { + if(!m_EditorActive) + { + GameClient()->OnActivateEditor(); + m_EditorActive = true; + } + Update(); m_pEditor->UpdateAndRender(); m_pGraphics->Swap(); } else { + if(m_EditorActive) + m_EditorActive = false; + Update(); if(g_Config.m_DbgStress) diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 406b0ac77..f25e7cf75 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -141,6 +141,7 @@ class CClient : public IClient, public CDemoPlayer::IListner int m_WindowMustRefocus; int m_SnapCrcErrors; bool m_AutoScreenshotRecycle; + bool m_EditorActive; int m_AckGameTick; int m_CurrentRecvTick; diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index 1dd74af28..f7da46b62 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -32,6 +32,11 @@ void CControls::OnReset() m_InputDirectionRight = 0; } +void CControls::OnRelease() +{ + OnReset(); +} + void CControls::OnPlayerDeath() { m_LastData.m_WantedWeapon = m_InputData.m_WantedWeapon = 0; diff --git a/src/game/client/components/controls.h b/src/game/client/components/controls.h index 38b3c8ba0..a50318f5a 100644 --- a/src/game/client/components/controls.h +++ b/src/game/client/components/controls.h @@ -19,6 +19,7 @@ public: CControls(); virtual void OnReset(); + virtual void OnRelease(); virtual void OnRender(); virtual void OnMessage(int MsgType, void *pRawMsg); virtual bool OnMouseMove(float x, float y); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 9a05cc88d..e37eebeab 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -971,6 +971,11 @@ void CGameClient::OnPredict() m_PredictedTick = Client()->PredGameTick(); } +void CGameClient::OnActivateEditor() +{ + OnRelease(); +} + void CGameClient::CClientData::UpdateRenderInfo() { m_RenderInfo = m_SkinInfo; diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index 99e64028a..1e5c4856f 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -176,6 +176,7 @@ public: virtual void OnMessage(int MsgId, CUnpacker *pUnpacker); virtual void OnNewSnapshot(); virtual void OnPredict(); + virtual void OnActivateEditor(); virtual int OnSnapInput(int *pData); virtual void OnShutdown(); virtual void OnEnterGame(); From 40f6740742c7d967038abdd5a582d8b50712d1b2 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 17 Jan 2011 12:56:49 +0100 Subject: [PATCH 02/24] fixed few spelling mistakes and disabled an unused command --- src/engine/server/register.cpp | 2 +- src/game/server/gamecontroller.cpp | 4 ++-- src/game/variables.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/server/register.cpp b/src/engine/server/register.cpp index dfa3060f3..36b26f1e1 100644 --- a/src/engine/server/register.cpp +++ b/src/engine/server/register.cpp @@ -187,7 +187,7 @@ void CRegister::RegisterUpdate() else { char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "choosen '%s' as master, sending heartbeats", m_pMasterServer->GetName(m_RegisterRegisteredServer)); + str_format(aBuf, sizeof(aBuf), "chose '%s' as master, sending heartbeats", m_pMasterServer->GetName(m_RegisterRegisteredServer)); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", aBuf); m_aMasterserverInfo[m_RegisterRegisteredServer].m_LastSend = 0; RegisterNewState(REGISTERSTATE_HEARTBEAT); diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 3e8af96c1..23a5e1716 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -626,7 +626,7 @@ bool IGameController::CheckTeamBalance() char aBuf[256]; if(absolute(aT[0]-aT[1]) >= 2) { - str_format(aBuf, sizeof(aBuf), "Team is NOT balanced (red=%d blue=%d)", aT[0], aT[1]); + str_format(aBuf, sizeof(aBuf), "Teams are NOT balanced (red=%d blue=%d)", aT[0], aT[1]); GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); if(GameServer()->m_pController->m_UnbalancedTick == -1) GameServer()->m_pController->m_UnbalancedTick = Server()->Tick(); @@ -634,7 +634,7 @@ bool IGameController::CheckTeamBalance() } else { - str_format(aBuf, sizeof(aBuf), "Team is balanced (red=%d blue=%d)", aT[0], aT[1]); + str_format(aBuf, sizeof(aBuf), "Teams are balanced (red=%d blue=%d)", aT[0], aT[1]); GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); GameServer()->m_pController->m_UnbalancedTick = -1; return true; diff --git a/src/game/variables.h b/src/game/variables.h index 1a5575d5a..0621f6afa 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -25,7 +25,7 @@ MACRO_CONFIG_INT(ClMouseMaxDistance, cl_mouse_max_distance, 800, 0, 0, CFGFLAG_C MACRO_CONFIG_INT(EdShowkeys, ed_showkeys, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") -MACRO_CONFIG_INT(ClFlow, cl_flow, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") +//MACRO_CONFIG_INT(ClFlow, cl_flow, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") MACRO_CONFIG_INT(ClShowWelcome, cl_show_welcome, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") MACRO_CONFIG_INT(ClMotdTime, cl_motd_time, 10, 0, 100, CFGFLAG_CLIENT|CFGFLAG_SAVE, "How long to show the server message of the day") From bf6fcc20f4a9cccab0470d5848a2401bd0bfe93e Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 17 Jan 2011 13:28:15 +0100 Subject: [PATCH 03/24] added an error popup on startup when the sound couldn't be initialised. Closes #425 --- data/languages/bosnian.txt | 6 ++++++ data/languages/czech.txt | 6 ++++++ data/languages/dutch.txt | 6 ++++++ data/languages/finnish.txt | 6 ++++++ data/languages/french.txt | 6 ++++++ data/languages/german.txt | 6 ++++++ data/languages/italian.txt | 6 ++++++ data/languages/polish.txt | 6 ++++++ data/languages/portuguese.txt | 6 ++++++ data/languages/romanian.txt | 6 ++++++ data/languages/russian.txt | 6 ++++++ data/languages/serbian.txt | 6 ++++++ data/languages/swedish.txt | 6 ++++++ data/languages/ukrainian.txt | 6 ++++++ src/engine/client.h | 2 ++ src/engine/client/client.cpp | 2 +- src/engine/client/client.h | 3 +++ src/game/client/components/menus.cpp | 15 +++++++++++++++ src/game/client/components/menus.h | 1 + 19 files changed, 106 insertions(+), 1 deletion(-) diff --git a/data/languages/bosnian.txt b/data/languages/bosnian.txt index 8f183bb19..c88063567 100644 --- a/data/languages/bosnian.txt +++ b/data/languages/bosnian.txt @@ -867,6 +867,9 @@ Select layer. Right click for properties. Shift == +Sound error +== + Square == @@ -882,6 +885,9 @@ Switch between images and layers managment. Switch curve type == +The audio device couldn't be initialised. +== + Tiles == diff --git a/data/languages/czech.txt b/data/languages/czech.txt index 0383f26e0..9b39066aa 100644 --- a/data/languages/czech.txt +++ b/data/languages/czech.txt @@ -858,6 +858,9 @@ Shift Show chat == +Sound error +== + Square == @@ -876,6 +879,9 @@ Switch between images and layers managment. Switch curve type == +The audio device couldn't be initialised. +== + Tiles == diff --git a/data/languages/dutch.txt b/data/languages/dutch.txt index fc5d2a8db..cf55a647c 100644 --- a/data/languages/dutch.txt +++ b/data/languages/dutch.txt @@ -963,6 +963,12 @@ no limit Name plates size == +Sound error +== + +The audio device couldn't be initialised. +== + Unable to delete the demo == diff --git a/data/languages/finnish.txt b/data/languages/finnish.txt index 6c240eef9..f97a10e58 100644 --- a/data/languages/finnish.txt +++ b/data/languages/finnish.txt @@ -864,6 +864,9 @@ Select layer. Right click for properties. Shift == +Sound error +== + Square == @@ -879,6 +882,9 @@ Switch between images and layers managment. Switch curve type == +The audio device couldn't be initialised. +== + Tiles == diff --git a/data/languages/french.txt b/data/languages/french.txt index febb632d3..e19aa1e20 100644 --- a/data/languages/french.txt +++ b/data/languages/french.txt @@ -897,6 +897,9 @@ Rotation of the envelope Shift == +Sound error +== + Squares the current quad == @@ -909,6 +912,9 @@ Switch between images and layers managment. Switch curve type == +The audio device couldn't be initialised. +== + Tiles == diff --git a/data/languages/german.txt b/data/languages/german.txt index ca1c50070..da62f00ee 100644 --- a/data/languages/german.txt +++ b/data/languages/german.txt @@ -963,6 +963,12 @@ no limit Name plates size == +Sound error +== + +The audio device couldn't be initialised. +== + Unable to delete the demo == diff --git a/data/languages/italian.txt b/data/languages/italian.txt index e93ac0bef..495033aa5 100644 --- a/data/languages/italian.txt +++ b/data/languages/italian.txt @@ -855,6 +855,9 @@ Shift Show chat == +Sound error +== + Square == @@ -873,6 +876,9 @@ Switch between images and layers managment. Switch curve type == +The audio device couldn't be initialised. +== + Tiles == diff --git a/data/languages/polish.txt b/data/languages/polish.txt index 2fee6abcc..9c693e2d6 100644 --- a/data/languages/polish.txt +++ b/data/languages/polish.txt @@ -930,9 +930,15 @@ Rotation of the envelope Shift == +Sound error +== + Stop record == +The audio device couldn't be initialised. +== + Tiles == diff --git a/data/languages/portuguese.txt b/data/languages/portuguese.txt index eb1770f02..db7beab28 100644 --- a/data/languages/portuguese.txt +++ b/data/languages/portuguese.txt @@ -864,6 +864,9 @@ Select layer. Right click for properties. Shift == +Sound error +== + Square == @@ -879,6 +882,9 @@ Switch between images and layers managment. Switch curve type == +The audio device couldn't be initialised. +== + Tiles == diff --git a/data/languages/romanian.txt b/data/languages/romanian.txt index 9e33ca351..49886482f 100644 --- a/data/languages/romanian.txt +++ b/data/languages/romanian.txt @@ -963,6 +963,12 @@ no limit ##### needs translation ##### +Sound error +== + +The audio device couldn't be initialised. +== + Unable to delete the demo == diff --git a/data/languages/russian.txt b/data/languages/russian.txt index 8ae65a8c8..d708923d5 100644 --- a/data/languages/russian.txt +++ b/data/languages/russian.txt @@ -930,9 +930,15 @@ Rotation of the envelope Shift == +Sound error +== + Stop record == +The audio device couldn't be initialised. +== + Tiles == diff --git a/data/languages/serbian.txt b/data/languages/serbian.txt index e3d106de3..54445eba8 100644 --- a/data/languages/serbian.txt +++ b/data/languages/serbian.txt @@ -864,6 +864,9 @@ Select layer. Right click for properties. Shift == +Sound error +== + Square == @@ -879,6 +882,9 @@ Switch between images and layers managment. Switch curve type == +The audio device couldn't be initialised. +== + Tiles == diff --git a/data/languages/swedish.txt b/data/languages/swedish.txt index b779995f0..4ee8e04d9 100644 --- a/data/languages/swedish.txt +++ b/data/languages/swedish.txt @@ -855,6 +855,9 @@ Shift Show chat == +Sound error +== + Square == @@ -873,6 +876,9 @@ Switch between images and layers managment. Switch curve type == +The audio device couldn't be initialised. +== + Tiles == diff --git a/data/languages/ukrainian.txt b/data/languages/ukrainian.txt index 477bed262..c526600c7 100644 --- a/data/languages/ukrainian.txt +++ b/data/languages/ukrainian.txt @@ -945,6 +945,12 @@ Rotation of the envelope Shift == +Sound error +== + +The audio device couldn't be initialised. +== + Unable to delete the demo == diff --git a/src/engine/client.h b/src/engine/client.h index a0ebb3e74..2da2bd8b7 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -130,6 +130,8 @@ public: virtual const char *ErrorString() = 0; virtual const char *LatestVersion() = 0; virtual bool ConnectionProblems() = 0; + + virtual bool SoundInitFailed() = 0; }; class IGameClient : public IInterface diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 9b8c41517..3652b2725 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1803,7 +1803,7 @@ void CClient::Run() m_pEditor->Init(); // init sound, allowed to fail - Sound()->Init(); + m_SoundInitFailed = Sound()->Init() != 0; // load data if(!LoadData()) diff --git a/src/engine/client/client.h b/src/engine/client/client.h index f25e7cf75..8ba706622 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -142,6 +142,7 @@ class CClient : public IClient, public CDemoPlayer::IListner int m_SnapCrcErrors; bool m_AutoScreenshotRecycle; bool m_EditorActive; + bool m_SoundInitFailed; int m_AckGameTick; int m_CurrentRecvTick; @@ -235,6 +236,8 @@ public: virtual bool ConnectionProblems(); + virtual bool SoundInitFailed() { return m_SoundInitFailed; } + void DirectInput(int *pInput, int Size); void SendInput(); diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index d70e0b880..cac865885 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -753,6 +753,14 @@ int CMenus::Render() // some margin around the screen Screen.Margin(10.0f, &Screen); + static bool s_SoundCheck = false; + if(!s_SoundCheck && m_Popup == POPUP_NONE) + { + if(Client()->SoundInitFailed()) + m_Popup = POPUP_SOUNDERROR; + s_SoundCheck = true; + } + if(m_Popup == POPUP_NONE) { // do tab bar @@ -840,6 +848,13 @@ int CMenus::Render() pExtraText = Localize("Are you sure that you want to delete the demo?"); ExtraAlign = -1; } + else if(m_Popup == POPUP_SOUNDERROR) + { + pTitle = Localize("Sound error"); + pExtraText = Localize("The audio device couldn't be initialised."); + pButtonText = Localize("Ok"); + ExtraAlign = -1; + } else if(m_Popup == POPUP_PASSWORD) { pTitle = Localize("Password incorrect"); diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 5e93a90ae..40f6f1bd7 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -97,6 +97,7 @@ class CMenus : public CComponent POPUP_PURE, POPUP_LANGUAGE, POPUP_DELETE_DEMO, + POPUP_SOUNDERROR, POPUP_PASSWORD, POPUP_QUIT, }; From 813f0797d8b47135df3c4448bf4df3272bdc12d7 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 17 Jan 2011 13:42:40 +0100 Subject: [PATCH 04/24] fixed scoreboard active check. Closes #423 --- src/game/client/components/scoreboard.cpp | 39 ++++++++++------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 5fb2395fc..afc87ef8d 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -265,24 +265,7 @@ void CScoreboard::RenderRecordingNotification(float x) void CScoreboard::OnRender() { - bool DoScoreBoard = false; - - // if we activly wanna look on the scoreboard - if(m_Active) - DoScoreBoard = true; - - if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS) - { - // we are not a spectator, check if we are ead - if(!m_pClient->m_Snap.m_pLocalCharacter || m_pClient->m_Snap.m_pLocalCharacter->m_Health < 0) - DoScoreBoard = true; - } - - // if we the game is over - if(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver) - DoScoreBoard = true; - - if(!DoScoreBoard) + if(!Active()) return; // if the score board is active, then we should clear the motd message aswell @@ -298,10 +281,7 @@ void CScoreboard::OnRender() float w = 650.0f; if(m_pClient->m_Snap.m_pGameobj && !(m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_TEAMS)) - { RenderScoreboard(Width/2-w/2, 150.0f, w, 0, 0); - //render_scoreboard(gameobj, 0, 0, -1, 0); - } else { @@ -328,5 +308,20 @@ void CScoreboard::OnRender() bool CScoreboard::Active() { - return m_Active | (m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver); + // if we activly wanna look on the scoreboard + if(m_Active) + return true; + + if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS) + { + // we are not a spectator, check if we are dead + if(!m_pClient->m_Snap.m_pLocalCharacter || m_pClient->m_Snap.m_pLocalCharacter->m_Health <= 0) + return true; + } + + // if the game is over + if(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver) + return true; + + return false; } From 99c6b87c1a1e6b01fd3f92e043a7100ae3b2f0d4 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 17 Jan 2011 13:46:59 +0100 Subject: [PATCH 05/24] hide broadcast when motd is active. Closes #420 --- src/game/client/components/broadcast.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/game/client/components/broadcast.cpp b/src/game/client/components/broadcast.cpp index 37876562c..17b2d66b6 100644 --- a/src/game/client/components/broadcast.cpp +++ b/src/game/client/components/broadcast.cpp @@ -8,6 +8,7 @@ #include +#include #include #include "broadcast.h" @@ -19,7 +20,7 @@ void CBroadcast::OnReset() void CBroadcast::OnRender() { - if(m_pClient->m_pScoreboard->Active()) + if(m_pClient->m_pScoreboard->Active() || m_pClient->m_pMotd->IsActive()) return; Graphics()->MapScreen(0, 0, 300*Graphics()->ScreenAspect(), 300); From 02db5bfe6626b0e6d480c59110816624083790ce Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 17 Jan 2011 13:55:14 +0100 Subject: [PATCH 06/24] decreased the height of the scoreboard a bit. Closes #417 --- src/game/client/components/scoreboard.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index afc87ef8d..36c847c8e 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -123,13 +123,13 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch return; //float ystart = y; - float h = 750.0f; + float h = 740.0f; Graphics()->BlendNormal(); Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); Graphics()->SetColor(0,0,0,0.5f); - RenderTools()->DrawRoundRect(x-10.f, y-10.f, w, h, 17.0f); + RenderTools()->DrawRoundRect(x-10.f, y, w, h, 17.0f); Graphics()->QuadsEnd(); // render title From 232aafa89157839cc63eef28795037f5fe2b15b4 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 17 Jan 2011 15:48:57 +0100 Subject: [PATCH 07/24] added Python 3 support fixes by Sworddragon --- datasrc/compile.py | 4 ++-- scripts/cmd5.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/datasrc/compile.py b/datasrc/compile.py index 0cca54981..bab139317 100644 --- a/datasrc/compile.py +++ b/datasrc/compile.py @@ -69,8 +69,8 @@ if gen_client_content_header or gen_server_content_header: order = [] for line in contentlines: line = line.strip() - if line[:6] == "class " and '(Struct)' in line: - order += [line.split()[1].split("(")[0]] + if line[:6] == b"class " and b'(Struct)' in line: + order += [line.split()[1].split(b"(")[0].decode('ascii')] for name in order: EmitTypeDeclaration(content.__dict__[name]) diff --git a/scripts/cmd5.py b/scripts/cmd5.py index dbdfae824..6ab65160e 100644 --- a/scripts/cmd5.py +++ b/scripts/cmd5.py @@ -3,15 +3,15 @@ import hashlib, sys, re alphanum = "0123456789abcdefghijklmnopqrstuvwzyxABCDEFGHIJKLMNOPQRSTUVWXYZ_" def cstrip(lines): - d = "" + d = b"" for l in lines: - l = re.sub("#.*", "", l) - l = re.sub("//.*", "", l) - d += l + " " - d = re.sub("\/\*.*?\*/", "", d) # remove /* */ comments - d = d.replace("\t", " ") # tab to space - d = re.sub(" *", " ", d) # remove double spaces - d = re.sub("", "", d) # remove /* */ comments + l = re.sub(b"#.*", b"", l) + l = re.sub(b"//.*", b"", l) + d += l + b" " + d = re.sub(b"\/\*.*?\*/", b"", d) # remove /* */ comments + d = d.replace(b"\t", b" ") # tab to space + d = re.sub(b" *", b" ", d) # remove double spaces + d = re.sub(b"", b"", d) # remove /* */ comments d = d.strip() @@ -24,11 +24,11 @@ def cstrip(lines): i += 1 return d -f = "" +f = b"" for filename in sys.argv[1:]: f += cstrip([l.strip() for l in open(filename, "rb")]) -hash = hashlib.md5(f.encode()).hexdigest().lower()[16:] +hash = hashlib.md5(f).hexdigest().lower()[16:] # TODO: refactor hash that is equal to the 0.5 hash, remove when we # TODO: remove when we don't need it any more if hash == "026b8eceb4cdd369": From 99e9d4910a4eb28cde118c0cc42eec750068b02d Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 17 Jan 2011 15:55:23 +0100 Subject: [PATCH 08/24] fixed that team mates are regarded when evaluating the spawn position. Closes #426 --- src/game/server/gamecontroller.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 23a5e1716..8ba693989 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -51,10 +51,7 @@ float IGameController::EvaluateSpawnPos(CSpawnEval *pEval, vec2 Pos) Scoremod = 0.5f; float d = distance(Pos, pC->m_Pos); - if(d == 0) - Score += 1000000000.0f; - else - Score += 1.0f/d; + Score += Scoremod * (d == 0 ? 1000000000.0f : 1.0f/d); } return Score; From 3b3ca9cd67badc96622b52ed5de6a9a387d47472 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 17 Jan 2011 16:31:24 +0100 Subject: [PATCH 09/24] rearranged the goals within the scoreboard a bit --- src/game/client/components/scoreboard.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 36c847c8e..3eda5ff01 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -51,32 +51,26 @@ void CScoreboard::RenderGoals(float x, float y, float w) Graphics()->QuadsEnd(); // render goals - //y = ystart+h-54; - float tw = 0.0f; if(m_pClient->m_Snap.m_pGameobj) { if(m_pClient->m_Snap.m_pGameobj->m_ScoreLimit) { char aBuf[64]; str_format(aBuf, sizeof(aBuf), "%s: %d", Localize("Score limit"), m_pClient->m_Snap.m_pGameobj->m_ScoreLimit); - TextRender()->Text(0, x+20.0f, y, 22.0f, aBuf, -1); - tw += TextRender()->TextWidth(0, 22.0f, aBuf, -1); + TextRender()->Text(0, x, y, 20.0f, aBuf, -1); } if(m_pClient->m_Snap.m_pGameobj->m_TimeLimit) { char aBuf[64]; str_format(aBuf, sizeof(aBuf), Localize("Time limit: %d min"), m_pClient->m_Snap.m_pGameobj->m_TimeLimit); - TextRender()->Text(0, x+220.0f, y, 22.0f, aBuf, -1); - tw += TextRender()->TextWidth(0, 22.0f, aBuf, -1); + TextRender()->Text(0, x+220.0f, y, 20.0f, aBuf, -1); } if(m_pClient->m_Snap.m_pGameobj->m_RoundNum && m_pClient->m_Snap.m_pGameobj->m_RoundCurrent) { char aBuf[64]; str_format(aBuf, sizeof(aBuf), "%s %d/%d", Localize("Round"), m_pClient->m_Snap.m_pGameobj->m_RoundCurrent, m_pClient->m_Snap.m_pGameobj->m_RoundNum); - TextRender()->Text(0, x+450.0f, y, 22.0f, aBuf, -1); - - /*[48c3fd4c][game/scoreboard]: timelimit x:219.428558 - [48c3fd4c][game/scoreboard]: round x:453.142822*/ + float tw = TextRender()->TextWidth(0, 20.0f, aBuf, -1); + TextRender()->Text(0, x+w-tw-20.0f, y, 20.0f, aBuf, -1); } } } From 0b14286c7f4accc1e38e0c84269d0c50b165a679 Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 18 Jan 2011 17:56:09 +0100 Subject: [PATCH 10/24] skip spectators in dm hud --- src/game/client/components/hud.cpp | 38 +++++++++++++++++++----------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index 9f49952d9..c49abca1e 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -138,24 +138,34 @@ void CHud::RenderScoreHud() } else { - int Local = 1; + int Local = -1; int aPos[2] = { 1, 2 }; - const CNetObj_PlayerInfo *apPlayerInfo[2] = { m_pClient->m_Snap.m_paInfoByScore[0], 0 }; - if(m_pClient->m_Snap.m_paInfoByScore[0]) + const CNetObj_PlayerInfo *apPlayerInfo[2] = { 0, 0 }; + int i = 0; + for(int t = 0; t < 2 && i < MAX_CLIENTS && m_pClient->m_Snap.m_paInfoByScore[i]; ++i) { - if(m_pClient->m_Snap.m_paInfoByScore[0]->m_ClientId == m_pClient->m_Snap.m_LocalCid) + if(m_pClient->m_Snap.m_paInfoByScore[i]->m_Team != TEAM_SPECTATORS) { - apPlayerInfo[1] = m_pClient->m_Snap.m_paInfoByScore[1]; - Local = 0; + apPlayerInfo[t] = m_pClient->m_Snap.m_paInfoByScore[i]; + if(apPlayerInfo[t]->m_ClientId == m_pClient->m_Snap.m_LocalCid) + Local = t; + ++t; + } + } + // search local player info if not a spectator, nor within top2 scores + if(Local == -1 && m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS) + { + for(; i < MAX_CLIENTS && m_pClient->m_Snap.m_paInfoByScore[i]; ++i) + { + if(m_pClient->m_Snap.m_paInfoByScore[i]->m_Team != TEAM_SPECTATORS) + ++aPos[1]; + if(m_pClient->m_Snap.m_paInfoByScore[i]->m_ClientId == m_pClient->m_Snap.m_LocalCid) + { + apPlayerInfo[1] = m_pClient->m_Snap.m_paInfoByScore[i]; + Local = 1; + break; + } } - else - for(int i = 1; i < MAX_CLIENTS; ++i) - if(m_pClient->m_Snap.m_paInfoByScore[i]->m_ClientId == m_pClient->m_Snap.m_LocalCid) - { - apPlayerInfo[1] = m_pClient->m_Snap.m_paInfoByScore[i]; - aPos[1] = i+1; - break; - } } char aScore[2][32]; for(int t = 0; t < 2; ++t) From 8cdabb890f2967d74e801ff090beff454322a81b Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 18 Jan 2011 18:09:09 +0100 Subject: [PATCH 11/24] fixed that the server crashes on too many snap items (Closes #317), optimised snapshot hashing --- src/engine/shared/snapshot.cpp | 15 ++++++++++----- src/engine/shared/snapshot.h | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/engine/shared/snapshot.cpp b/src/engine/shared/snapshot.cpp index ac16a6f8e..7ead43201 100644 --- a/src/engine/shared/snapshot.cpp +++ b/src/engine/shared/snapshot.cpp @@ -80,7 +80,7 @@ static void GenerateHash(CItemList *pHashlist, CSnapshot *pSnapshot) for(int i = 0; i < pSnapshot->NumItems(); i++) { int Key = pSnapshot->GetItem(i)->Key(); - int HashID = ((Key>>8)&0xf0) | (Key&0xf); + int HashID = ((Key>>12)&0xf0) | (Key&0xf); if(pHashlist[HashID].m_Num != 64) { pHashlist[HashID].m_aIndex[pHashlist[HashID].m_Num] = i; @@ -92,7 +92,7 @@ static void GenerateHash(CItemList *pHashlist, CSnapshot *pSnapshot) static int GetItemIndexHashed(int Key, const CItemList *pHashlist) { - int HashID = ((Key>>8)&0xf0) | (Key&0xf); + int HashID = ((Key>>12)&0xf0) | (Key&0xf); for(int i = 0; i < pHashlist[HashID].m_Num; i++) { if(pHashlist[HashID].m_aKeys[i] == Key) @@ -523,6 +523,14 @@ int CSnapshotBuilder::Finish(void *SpnapData) void *CSnapshotBuilder::NewItem(int Type, int ID, int Size) { + if(m_DataSize + sizeof(CSnapshotItem) + Size >= CSnapshot::MAX_SIZE || + m_NumItems+1 >= MAX_ITEMS) + { + dbg_assert(m_DataSize < CSnapshot::MAX_SIZE, "too much data"); + dbg_assert(m_NumItems < MAX_ITEMS, "too many items"); + return 0; + } + CSnapshotItem *pObj = (CSnapshotItem *)(m_aData + m_DataSize); mem_zero(pObj, sizeof(CSnapshotItem) + Size); @@ -530,9 +538,6 @@ void *CSnapshotBuilder::NewItem(int Type, int ID, int Size) m_aOffsets[m_NumItems] = m_DataSize; m_DataSize += sizeof(CSnapshotItem) + Size; m_NumItems++; - - dbg_assert(m_DataSize < CSnapshot::MAX_SIZE, "too much data"); - dbg_assert(m_NumItems < MAX_ITEMS, "too many items"); return pObj->Data(); } diff --git a/src/engine/shared/snapshot.h b/src/engine/shared/snapshot.h index abd25a72f..34c3a5487 100644 --- a/src/engine/shared/snapshot.h +++ b/src/engine/shared/snapshot.h @@ -114,7 +114,7 @@ class CSnapshotBuilder { enum { - MAX_ITEMS = 1024*2 + MAX_ITEMS = 1024 }; char m_aData[CSnapshot::MAX_SIZE]; From 9c5477a6e81a091f6b8724aa962b2d3038c96ce9 Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 18 Jan 2011 18:26:02 +0100 Subject: [PATCH 12/24] added romanian translation update by kneekoo --- data/languages/romanian.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/languages/romanian.txt b/data/languages/romanian.txt index 49886482f..32e1011b9 100644 --- a/data/languages/romanian.txt +++ b/data/languages/romanian.txt @@ -856,6 +856,9 @@ Type UI Color == Culoare meniu +Unable to delete the demo +== Nu pot șterge demo-ul + Up == Sus @@ -969,8 +972,5 @@ Sound error The audio device couldn't be initialised. == -Unable to delete the demo -== - ##### old translations ##### From da84771345e48ce55ee2b46f0d79002c5b535175 Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 18 Jan 2011 18:53:19 +0100 Subject: [PATCH 13/24] removed some old checks --- src/game/client/components/players.cpp | 16 ++-------------- src/game/client/components/scoreboard.cpp | 2 +- src/game/client/gameclient.cpp | 2 +- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index d1fe2aed0..0544010a4 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -121,9 +121,6 @@ void CPlayers::RenderHook( float IntraTick = Client()->IntraGameTick(); - if(Player.m_Health < 0) // dont render dead players - return; - // set size RenderInfo.m_Size = 64.0f; @@ -131,7 +128,7 @@ void CPlayers::RenderHook( // use preditect players if needed if(pInfo.m_Local && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK) { - if(!m_pClient->m_Snap.m_pLocalCharacter || (m_pClient->m_Snap.m_pLocalCharacter->m_Health < 0) || (m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver)) + if(!m_pClient->m_Snap.m_pLocalCharacter || (m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver)) { } else @@ -145,9 +142,6 @@ void CPlayers::RenderHook( vec2 Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick); - if(Prev.m_Health < 0) // Don't flicker from previous position - Position = vec2(Player.m_X, Player.m_Y); - // draw hook if (Prev.m_HookState>0 && Player.m_HookState>0) { @@ -254,9 +248,6 @@ void CPlayers::RenderPlayer( float IntraTick = Client()->IntraGameTick(); - if(Player.m_Health < 0) // dont render dead players - return; - float Angle = mix((float)Prev.m_Angle, (float)Player.m_Angle, IntraTick)/256.0f; //float angle = 0; @@ -292,7 +283,7 @@ void CPlayers::RenderPlayer( // use preditect players if needed if(pInfo.m_Local && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK) { - if(!m_pClient->m_Snap.m_pLocalCharacter || (m_pClient->m_Snap.m_pLocalCharacter->m_Health < 0) || (m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver)) + if(!m_pClient->m_Snap.m_pLocalCharacter || (m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver)) { } else @@ -322,9 +313,6 @@ void CPlayers::RenderPlayer( m_pClient->m_pEffects->AirJump(Position); } - if(Prev.m_Health < 0) // Don't flicker from previous position - Position = vec2(Player.m_X, Player.m_Y); - bool Stationary = Player.m_VelX <= 1 && Player.m_VelX >= -1; bool InAir = !Collision()->CheckPoint(Player.m_X, Player.m_Y+16); bool WantOtherDir = (Player.m_Direction == -1 && Vel.x > 0) || (Player.m_Direction == 1 && Vel.x < 0); diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 3eda5ff01..bed486194 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -309,7 +309,7 @@ bool CScoreboard::Active() if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS) { // we are not a spectator, check if we are dead - if(!m_pClient->m_Snap.m_pLocalCharacter || m_pClient->m_Snap.m_pLocalCharacter->m_Health <= 0) + if(!m_pClient->m_Snap.m_pLocalCharacter) return true; } diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index e37eebeab..9bb3bb907 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -393,7 +393,7 @@ void CGameClient::UpdateLocalCharacterPos() { if(g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK) { - if(!m_Snap.m_pLocalCharacter || (m_Snap.m_pLocalCharacter->m_Health < 0) || (m_Snap.m_pGameobj && m_Snap.m_pGameobj->m_GameOver)) + if(!m_Snap.m_pLocalCharacter || (m_Snap.m_pGameobj && m_Snap.m_pGameobj->m_GameOver)) { // don't use predicted } From 68faba809c9c0be9c63a462f91d5dac3c540a8b6 Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 18 Jan 2011 19:09:53 +0100 Subject: [PATCH 14/24] made dbg dummies work again --- src/game/server/player.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 78e7bd009..cf75615ee 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -1,6 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include +#include #include "player.h" @@ -28,6 +29,9 @@ CPlayer::~CPlayer() void CPlayer::Tick() { +#ifdef CONF_DEBUG + if(!g_Config.m_DbgDummies || m_ClientID < MAX_CLIENTS-g_Config.m_DbgDummies) +#endif if(!Server()->ClientIngame(m_ClientID)) return; @@ -75,6 +79,9 @@ void CPlayer::Tick() void CPlayer::Snap(int SnappingClient) { +#ifdef CONF_DEBUG + if(!g_Config.m_DbgDummies || m_ClientID < MAX_CLIENTS-g_Config.m_DbgDummies) +#endif if(!Server()->ClientIngame(m_ClientID)) return; From 1359db54763739d65895d9fe48c13de95570bbe5 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 19 Jan 2011 15:31:42 +0100 Subject: [PATCH 15/24] prevent that removing an entity aborts traversing the entity list in gameworld --- src/game/server/gameworld.cpp | 32 ++++++++++++++++++++++++++------ src/game/server/gameworld.h | 1 + 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/game/server/gameworld.cpp b/src/game/server/gameworld.cpp index e2d08ed66..8fc9fec87 100644 --- a/src/game/server/gameworld.cpp +++ b/src/game/server/gameworld.cpp @@ -107,6 +107,10 @@ void CGameWorld::RemoveEntity(CEntity *pEnt) if(pEnt->m_pNextTypeEntity) pEnt->m_pNextTypeEntity->m_pPrevTypeEntity = pEnt->m_pPrevTypeEntity; + // keep list traversing valid + if(m_pNextTraverseEntity == pEnt) + m_pNextTraverseEntity = pEnt->m_pNextEntity; + pEnt->m_pNextEntity = 0; pEnt->m_pPrevEntity = 0; pEnt->m_pNextTypeEntity = 0; @@ -116,15 +120,23 @@ void CGameWorld::RemoveEntity(CEntity *pEnt) // void CGameWorld::Snap(int SnappingClient) { - for(CEntity *pEnt = m_pFirstEntity; pEnt; pEnt = pEnt->m_pNextEntity) + for(CEntity *pEnt = m_pFirstEntity; pEnt; ) + { + m_pNextTraverseEntity = pEnt->m_pNextEntity; pEnt->Snap(SnappingClient); + pEnt = m_pNextTraverseEntity; + } } void CGameWorld::Reset() { // reset all entities - for(CEntity *pEnt = m_pFirstEntity; pEnt; pEnt = pEnt->m_pNextEntity) + for(CEntity *pEnt = m_pFirstEntity; pEnt; ) + { + m_pNextTraverseEntity = pEnt->m_pNextEntity; pEnt->Reset(); + pEnt = m_pNextTraverseEntity; + } RemoveEntities(); GameServer()->m_pController->PostReset(); @@ -139,13 +151,13 @@ void CGameWorld::RemoveEntities() CEntity *pEnt = m_pFirstEntity; while(pEnt) { - CEntity *pNext = pEnt->m_pNextEntity; + m_pNextTraverseEntity = pEnt->m_pNextEntity; if(pEnt->m_MarkedForDestroy) { RemoveEntity(pEnt); pEnt->Destroy(); } - pEnt = pNext; + pEnt = m_pNextTraverseEntity; } } @@ -159,11 +171,19 @@ void CGameWorld::Tick() if(GameServer()->m_pController->IsForceBalanced()) GameServer()->SendChat(-1, CGameContext::CHAT_ALL, "Teams have been balanced"); // update all objects - for(CEntity *pEnt = m_pFirstEntity; pEnt; pEnt = pEnt->m_pNextEntity) + for(CEntity *pEnt = m_pFirstEntity; pEnt; ) + { + m_pNextTraverseEntity = pEnt->m_pNextEntity; pEnt->Tick(); + pEnt = m_pNextTraverseEntity; + } - for(CEntity *pEnt = m_pFirstEntity; pEnt; pEnt = pEnt->m_pNextEntity) + for(CEntity *pEnt = m_pFirstEntity; pEnt; ) + { + m_pNextTraverseEntity = pEnt->m_pNextEntity; pEnt->TickDefered(); + pEnt = m_pNextTraverseEntity; + } } RemoveEntities(); diff --git a/src/game/server/gameworld.h b/src/game/server/gameworld.h index 86ac6a0c9..62d1e58c1 100644 --- a/src/game/server/gameworld.h +++ b/src/game/server/gameworld.h @@ -24,6 +24,7 @@ class CGameWorld }; // TODO: two lists seams kinda not good, shouldn't be needed + CEntity *m_pNextTraverseEntity; CEntity *m_pFirstEntity; CEntity *m_apFirstEntityTypes[NUM_ENT_TYPES]; From 7a20c313ee83de1619d329fd8ba0b6138a7eb4bc Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 19 Jan 2011 15:39:04 +0100 Subject: [PATCH 16/24] made some output just show up on debug --- src/engine/server/server.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 299919ddf..95cb06bd2 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -845,22 +845,24 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) } else { - char aHex[] = "0123456789ABCDEF"; - char aBuf[512]; - - for(int b = 0; b < pPacket->m_DataSize && b < 32; b++) + if(g_Config.m_Debug) { - aBuf[b*3] = aHex[((const unsigned char *)pPacket->m_pData)[b]>>4]; - aBuf[b*3+1] = aHex[((const unsigned char *)pPacket->m_pData)[b]&0xf]; - aBuf[b*3+2] = ' '; - aBuf[b*3+3] = 0; - } + char aHex[] = "0123456789ABCDEF"; + char aBuf[512]; - char aBufMsg[256]; - str_format(aBufMsg, sizeof(aBufMsg), "strange message ClientId=%d msg=%d data_size=%d", ClientId, Msg, pPacket->m_DataSize); - Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBufMsg); - Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf); - + for(int b = 0; b < pPacket->m_DataSize && b < 32; b++) + { + aBuf[b*3] = aHex[((const unsigned char *)pPacket->m_pData)[b]>>4]; + aBuf[b*3+1] = aHex[((const unsigned char *)pPacket->m_pData)[b]&0xf]; + aBuf[b*3+2] = ' '; + aBuf[b*3+3] = 0; + } + + char aBufMsg[256]; + str_format(aBufMsg, sizeof(aBufMsg), "strange message ClientId=%d msg=%d data_size=%d", ClientId, Msg, pPacket->m_DataSize); + Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBufMsg); + Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf); + } } } else From 7ca7c95bc0d29aca731838d9c404c038cbc15599 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 19 Jan 2011 15:54:50 +0100 Subject: [PATCH 17/24] limit the latency within server browser entries to a maximum of 999 --- src/engine/client/srvbrowse.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/engine/client/srvbrowse.cpp b/src/engine/client/srvbrowse.cpp index 82f4a48d4..7330850b5 100644 --- a/src/engine/client/srvbrowse.cpp +++ b/src/engine/client/srvbrowse.cpp @@ -2,6 +2,7 @@ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include // sort +#include #include #include #include @@ -440,9 +441,9 @@ void CServerBrowser::Set(const NETADDR &Addr, int Type, int Token, const CServer { SetInfo(pEntry, *pInfo); if(m_ServerlistType == IServerBrowser::TYPE_LAN) - pEntry->m_Info.m_Latency = (time_get()-m_BroadcastTime)*1000/time_freq(); + pEntry->m_Info.m_Latency = min(static_cast((time_get()-m_BroadcastTime)*1000/time_freq()), 999); else - pEntry->m_Info.m_Latency = (time_get()-pEntry->m_RequestTime)*1000/time_freq(); + pEntry->m_Info.m_Latency = min(static_cast((time_get()-pEntry->m_RequestTime)*1000/time_freq()), 999); RemoveRequest(pEntry); } } @@ -454,9 +455,9 @@ void CServerBrowser::Set(const NETADDR &Addr, int Type, int Token, const CServer SetInfo(pEntry, *pInfo); if(m_ServerlistType == IServerBrowser::TYPE_LAN) - pEntry->m_Info.m_Latency = (time_get()-m_BroadcastTime)*1000/time_freq(); + pEntry->m_Info.m_Latency = min(static_cast((time_get()-m_BroadcastTime)*1000/time_freq()), 999); else - pEntry->m_Info.m_Latency = (time_get()-pEntry->m_RequestTime)*1000/time_freq(); + pEntry->m_Info.m_Latency = min(static_cast((time_get()-pEntry->m_RequestTime)*1000/time_freq()), 999); RemoveRequest(pEntry); } } From 19a9462fe88b2573ab9f24a2890d4affb2bdcf47 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 19 Jan 2011 18:27:50 +0100 Subject: [PATCH 18/24] removed double entity list in gameworld and cleaned up connected stuff --- src/game/server/entities/character.cpp | 10 +- src/game/server/entities/flag.cpp | 2 +- src/game/server/entities/laser.cpp | 2 +- src/game/server/entities/pickup.cpp | 9 +- src/game/server/entities/projectile.cpp | 2 +- src/game/server/entity.cpp | 4 +- src/game/server/entity.h | 7 +- src/game/server/gamecontext.cpp | 4 +- src/game/server/gamecontroller.cpp | 2 +- src/game/server/gamemodes/ctf.cpp | 2 +- src/game/server/gameworld.cpp | 129 +++++++++++------------- src/game/server/gameworld.h | 26 +++-- src/game/server/player.cpp | 2 +- 13 files changed, 92 insertions(+), 109 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 0a3dd87bd..53c75e3df 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -40,7 +40,7 @@ MACRO_ALLOC_POOL_ID_IMPL(CCharacter, MAX_CLIENTS) // Character, "physical" player's part CCharacter::CCharacter(CGameWorld *pWorld) -: CEntity(pWorld, NETOBJTYPE_CHARACTER) +: CEntity(pWorld, CGameWorld::ENTTYPE_CHARACTER) { m_ProximityRadius = ms_PhysSize; m_Health = 0; @@ -153,11 +153,11 @@ void CCharacter::HandleNinja() // check if we Hit anything along the way { - CCharacter *aEnts[64]; + CCharacter *aEnts[MAX_CLIENTS]; vec2 Dir = m_Pos - OldPos; float Radius = m_ProximityRadius * 2.0f; vec2 Center = OldPos + Dir * 0.5f; - int Num = GameServer()->m_World.FindEntities(Center, Radius, (CEntity**)aEnts, 64, NETOBJTYPE_CHARACTER); + int Num = GameServer()->m_World.FindEntities(Center, Radius, (CEntity**)aEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); for (int i = 0; i < Num; ++i) { @@ -289,10 +289,10 @@ void CCharacter::FireWeapon() m_NumObjectsHit = 0; GameServer()->CreateSound(m_Pos, SOUND_HAMMER_FIRE); - CCharacter *apEnts[64]; + CCharacter *apEnts[MAX_CLIENTS]; int Hits = 0; int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius*0.5f, (CEntity**)apEnts, - 64, NETOBJTYPE_CHARACTER); + MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); for (int i = 0; i < Num; ++i) { diff --git a/src/game/server/entities/flag.cpp b/src/game/server/entities/flag.cpp index 4d034214d..13109b077 100644 --- a/src/game/server/entities/flag.cpp +++ b/src/game/server/entities/flag.cpp @@ -4,7 +4,7 @@ #include "flag.h" CFlag::CFlag(CGameWorld *pGameWorld, int Team) -: CEntity(pGameWorld, NETOBJTYPE_FLAG) +: CEntity(pGameWorld, CGameWorld::ENTTYPE_FLAG) { m_Team = Team; m_ProximityRadius = ms_PhysSize; diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp index 17eb43321..2f6568faf 100644 --- a/src/game/server/entities/laser.cpp +++ b/src/game/server/entities/laser.cpp @@ -5,7 +5,7 @@ #include "laser.h" CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner) -: CEntity(pGameWorld, NETOBJTYPE_LASER) +: CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER) { m_Pos = Pos; m_Owner = Owner; diff --git a/src/game/server/entities/pickup.cpp b/src/game/server/entities/pickup.cpp index a2c6f650f..136e3efe2 100644 --- a/src/game/server/entities/pickup.cpp +++ b/src/game/server/entities/pickup.cpp @@ -5,7 +5,7 @@ #include "pickup.h" CPickup::CPickup(CGameWorld *pGameWorld, int Type, int SubType) -: CEntity(pGameWorld, NETOBJTYPE_PICKUP) +: CEntity(pGameWorld, CGameWorld::ENTTYPE_PICKUP) { m_Type = Type; m_Subtype = SubType; @@ -91,12 +91,9 @@ void CPickup::Tick() RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime; // loop through all players, setting their emotes - CEntity *apEnts[64]; - int Num = GameServer()->m_World.FindEntities(vec2(0, 0), 1000000, apEnts, 64, NETOBJTYPE_CHARACTER); - - for (int i = 0; i < Num; ++i) + CCharacter *pC = static_cast(GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER)); + for(; pC; pC = (CCharacter *)pC->TypeNext()) { - CCharacter *pC = static_cast(apEnts[i]); if (pC != pChr) pC->SetEmote(EMOTE_SURPRISE, Server()->Tick() + Server()->TickSpeed()); } diff --git a/src/game/server/entities/projectile.cpp b/src/game/server/entities/projectile.cpp index f5c376a2f..6e256e955 100644 --- a/src/game/server/entities/projectile.cpp +++ b/src/game/server/entities/projectile.cpp @@ -6,7 +6,7 @@ CProjectile::CProjectile(CGameWorld *pGameWorld, int Type, int Owner, vec2 Pos, vec2 Dir, int Span, int Damage, bool Explosive, float Force, int SoundImpact, int Weapon) -: CEntity(pGameWorld, NETOBJTYPE_PROJECTILE) +: CEntity(pGameWorld, CGameWorld::ENTTYPE_PROJECTILE) { m_Type = Type; m_Pos = Pos; diff --git a/src/game/server/entity.cpp b/src/game/server/entity.cpp index 5241c06b1..aff36943c 100644 --- a/src/game/server/entity.cpp +++ b/src/game/server/entity.cpp @@ -11,15 +11,13 @@ CEntity::CEntity(CGameWorld *pGameWorld, int ObjType) { m_pGameWorld = pGameWorld; - m_Objtype = ObjType; + m_ObjType = ObjType; m_Pos = vec2(0,0); m_ProximityRadius = 0; m_MarkedForDestroy = false; m_Id = Server()->SnapNewID(); - m_pNextEntity = 0; - m_pPrevEntity = 0; m_pPrevTypeEntity = 0; m_pNextTypeEntity = 0; } diff --git a/src/game/server/entity.h b/src/game/server/entity.h index dc50daca7..d56c60e77 100644 --- a/src/game/server/entity.h +++ b/src/game/server/entity.h @@ -57,11 +57,8 @@ class CEntity { MACRO_ALLOC_HEAP() -private: - friend class CGameWorld; // thy these? - CEntity *m_pPrevEntity; - CEntity *m_pNextEntity; + friend class CGameWorld; // entity list handling CEntity *m_pPrevTypeEntity; CEntity *m_pNextTypeEntity; @@ -69,7 +66,7 @@ private: protected: bool m_MarkedForDestroy; int m_Id; - int m_Objtype; + int m_ObjType; public: CEntity(CGameWorld *pGameWorld, int Objtype); virtual ~CEntity(); diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 906b9801f..063e3a005 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -125,10 +125,10 @@ void CGameContext::CreateExplosion(vec2 p, int Owner, int Weapon, bool NoDamage) if (!NoDamage) { // deal damage - CCharacter *apEnts[64]; + CCharacter *apEnts[MAX_CLIENTS]; float Radius = 135.0f; float InnerRadius = 48.0f; - int Num = m_World.FindEntities(p, Radius, (CEntity**)apEnts, 64, NETOBJTYPE_CHARACTER); + int Num = m_World.FindEntities(p, Radius, (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); for(int i = 0; i < Num; i++) { vec2 Diff = apEnts[i]->m_Pos - p; diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 8ba693989..f4b6d33ce 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -42,7 +42,7 @@ IGameController::~IGameController() float IGameController::EvaluateSpawnPos(CSpawnEval *pEval, vec2 Pos) { float Score = 0.0f; - CCharacter *pC = static_cast(GameServer()->m_World.FindFirst(NETOBJTYPE_CHARACTER)); + CCharacter *pC = static_cast(GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER)); for(; pC; pC = (CCharacter *)pC->TypeNext()) { // team mates are not as dangerous as enemies diff --git a/src/game/server/gamemodes/ctf.cpp b/src/game/server/gamemodes/ctf.cpp index f6681ff69..6cefe4359 100644 --- a/src/game/server/gamemodes/ctf.cpp +++ b/src/game/server/gamemodes/ctf.cpp @@ -139,7 +139,7 @@ void CGameControllerCTF::Tick() else { CCharacter *apCloseCCharacters[MAX_CLIENTS]; - int Num = GameServer()->m_World.FindEntities(F->m_Pos, CFlag::ms_PhysSize, (CEntity**)apCloseCCharacters, MAX_CLIENTS, NETOBJTYPE_CHARACTER); + int Num = GameServer()->m_World.FindEntities(F->m_Pos, CFlag::ms_PhysSize, (CEntity**)apCloseCCharacters, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); for(int i = 0; i < Num; i++) { if(!apCloseCCharacters[i]->IsAlive() || apCloseCCharacters[i]->GetPlayer()->GetTeam() == TEAM_SPECTATORS || GameServer()->Collision()->IntersectLine(F->m_Pos, apCloseCCharacters[i]->m_Pos, NULL, NULL)) diff --git a/src/game/server/gameworld.cpp b/src/game/server/gameworld.cpp index 8fc9fec87..b4ab4594b 100644 --- a/src/game/server/gameworld.cpp +++ b/src/game/server/gameworld.cpp @@ -15,16 +15,16 @@ CGameWorld::CGameWorld() m_Paused = false; m_ResetRequested = false; - m_pFirstEntity = 0x0; - for(int i = 0; i < NUM_ENT_TYPES; i++) + for(int i = 0; i < NUM_ENTTYPES; i++) m_apFirstEntityTypes[i] = 0; } CGameWorld::~CGameWorld() { // delete all entities - while(m_pFirstEntity) - delete m_pFirstEntity; + for(int i = 0; i < NUM_ENTTYPES; i++) + while(m_apFirstEntityTypes[i]) + delete m_apFirstEntityTypes[i]; } void CGameWorld::SetGameServer(CGameContext *pGameServer) @@ -35,15 +35,16 @@ void CGameWorld::SetGameServer(CGameContext *pGameServer) CEntity *CGameWorld::FindFirst(int Type) { - return m_apFirstEntityTypes[Type]; + return Type < 0 || Type >= NUM_ENTTYPES ? 0 : m_apFirstEntityTypes[Type]; } - int CGameWorld::FindEntities(vec2 Pos, float Radius, CEntity **ppEnts, int Max, int Type) { + if(Type < 0 || Type >= NUM_ENTTYPES) + return 0; + int Num = 0; - for(CEntity *pEnt = (Type<0) ? m_pFirstEntity : m_apFirstEntityTypes[Type]; - pEnt; pEnt = (Type<0) ? pEnt->m_pNextEntity : pEnt->m_pNextTypeEntity) + for(CEntity *pEnt = m_apFirstEntityTypes[Type]; pEnt; pEnt = pEnt->m_pNextTypeEntity) { if(distance(pEnt->m_Pos, Pos) < Radius+pEnt->m_ProximityRadius) { @@ -59,26 +60,17 @@ int CGameWorld::FindEntities(vec2 Pos, float Radius, CEntity **ppEnts, int Max, void CGameWorld::InsertEntity(CEntity *pEnt) { - CEntity *pCur = m_pFirstEntity; - while(pCur) - { +#ifdef CONF_DEBUG + for(CEntity *pCur = m_apFirstEntityTypes[pEnt->m_Objtype]; pCur; pCur = pCur->m_pNextTypeEntity) dbg_assert(pCur != pEnt, "err"); - pCur = pCur->m_pNextEntity; - } +#endif // insert it - if(m_pFirstEntity) - m_pFirstEntity->m_pPrevEntity = pEnt; - pEnt->m_pNextEntity = m_pFirstEntity; - pEnt->m_pPrevEntity = 0x0; - m_pFirstEntity = pEnt; - - // into typelist aswell - if(m_apFirstEntityTypes[pEnt->m_Objtype]) - m_apFirstEntityTypes[pEnt->m_Objtype]->m_pPrevTypeEntity = pEnt; - pEnt->m_pNextTypeEntity = m_apFirstEntityTypes[pEnt->m_Objtype]; + if(m_apFirstEntityTypes[pEnt->m_ObjType]) + m_apFirstEntityTypes[pEnt->m_ObjType]->m_pPrevTypeEntity = pEnt; + pEnt->m_pNextTypeEntity = m_apFirstEntityTypes[pEnt->m_ObjType]; pEnt->m_pPrevTypeEntity = 0x0; - m_apFirstEntityTypes[pEnt->m_Objtype] = pEnt; + m_apFirstEntityTypes[pEnt->m_ObjType] = pEnt; } void CGameWorld::DestroyEntity(CEntity *pEnt) @@ -89,30 +81,21 @@ void CGameWorld::DestroyEntity(CEntity *pEnt) void CGameWorld::RemoveEntity(CEntity *pEnt) { // not in the list - if(!pEnt->m_pNextEntity && !pEnt->m_pPrevEntity && m_pFirstEntity != pEnt) + if(!pEnt->m_pNextTypeEntity && !pEnt->m_pPrevTypeEntity && m_apFirstEntityTypes[pEnt->m_ObjType] != pEnt) return; // remove - if(pEnt->m_pPrevEntity) - pEnt->m_pPrevEntity->m_pNextEntity = pEnt->m_pNextEntity; - else - m_pFirstEntity = pEnt->m_pNextEntity; - if(pEnt->m_pNextEntity) - pEnt->m_pNextEntity->m_pPrevEntity = pEnt->m_pPrevEntity; - if(pEnt->m_pPrevTypeEntity) pEnt->m_pPrevTypeEntity->m_pNextTypeEntity = pEnt->m_pNextTypeEntity; else - m_apFirstEntityTypes[pEnt->m_Objtype] = pEnt->m_pNextTypeEntity; + m_apFirstEntityTypes[pEnt->m_ObjType] = pEnt->m_pNextTypeEntity; if(pEnt->m_pNextTypeEntity) pEnt->m_pNextTypeEntity->m_pPrevTypeEntity = pEnt->m_pPrevTypeEntity; // keep list traversing valid if(m_pNextTraverseEntity == pEnt) - m_pNextTraverseEntity = pEnt->m_pNextEntity; + m_pNextTraverseEntity = pEnt->m_pNextTypeEntity; - pEnt->m_pNextEntity = 0; - pEnt->m_pPrevEntity = 0; pEnt->m_pNextTypeEntity = 0; pEnt->m_pPrevTypeEntity = 0; } @@ -120,23 +103,25 @@ void CGameWorld::RemoveEntity(CEntity *pEnt) // void CGameWorld::Snap(int SnappingClient) { - for(CEntity *pEnt = m_pFirstEntity; pEnt; ) - { - m_pNextTraverseEntity = pEnt->m_pNextEntity; - pEnt->Snap(SnappingClient); - pEnt = m_pNextTraverseEntity; - } + for(int i = 0; i < NUM_ENTTYPES; i++) + for(CEntity *pEnt = m_apFirstEntityTypes[i]; pEnt; ) + { + m_pNextTraverseEntity = pEnt->m_pNextTypeEntity; + pEnt->Snap(SnappingClient); + pEnt = m_pNextTraverseEntity; + } } void CGameWorld::Reset() { // reset all entities - for(CEntity *pEnt = m_pFirstEntity; pEnt; ) - { - m_pNextTraverseEntity = pEnt->m_pNextEntity; - pEnt->Reset(); - pEnt = m_pNextTraverseEntity; - } + for(int i = 0; i < NUM_ENTTYPES; i++) + for(CEntity *pEnt = m_apFirstEntityTypes[i]; pEnt; ) + { + m_pNextTraverseEntity = pEnt->m_pNextTypeEntity; + pEnt->Reset(); + pEnt = m_pNextTraverseEntity; + } RemoveEntities(); GameServer()->m_pController->PostReset(); @@ -148,17 +133,17 @@ void CGameWorld::Reset() void CGameWorld::RemoveEntities() { // destroy objects marked for destruction - CEntity *pEnt = m_pFirstEntity; - while(pEnt) - { - m_pNextTraverseEntity = pEnt->m_pNextEntity; - if(pEnt->m_MarkedForDestroy) + for(int i = 0; i < NUM_ENTTYPES; i++) + for(CEntity *pEnt = m_apFirstEntityTypes[i]; pEnt; ) { - RemoveEntity(pEnt); - pEnt->Destroy(); + m_pNextTraverseEntity = pEnt->m_pNextTypeEntity; + if(pEnt->m_MarkedForDestroy) + { + RemoveEntity(pEnt); + pEnt->Destroy(); + } + pEnt = m_pNextTraverseEntity; } - pEnt = m_pNextTraverseEntity; - } } void CGameWorld::Tick() @@ -171,19 +156,21 @@ void CGameWorld::Tick() if(GameServer()->m_pController->IsForceBalanced()) GameServer()->SendChat(-1, CGameContext::CHAT_ALL, "Teams have been balanced"); // update all objects - for(CEntity *pEnt = m_pFirstEntity; pEnt; ) - { - m_pNextTraverseEntity = pEnt->m_pNextEntity; - pEnt->Tick(); - pEnt = m_pNextTraverseEntity; - } + for(int i = 0; i < NUM_ENTTYPES; i++) + for(CEntity *pEnt = m_apFirstEntityTypes[i]; pEnt; ) + { + m_pNextTraverseEntity = pEnt->m_pNextTypeEntity; + pEnt->Tick(); + pEnt = m_pNextTraverseEntity; + } - for(CEntity *pEnt = m_pFirstEntity; pEnt; ) - { - m_pNextTraverseEntity = pEnt->m_pNextEntity; - pEnt->TickDefered(); - pEnt = m_pNextTraverseEntity; - } + for(int i = 0; i < NUM_ENTTYPES; i++) + for(CEntity *pEnt = m_apFirstEntityTypes[i]; pEnt; ) + { + m_pNextTraverseEntity = pEnt->m_pNextTypeEntity; + pEnt->TickDefered(); + pEnt = m_pNextTraverseEntity; + } } RemoveEntities(); @@ -198,7 +185,7 @@ CCharacter *CGameWorld::IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, v vec2 LineDir = normalize(Pos1-Pos0); CCharacter *pClosest = 0; - CCharacter *p = (CCharacter *)FindFirst(NETOBJTYPE_CHARACTER); + CCharacter *p = (CCharacter *)FindFirst(ENTTYPE_CHARACTER); for(; p; p = (CCharacter *)p->TypeNext()) { if(p == pNotThis) @@ -228,7 +215,7 @@ CCharacter *CGameWorld::ClosestCharacter(vec2 Pos, float Radius, CEntity *pNotTh float ClosestRange = Radius*2; CCharacter *pClosest = 0; - CCharacter *p = (CCharacter *)GameServer()->m_World.FindFirst(NETOBJTYPE_CHARACTER); + CCharacter *p = (CCharacter *)GameServer()->m_World.FindFirst(ENTTYPE_CHARACTER); for(; p; p = (CCharacter *)p->TypeNext()) { if(p == pNotThis) diff --git a/src/game/server/gameworld.h b/src/game/server/gameworld.h index 62d1e58c1..38002b87c 100644 --- a/src/game/server/gameworld.h +++ b/src/game/server/gameworld.h @@ -15,18 +15,23 @@ class CCharacter; */ class CGameWorld { +public: + enum + { + ENTTYPE_PROJECTILE = 0, + ENTTYPE_LASER, + ENTTYPE_PICKUP, + ENTTYPE_FLAG, + ENTTYPE_CHARACTER, + NUM_ENTTYPES + }; + +private: void Reset(); void RemoveEntities(); - enum - { - NUM_ENT_TYPES=10, // TODO: are more exact value perhaps? :) - }; - - // TODO: two lists seams kinda not good, shouldn't be needed CEntity *m_pNextTraverseEntity; - CEntity *m_pFirstEntity; - CEntity *m_apFirstEntityTypes[NUM_ENT_TYPES]; + CEntity *m_apFirstEntityTypes[NUM_ENTTYPES]; class CGameContext *m_pGameServer; class IServer *m_pServer; @@ -44,7 +49,6 @@ public: void SetGameServer(CGameContext *pGameServer); - CEntity *FindFirst() { return m_pFirstEntity; } CEntity *FindFirst(int Type); /* @@ -57,12 +61,12 @@ public: ents - Pointer to a list that should be filled with the pointers to the entities. max - Number of entities that fits into the ents array. - type - Type of the entities to find. -1 for all types. + type - Type of the entities to find. Returns: Number of entities found and added to the ents array. */ - int FindEntities(vec2 Pos, float Radius, CEntity **ppEnts, int Max, int Type = -1); + int FindEntities(vec2 Pos, float Radius, CEntity **ppEnts, int Max, int Type); /* Function: interserct_CCharacter diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index cf75615ee..3f32d6af1 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -208,7 +208,7 @@ void CPlayer::TryRespawn() // check if the position is occupado CEntity *apEnts[2] = {0}; - int NumEnts = GameServer()->m_World.FindEntities(SpawnPos, 64, apEnts, 2, NETOBJTYPE_CHARACTER); + int NumEnts = GameServer()->m_World.FindEntities(SpawnPos, 64, apEnts, 2, CGameWorld::ENTTYPE_CHARACTER); if(NumEnts == 0) { From 82749dedf0d95a41adf517e24a15c92bb656acc4 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 19 Jan 2011 19:29:10 +0100 Subject: [PATCH 19/24] fixed beginning of gametime margin graph --- src/engine/client/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 3652b2725..6b52615e8 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1462,11 +1462,11 @@ void CClient::ProcessPacket(CNetChunk *pPacket) } // adjust game time + if(m_RecivedSnapshots > 2) { int64 Now = m_GameTime.Get(time_get()); int64 TickStart = GameTick*time_freq()/50; int64 TimeLeft = (TickStart-Now)*1000 / time_freq(); - //st_update(&game_time, (game_tick-1)*time_freq()/50); m_GameTime.Update(&m_GametimeMarginGraph, (GameTick-1)*time_freq()/50, TimeLeft, 0); } From 9a9c10b1a37ea7b490f208bdd984f5f0a55fbcff Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 19 Jan 2011 22:14:40 +0100 Subject: [PATCH 20/24] added a missing close handle --- src/game/localization.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/game/localization.cpp b/src/game/localization.cpp index 47b9fddbe..ad025100a 100644 --- a/src/game/localization.cpp +++ b/src/game/localization.cpp @@ -91,6 +91,7 @@ bool CLocalizationDatabase::Load(const char *pFilename, IStorage *pStorage, ICon pReplacement += 3; AddString(pLine, pReplacement); } + io_close(IoHandle); m_CurrentVersion = ++m_VersionCounter; return true; From 17012416369663cdd5bdeead537faede3b8b308d Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 19 Jan 2011 22:41:44 +0100 Subject: [PATCH 21/24] added hammerhit simplification by fisted. Closes #443 --- src/game/server/entities/character.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 53c75e3df..f3bfe793c 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -298,13 +298,11 @@ void CCharacter::FireWeapon() { CCharacter *pTarget = apEnts[i]; - //for race mod or any other mod, which needs hammer hits through the wall remove second condition if ((pTarget == this) || GameServer()->Collision()->IntersectLine(ProjStartPos, pTarget->m_Pos, NULL, NULL)) continue; // set his velocity to fast upward (for now) GameServer()->CreateHammerHit(m_Pos); - pTarget->TakeDamage(vec2(0.f, -1.f), g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage, m_pPlayer->GetCID(), m_ActiveWeapon); vec2 Dir; if (length(pTarget->m_Pos - m_Pos) > 0.0f) @@ -312,7 +310,8 @@ void CCharacter::FireWeapon() else Dir = vec2(0.f, -1.f); - pTarget->m_Core.m_Vel += normalize(Dir + vec2(0.f, -1.1f)) * 10.0f; + pTarget->TakeDamage(vec2(0.f, -1.f) + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f, g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage, + m_pPlayer->GetCID(), m_ActiveWeapon); Hits++; } From 372b62566b15bbcf79e3320d6daf751e04b7e501 Mon Sep 17 00:00:00 2001 From: fisted Date: Tue, 18 Jan 2011 06:50:24 +0100 Subject: [PATCH 22/24] fixed tower bug --- scripts/cmd5.py | 2 +- src/game/gamecore.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/cmd5.py b/scripts/cmd5.py index 6ab65160e..3a8848bb5 100644 --- a/scripts/cmd5.py +++ b/scripts/cmd5.py @@ -31,6 +31,6 @@ for filename in sys.argv[1:]: hash = hashlib.md5(f).hexdigest().lower()[16:] # TODO: refactor hash that is equal to the 0.5 hash, remove when we # TODO: remove when we don't need it any more -if hash == "026b8eceb4cdd369": +if hash == "f16c2456fc487748": hash = "b67d1f1a1eea234e" print('#define GAME_NETVERSION_HASH "%s"' % hash) diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp index c3c295372..629b32e88 100644 --- a/src/game/gamecore.cpp +++ b/src/game/gamecore.cpp @@ -320,13 +320,15 @@ void CCharacterCore::Tick(bool UseInput) if(d < PhysSize*1.25f && d > 1.0f) { float a = (PhysSize*1.45f - d); - + float v = 0.5f; + // make sure that we don't add excess force by checking the - // direction against the current velocity - vec2 VelDir = normalize(m_Vel); - float v = 1-(dot(VelDir, Dir)+1)/2; - m_Vel = m_Vel + Dir*a*(v*0.75f); - m_Vel = m_Vel * 0.85f; + // direction against the current velocity. if not zero. + if (length(m_Vel) > 0.0001) + v = 1-(dot(normalize(m_Vel), Dir)+1)/2; + + m_Vel += Dir*a*(v*0.75f); + m_Vel *= 0.85f; } // handle hook influence From 3c1eee2a121c54f16090e5392918d39bf7105e9d Mon Sep 17 00:00:00 2001 From: oy Date: Thu, 20 Jan 2011 01:28:17 +0100 Subject: [PATCH 23/24] reverted Python 3 support fixes to keep compatibility with 2.5 --- datasrc/compile.py | 4 ++-- scripts/cmd5.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/datasrc/compile.py b/datasrc/compile.py index bab139317..0cca54981 100644 --- a/datasrc/compile.py +++ b/datasrc/compile.py @@ -69,8 +69,8 @@ if gen_client_content_header or gen_server_content_header: order = [] for line in contentlines: line = line.strip() - if line[:6] == b"class " and b'(Struct)' in line: - order += [line.split()[1].split(b"(")[0].decode('ascii')] + if line[:6] == "class " and '(Struct)' in line: + order += [line.split()[1].split("(")[0]] for name in order: EmitTypeDeclaration(content.__dict__[name]) diff --git a/scripts/cmd5.py b/scripts/cmd5.py index 3a8848bb5..11a18137d 100644 --- a/scripts/cmd5.py +++ b/scripts/cmd5.py @@ -3,15 +3,15 @@ import hashlib, sys, re alphanum = "0123456789abcdefghijklmnopqrstuvwzyxABCDEFGHIJKLMNOPQRSTUVWXYZ_" def cstrip(lines): - d = b"" + d = "" for l in lines: - l = re.sub(b"#.*", b"", l) - l = re.sub(b"//.*", b"", l) - d += l + b" " - d = re.sub(b"\/\*.*?\*/", b"", d) # remove /* */ comments - d = d.replace(b"\t", b" ") # tab to space - d = re.sub(b" *", b" ", d) # remove double spaces - d = re.sub(b"", b"", d) # remove /* */ comments + l = re.sub("#.*", "", l) + l = re.sub("//.*", "", l) + d += l + " " + d = re.sub("\/\*.*?\*/", "", d) # remove /* */ comments + d = d.replace("\t", " ") # tab to space + d = re.sub(" *", " ", d) # remove double spaces + d = re.sub("", "", d) # remove /* */ comments d = d.strip() @@ -24,11 +24,11 @@ def cstrip(lines): i += 1 return d -f = b"" +f = "" for filename in sys.argv[1:]: f += cstrip([l.strip() for l in open(filename, "rb")]) -hash = hashlib.md5(f).hexdigest().lower()[16:] +hash = hashlib.md5(f.encode()).hexdigest().lower()[16:] # TODO: refactor hash that is equal to the 0.5 hash, remove when we # TODO: remove when we don't need it any more if hash == "f16c2456fc487748": From 7c67a1334c1cac4c8144aec86dfe516fc073e790 Mon Sep 17 00:00:00 2001 From: oy Date: Thu, 20 Jan 2011 01:35:21 +0100 Subject: [PATCH 24/24] fixed a typo --- src/game/server/gameworld.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/server/gameworld.cpp b/src/game/server/gameworld.cpp index b4ab4594b..66da43699 100644 --- a/src/game/server/gameworld.cpp +++ b/src/game/server/gameworld.cpp @@ -61,7 +61,7 @@ int CGameWorld::FindEntities(vec2 Pos, float Radius, CEntity **ppEnts, int Max, void CGameWorld::InsertEntity(CEntity *pEnt) { #ifdef CONF_DEBUG - for(CEntity *pCur = m_apFirstEntityTypes[pEnt->m_Objtype]; pCur; pCur = pCur->m_pNextTypeEntity) + for(CEntity *pCur = m_apFirstEntityTypes[pEnt->m_ObjType]; pCur; pCur = pCur->m_pNextTypeEntity) dbg_assert(pCur != pEnt, "err"); #endif