From 57a92359972b789c8de5794619e62f339fa10707 Mon Sep 17 00:00:00 2001 From: Choupom Date: Sat, 30 Oct 2010 14:06:28 +0200 Subject: [PATCH 01/11] reload the map on save if you are authed --- src/game/editor/ed_io.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/game/editor/ed_io.cpp b/src/game/editor/ed_io.cpp index 6684a4a94..c0df17c47 100644 --- a/src/game/editor/ed_io.cpp +++ b/src/game/editor/ed_io.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -359,11 +360,8 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving done"); // send rcon.. if we can - /* - if(Client()->RconAuthed()) - { - Client()->Rcon("sv_map_reload 1"); - }*/ + if(m_pEditor->Client()->RconAuthed()) + m_pEditor->Client()->Rcon("reload"); return 1; } From a7f37446b62630d751ea7edd5b4a396385887869 Mon Sep 17 00:00:00 2001 From: Choupom Date: Sat, 30 Oct 2010 18:56:57 +0200 Subject: [PATCH 02/11] added loading progression in server browser --- src/engine/client/srvbrowse.cpp | 12 +++++++++++- src/engine/client/srvbrowse.h | 1 + src/engine/serverbrowser.h | 1 + src/game/client/components/menus_browser.cpp | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/engine/client/srvbrowse.cpp b/src/engine/client/srvbrowse.cpp index aed0d5146..5835bb3be 100644 --- a/src/engine/client/srvbrowse.cpp +++ b/src/engine/client/srvbrowse.cpp @@ -615,7 +615,6 @@ void CServerBrowser::Update() { // timeout RemoveRequest(pEntry); - m_NumRequests--; } pEntry = pNext; @@ -715,6 +714,17 @@ bool CServerBrowser::IsRefreshingMasters() const } +int CServerBrowser::LoadingProgression() const +{ + if(m_NumServers == 0) + return 0; + + int Servers = m_NumServers; + int Loaded = m_NumServers-m_NumRequests; + return 100.0f * Loaded/Servers; +} + + void CServerBrowser::ConfigSaveCallback(IConfig *pConfig, void *pUserData) { CServerBrowser *pSelf = (CServerBrowser *)pUserData; diff --git a/src/engine/client/srvbrowse.h b/src/engine/client/srvbrowse.h index ecaed7efb..ebcdbb309 100644 --- a/src/engine/client/srvbrowse.h +++ b/src/engine/client/srvbrowse.h @@ -30,6 +30,7 @@ public: // interface functions void Refresh(int Type); bool IsRefreshingMasters() const; + int LoadingProgression() const; int NumServers() const { return m_NumServers; } diff --git a/src/engine/serverbrowser.h b/src/engine/serverbrowser.h index 43732f131..4409e9bc0 100644 --- a/src/engine/serverbrowser.h +++ b/src/engine/serverbrowser.h @@ -79,6 +79,7 @@ public: virtual void Refresh(int Type) = 0; virtual bool IsRefreshingMasters() const = 0; + virtual int LoadingProgression() const = 0; virtual int NumServers() const = 0; diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 409c81f69..ff3d7b3a6 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -392,10 +392,10 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) UI()->SetActiveItem(&g_Config.m_BrFilterString); } } - + // render status char aBuf[128]; - str_format(aBuf, sizeof(aBuf), Localize("%d of %d servers, %d players"), ServerBrowser()->NumSortedServers(), ServerBrowser()->NumServers(), NumPlayers); + str_format(aBuf, sizeof(aBuf), Localize("%d of %d servers, %d players (%d%% loaded)"), ServerBrowser()->NumSortedServers(), ServerBrowser()->NumServers(), NumPlayers, ServerBrowser()->LoadingProgression()); Status.VSplitRight(TextRender()->TextWidth(0, 14.0f, aBuf, -1), 0, &Status); UI()->DoLabel(&Status, aBuf, 14.0f, -1); } From f1ce0d1949a7197a292f5376e3109162cc639390 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 17 Nov 2010 12:43:24 +0100 Subject: [PATCH 03/11] improved loading progression in the server browser --- src/engine/client/srvbrowse.cpp | 4 ++++ src/engine/client/srvbrowse.h | 1 + src/engine/serverbrowser.h | 1 + src/game/client/components/menus_browser.cpp | 5 ++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/engine/client/srvbrowse.cpp b/src/engine/client/srvbrowse.cpp index 5835bb3be..cb91477dd 100644 --- a/src/engine/client/srvbrowse.cpp +++ b/src/engine/client/srvbrowse.cpp @@ -707,6 +707,10 @@ void CServerBrowser::RemoveFavorite(const NETADDR &Addr) } } +bool CServerBrowser::IsRefreshing() const +{ + return m_pFirstReqServer != 0; +} bool CServerBrowser::IsRefreshingMasters() const { diff --git a/src/engine/client/srvbrowse.h b/src/engine/client/srvbrowse.h index ebcdbb309..20e8bd46a 100644 --- a/src/engine/client/srvbrowse.h +++ b/src/engine/client/srvbrowse.h @@ -29,6 +29,7 @@ public: // interface functions void Refresh(int Type); + bool IsRefreshing() const; bool IsRefreshingMasters() const; int LoadingProgression() const; diff --git a/src/engine/serverbrowser.h b/src/engine/serverbrowser.h index 4409e9bc0..d140df25c 100644 --- a/src/engine/serverbrowser.h +++ b/src/engine/serverbrowser.h @@ -78,6 +78,7 @@ public: }; virtual void Refresh(int Type) = 0; + virtual bool IsRefreshing() const = 0; virtual bool IsRefreshingMasters() const = 0; virtual int LoadingProgression() const = 0; diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index ff3d7b3a6..507e99d6e 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -395,7 +395,10 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) // render status char aBuf[128]; - str_format(aBuf, sizeof(aBuf), Localize("%d of %d servers, %d players (%d%% loaded)"), ServerBrowser()->NumSortedServers(), ServerBrowser()->NumServers(), NumPlayers, ServerBrowser()->LoadingProgression()); + if(ServerBrowser()->IsRefreshing()) + str_format(aBuf, sizeof(aBuf), Localize("%d%% loaded"), ServerBrowser()->LoadingProgression()); + else + str_format(aBuf, sizeof(aBuf), Localize("%d of %d servers, %d players"), ServerBrowser()->NumSortedServers(), ServerBrowser()->NumServers(), NumPlayers); Status.VSplitRight(TextRender()->TextWidth(0, 14.0f, aBuf, -1), 0, &Status); UI()->DoLabel(&Status, aBuf, 14.0f, -1); } From 994a44f6e1b821517d36f0cf20beaaf07cfca4e4 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 17 Nov 2010 12:50:01 +0100 Subject: [PATCH 04/11] simplified change_map command so that it switches to the next map in the maprotation when called without param --- src/game/client/gameclient.cpp | 2 +- src/game/server/gamecontext.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index f782f5345..cffbf7ae1 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -187,7 +187,7 @@ void CGameClient::OnConsoleInit() Console()->Register("tune", "si", CFGFLAG_SERVER, 0, 0, "Tune variable to value"); Console()->Register("tune_reset", "", CFGFLAG_SERVER, 0, 0, "Reset tuning"); Console()->Register("tune_dump", "", CFGFLAG_SERVER, 0, 0, "Dump tuning"); - Console()->Register("change_map", "r", CFGFLAG_SERVER, 0, 0, "Change map"); + Console()->Register("change_map", "?r", CFGFLAG_SERVER, 0, 0, "Change map"); Console()->Register("restart", "?i", CFGFLAG_SERVER, 0, 0, "Restart in x seconds"); Console()->Register("broadcast", "r", CFGFLAG_SERVER, 0, 0, "Broadcast message"); Console()->Register("say", "r", CFGFLAG_SERVER, 0, 0, "Say in chat"); diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 4d19dd531..c09beb208 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -861,7 +861,7 @@ void CGameContext::ConTuneDump(IConsole::IResult *pResult, void *pUserData) void CGameContext::ConChangeMap(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; - pSelf->m_pController->ChangeMap(pResult->GetString(0)); + pSelf->m_pController->ChangeMap(pResult->NumArguments() ? pResult->GetString(0) : ""); } void CGameContext::ConRestart(IConsole::IResult *pResult, void *pUserData) @@ -970,7 +970,7 @@ void CGameContext::OnConsoleInit() Console()->Register("tune_reset", "", CFGFLAG_SERVER, ConTuneReset, this, ""); Console()->Register("tune_dump", "", CFGFLAG_SERVER, ConTuneDump, this, ""); - Console()->Register("change_map", "r", CFGFLAG_SERVER|CFGFLAG_STORE, ConChangeMap, this, ""); + Console()->Register("change_map", "?r", CFGFLAG_SERVER|CFGFLAG_STORE, ConChangeMap, this, ""); Console()->Register("restart", "?i", CFGFLAG_SERVER|CFGFLAG_STORE, ConRestart, this, ""); Console()->Register("broadcast", "r", CFGFLAG_SERVER, ConBroadcast, this, ""); Console()->Register("say", "r", CFGFLAG_SERVER, ConSay, this, ""); From 8351682edf630d2d1ec706f0cf6406d026c7a8a4 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 17 Nov 2010 13:01:46 +0100 Subject: [PATCH 05/11] added constants for console types by Choupom --- src/game/client/components/console.cpp | 40 +++++++++++++------------- src/game/client/components/console.h | 6 ++++ src/game/client/gameclient.cpp | 2 +- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 3df13cadf..420b78843 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -41,7 +41,7 @@ CGameConsole::CInstance::CInstance(int Type) m_Type = Type; - if(Type == 0) + if(Type == CGameConsole::CONSOLETYPE_LOCAL) m_CompletionFlagmask = CFGFLAG_CLIENT; else m_CompletionFlagmask = CFGFLAG_SERVER; @@ -72,7 +72,7 @@ void CGameConsole::CInstance::ClearHistory() void CGameConsole::CInstance::ExecuteLine(const char *pLine) { - if(m_Type == 0) + if(m_Type == CGameConsole::CONSOLETYPE_LOCAL) m_pGameConsole->m_pConsole->ExecuteLine(pLine); else { @@ -101,7 +101,7 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event) { if(m_Input.GetString()[0]) { - if(m_Type != 1 || m_pGameConsole->Client()->RconAuthed()) + if(m_Type == CONSOLETYPE_LOCAL || m_pGameConsole->Client()->RconAuthed()) { char *pEntry = m_History.Allocate(m_Input.GetLength()+1); mem_copy(pEntry, m_Input.GetString(), m_Input.GetLength()+1); @@ -150,7 +150,7 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event) } else if(Event.m_Key == KEY_TAB) { - if(m_Type == 0 || m_pGameConsole->Client()->RconAuthed()) + if(m_Type == CGameConsole::CONSOLETYPE_LOCAL || m_pGameConsole->Client()->RconAuthed()) { m_CompletionChosen++; m_CompletionEnumerationCount = 0; @@ -216,9 +216,9 @@ void CGameConsole::CInstance::PrintLine(const char *pLine) } CGameConsole::CGameConsole() -: m_LocalConsole(0), m_RemoteConsole(1) +: m_LocalConsole(CONSOLETYPE_LOCAL), m_RemoteConsole(CONSOLETYPE_REMOTE) { - m_ConsoleType = 0; + m_ConsoleType = CONSOLETYPE_LOCAL; m_ConsoleState = CONSOLE_CLOSED; m_StateChangeEnd = 0.0f; m_StateChangeDuration = 0.1f; @@ -232,7 +232,7 @@ float CGameConsole::TimeNow() CGameConsole::CInstance *CGameConsole::CurrentConsole() { - if(m_ConsoleType != 0) + if(m_ConsoleType == CONSOLETYPE_REMOTE) return &m_RemoteConsole; return &m_LocalConsole; } @@ -324,7 +324,7 @@ void CGameConsole::OnRender() } if (m_ConsoleState == CONSOLE_OPEN && g_Config.m_ClEditor) - Toggle(0); + Toggle(CONSOLETYPE_LOCAL); if (m_ConsoleState == CONSOLE_CLOSED) return; @@ -362,7 +362,7 @@ void CGameConsole::OnRender() Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CONSOLE_BG].m_Id); Graphics()->QuadsBegin(); Graphics()->SetColor(0.2f, 0.2f, 0.2f,0.9f); - if(m_ConsoleType != 0) + if(m_ConsoleType == CONSOLETYPE_REMOTE) Graphics()->SetColor(0.4f, 0.2f, 0.2f,0.9f); Graphics()->QuadsSetSubset(0,-ConsoleHeight*0.075f,Screen.w*0.075f*0.5f,0); QuadItem = IGraphics::CQuadItem(0, 0, Screen.w, ConsoleHeight); @@ -414,7 +414,7 @@ void CGameConsole::OnRender() TextRender()->SetCursor(&Info.m_Cursor, x+Info.m_Offset, y+12.0f, FontSize, TEXTFLAG_RENDER); const char *pPrompt = "> "; - if(m_ConsoleType) + if(m_ConsoleType == CONSOLETYPE_REMOTE) { if(Client()->State() == IClient::STATE_ONLINE) { @@ -445,7 +445,7 @@ void CGameConsole::OnRender() //hide rcon password char aInputString[256]; str_copy(aInputString, pConsole->m_Input.GetString(), sizeof(aInputString)); - if(m_ConsoleType && Client()->State() == IClient::STATE_ONLINE && !Client()->RconAuthed()) + if(m_ConsoleType == CONSOLETYPE_REMOTE && Client()->State() == IClient::STATE_ONLINE && !Client()->RconAuthed()) { for(int i = 0; i < pConsole->m_Input.GetLength(); ++i) aInputString[i] = '*'; @@ -457,7 +457,7 @@ void CGameConsole::OnRender() TextRender()->TextEx(&Cursor, aInputString+pConsole->m_Input.GetCursorOffset(), -1); // render possible commands - if(m_ConsoleType == 0 || Client()->RconAuthed()) + if(m_ConsoleType == CONSOLETYPE_LOCAL || Client()->RconAuthed()) { if(pConsole->m_Input.GetString()[0] != 0) { @@ -589,7 +589,7 @@ void CGameConsole::Toggle(int Type) void CGameConsole::Dump(int Type) { - CInstance *pConsole = Type == 1 ? &m_RemoteConsole : &m_LocalConsole; + CInstance *pConsole = Type == CONSOLETYPE_REMOTE ? &m_RemoteConsole : &m_LocalConsole; char aFilename[128]; time_t Time; char aDate[20]; @@ -601,7 +601,7 @@ void CGameConsole::Dump(int Type) for(int i = 0; i < 10; i++) { IOHANDLE io; - str_format(aFilename, sizeof(aFilename), "dumps/%s_dump%s-%05d.txt", Type==1?"remote_console":"local_console", aDate, i); + str_format(aFilename, sizeof(aFilename), "dumps/%s_dump%s-%05d.txt", Type==CONSOLETYPE_REMOTE?"remote_console":"local_console", aDate, i); io = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE); if(io) { @@ -624,12 +624,12 @@ void CGameConsole::Dump(int Type) void CGameConsole::ConToggleLocalConsole(IConsole::IResult *pResult, void *pUserData) { - ((CGameConsole *)pUserData)->Toggle(0); + ((CGameConsole *)pUserData)->Toggle(CONSOLETYPE_LOCAL); } void CGameConsole::ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUserData) { - ((CGameConsole *)pUserData)->Toggle(1); + ((CGameConsole *)pUserData)->Toggle(CONSOLETYPE_REMOTE); } void CGameConsole::ConClearLocalConsole(IConsole::IResult *pResult, void *pUserData) @@ -644,12 +644,12 @@ void CGameConsole::ConClearRemoteConsole(IConsole::IResult *pResult, void *pUser void CGameConsole::ConDumpLocalConsole(IConsole::IResult *pResult, void *pUserData) { - ((CGameConsole *)pUserData)->Dump(0); + ((CGameConsole *)pUserData)->Dump(CONSOLETYPE_LOCAL); } void CGameConsole::ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData) { - ((CGameConsole *)pUserData)->Dump(1); + ((CGameConsole *)pUserData)->Dump(CONSOLETYPE_REMOTE); } void CGameConsole::ClientConsolePrintCallback(const char *pStr, void *pUserData) @@ -659,9 +659,9 @@ void CGameConsole::ClientConsolePrintCallback(const char *pStr, void *pUserData) void CGameConsole::PrintLine(int Type, const char *pLine) { - if(Type == 0) + if(Type == CONSOLETYPE_LOCAL) m_LocalConsole.PrintLine(pLine); - else if(Type == 1) + else if(Type == CONSOLETYPE_REMOTE) m_RemoteConsole.PrintLine(pLine); } diff --git a/src/game/client/components/console.h b/src/game/client/components/console.h index c126f6d85..40ee082fa 100644 --- a/src/game/client/components/console.h +++ b/src/game/client/components/console.h @@ -74,6 +74,12 @@ class CGameConsole : public CComponent static void ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData); public: + enum + { + CONSOLETYPE_LOCAL=0, + CONSOLETYPE_REMOTE, + }; + CGameConsole(); void PrintLine(int Type, const char *pLine); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index cffbf7ae1..26de650e6 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -586,7 +586,7 @@ void CGameClient::OnEnterGame() {} void CGameClient::OnRconLine(const char *pLine) { - m_pGameConsole->PrintLine(1, pLine); + m_pGameConsole->PrintLine(CGameConsole::CONSOLETYPE_REMOTE, pLine); } void CGameClient::ProcessEvents() From ca80d2a347689b5482f5c89a17a34131f79ed7cc Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 17 Nov 2010 13:08:29 +0100 Subject: [PATCH 06/11] reload the map on save just when the map name is equal --- src/game/editor/ed_editor.cpp | 18 +----------------- src/game/editor/ed_editor.h | 15 +++++++++++++++ src/game/editor/ed_io.cpp | 10 +++++++++- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 97e9452f2..9fb457aae 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -1850,22 +1850,6 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) } } -static void ExtractName(const char *pFileName, char *pName, int BufferSize) -{ - const char *pExtractedName = pFileName; - const char *pEnd = 0; - for(; *pFileName; ++pFileName) - { - if(*pFileName == '/' || *pFileName == '\\') - pExtractedName = pFileName+1; - else if(*pFileName == '.') - pEnd = pFileName; - } - - int Length = pEnd > pExtractedName ? min(BufferSize, (int)(pEnd-pExtractedName+1)) : BufferSize; - str_copy(pName, pExtractedName, Length); -} - void CEditor::ReplaceImage(const char *pFileName, int StorageType, void *pUser) { CEditor *pEditor = (CEditor *)pUser; @@ -1878,7 +1862,7 @@ void CEditor::ReplaceImage(const char *pFileName, int StorageType, void *pUser) pEditor->Graphics()->UnloadTexture(pImg->m_TexId); *pImg = ImgInfo; pImg->m_External = External; - ExtractName(pFileName, pImg->m_aName, sizeof(pImg->m_aName)); + pEditor->ExtractName(pFileName, pImg->m_aName, sizeof(pImg->m_aName)); pImg->m_TexId = pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0); pEditor->SortImages(); for(int i = 0; i < pEditor->m_Map.m_lImages.size(); ++i) diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h index fb4cd50e7..6ff9e6c8e 100644 --- a/src/game/editor/ed_editor.h +++ b/src/game/editor/ed_editor.h @@ -680,6 +680,21 @@ public: void AddFileDialogEntry(int Index, CUIRect *pView); void SortImages(); + static void ExtractName(const char *pFileName, char *pName, int BufferSize) + { + const char *pExtractedName = pFileName; + const char *pEnd = 0; + for(; *pFileName; ++pFileName) + { + if(*pFileName == '/' || *pFileName == '\\') + pExtractedName = pFileName+1; + else if(*pFileName == '.') + pEnd = pFileName; + } + + int Length = pEnd > pExtractedName ? min(BufferSize, (int)(pEnd-pExtractedName+1)) : BufferSize; + str_copy(pName, pExtractedName, Length); + } }; // make sure to inline this function diff --git a/src/game/editor/ed_io.cpp b/src/game/editor/ed_io.cpp index c0df17c47..30fe4c0bd 100644 --- a/src/game/editor/ed_io.cpp +++ b/src/game/editor/ed_io.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include "ed_editor.h" @@ -361,7 +362,14 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) // send rcon.. if we can if(m_pEditor->Client()->RconAuthed()) - m_pEditor->Client()->Rcon("reload"); + { + CServerInfo CurrentServerInfo; + m_pEditor->Client()->GetServerInfo(&CurrentServerInfo); + char aMapName[128]; + m_pEditor->ExtractName(pFileName, aMapName, sizeof(aMapName)); + if(!str_comp(aMapName, CurrentServerInfo.m_aMap)) + m_pEditor->Client()->Rcon("reload"); + } return 1; } From d32b93d3ec538c89539d39c61cac4b56e00db8be Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 17 Nov 2010 18:28:28 +0100 Subject: [PATCH 07/11] added file icons by Landil --- data/file_icons.png | Bin 0 -> 2246 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 data/file_icons.png diff --git a/data/file_icons.png b/data/file_icons.png new file mode 100644 index 0000000000000000000000000000000000000000..92c32601fda1df9ade68886630724f9d5285f03c GIT binary patch literal 2246 zcmV;%2s!tOP)%`t9E*Ns(Y%Zd%9q|P_RsFhN)zVe{>bb}6QB#&JV*Tw$DpQY z$oo?tS*0BgM^2b5fPy}&4ARa5a5!>gh#_z7jMFxFmP&t0a$&3rtQ>N0Iq*-7N~t%MQcLymrp~KXF6y{ODYZPJuFJJdoHCt$ z`=doE^_WtsH=+(n>D4+~>e!B^YJVd;0dD~=3b}VHFg2!JHU6P`MC4y!3(NAtp8vz? zH*z;{Zi2Goa1Ssso5!87hwH}G5~(nXB)Wnb# zUqFv;Dqq58(;s|MTZ~fm)1Q<=AiWe=J!Ksq0XymI-+=Fd9f@v#uwH3ljP?aP@jVd* z6cBU!P+%Hx3b3>9{t#qv*b6w!pwO>lzmR(#Hs0n{Eo8#VTA6%TAg2AI<)MG`Ksrtb zj?%x-cfA?n6<-E?>&xF(pSyv@`g#LkU47k!%(p$(!8`@Ety3+W0Xz!4g0$lZWRQ6q zyU_PYef}(^w3&dHaAbs+a*9uGv{I_5l$xlN`pMvJoDxyaNT1v{Au@C0x;G=3>nnGd z5>NJz2Ax^c?E35VygzTY&YK+~d#x|8-IqT)AYV{Q?X8r0BgOhxW2P>5W2Mx(`g#wg z)DKnk*E?O7Z|m$>0Wt0U^dp|jZ4l>4kMG_L{Y)H2>SH6|nm~EA(xc021?C`MhHHUg zDU|J~FGb*0ef=txjyVN9=u1D3Odb7uS92V%~F2ub5J?8T!mgw@{2hJpXk&C18 zXhk|qpFZy#xZepZLVOPgAbzJu0x~0jnZRi}{YibQYGfAjK6{*wOlNHIK8Q)v6DUpX z7X_7=q5vj#w2=7{@o=^S^Yk;d{K1dbho42rKoiB9RK}=>V?W|HG9T9XT(HyBQ@=?j ziT;BS%kn{FAU_)!$UWxha~ooXcIrI;x{preL*#u4PfbvtI7|TUL#*I7;A!A|U|*{H zB0O64`GW-MV}Yv?|J_u?M>5^7#C8Dqwz>#KE3V27noXG)T<+Nqs#Waqn892+Z z^#ODvqgjwGk&(EAQs+m@b{phv_?7a;#4+Iqg1PSyRsr_W*ZWYuJlE^wV}KjhVHzE@0HR{+laVj|CdhpIMqmn+JD0xG zvSEbj=+x&Ik$+Ine0%`74LcvelqxdK%Gd_f-(ew>L{|}U-u3BoF`#2CV$ymY|8Pnl zor1oMLK1o-$_S3gd9OrkHvM@&pA;MYUm%-zb~nfe=|fEY zpODV?GvXLMB&PnPzqbMA&JVK6*Za^GpmGXuCedrM=OZiqrXeA}E`2H@-x?{b8NohEB@g+o<%( zzI+871Du6e#eS+<03fFJ1BfY}=5D~lkk0R~RFnm9kgh|mRzR=T=`AK{MWzU+Al6GW ze1RHSf8Nh0rJDXe;5wx9zlgl2yC7k<50DV&4#20t=SV1WnwB|%>i)HA7C;!ryGUa5T8L7Um#OdVzBGan`UqS35ZkjYs85UaH2lX3&{Te ztJ%&6;BYiQMa0233K?J~0c#=qasEY?BpX-e4gns|rjAB}`?nnqM|^gt^dTJ&9Ebc8 zPyu*>h-LYOd<_7H!;uneA}0S?$Q}fb6DciZs=y5Z4#&V_1hVMvIAmc`=>LZFAKHMs UEYWP5#Q*>R07*qoM6N<$f=Yrzod5s; literal 0 HcmV?d00001 From 3d3572f845c1d61acd960caf0c28562b9c8681e5 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 17 Nov 2010 18:36:19 +0100 Subject: [PATCH 08/11] fixed some compiler warnings --- src/base/system.c | 10 ++++++---- src/engine/client/text.cpp | 4 ++-- src/engine/shared/demo.h | 1 + src/game/client/lineinput.h | 2 +- src/game/editor/ed_editor.cpp | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/base/system.c b/src/base/system.c index 972fbada9..b7f76a881 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -987,10 +987,12 @@ int fs_is_dir(const char *path) int fs_chdir(const char *path) { - if (fs_is_dir(path)) + if(fs_is_dir(path)) { - chdir(path); - return 0; + if(chdir(path)) + return 1; + else + return 0; } else return 1; @@ -1306,7 +1308,7 @@ void gui_messagebox(const char *title, const char *message) title, message); - system(cmd); + (void)system(cmd); #elif defined(CONF_FAMILY_WINDOWS) MessageBox(NULL, message, diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index ddc9429fa..e4707a69e 100644 --- a/src/engine/client/text.cpp +++ b/src/engine/client/text.cpp @@ -540,8 +540,8 @@ public: int ActualSize; int i; int GotNewLine = 0; - float DrawX, DrawY; - int LineCount; + float DrawX = 0.0f, DrawY = 0.0f; + int LineCount = 0; float CursorX, CursorY; const char *pEnd; diff --git a/src/engine/shared/demo.h b/src/engine/shared/demo.h index 12b12f053..37e868313 100644 --- a/src/engine/shared/demo.h +++ b/src/engine/shared/demo.h @@ -43,6 +43,7 @@ public: class IListner { public: + virtual ~IListner() {} virtual void OnDemoPlayerSnapshot(void *pData, int Size) = 0; virtual void OnDemoPlayerMessage(void *pData, int Size) = 0; }; diff --git a/src/game/client/lineinput.h b/src/game/client/lineinput.h index f5c652823..71612b990 100644 --- a/src/game/client/lineinput.h +++ b/src/game/client/lineinput.h @@ -25,7 +25,7 @@ public: void Set(const char *pString); const char *GetString() const { return m_Str; } int GetLength() const { return m_Len; } - unsigned GetCursorOffset() const { return m_CursorPos; } + int GetCursorOffset() const { return m_CursorPos; } }; #endif diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 9fb457aae..867049e14 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -2127,8 +2127,8 @@ static void EditorListdirCallback(const char *pName, int IsDir, int StorageType, int Length = str_length(pName); if((pName[0] == '.' && (pName[1] == 0 || (pName[1] == '.' && pName[2] == 0 && (!str_comp(pEditor->m_pFileDialogPath, "maps") || !str_comp(pEditor->m_pFileDialogPath, "mapres"))))) || - (!IsDir && (pEditor->m_FileDialogFileType == CEditor::FILETYPE_MAP && (Length < 4 || str_comp(pName+Length-4, ".map"))) || - (pEditor->m_FileDialogFileType == CEditor::FILETYPE_IMG && (Length < 4 || str_comp(pName+Length-4, ".png"))))) + (!IsDir && ((pEditor->m_FileDialogFileType == CEditor::FILETYPE_MAP && (Length < 4 || str_comp(pName+Length-4, ".map"))) || + (pEditor->m_FileDialogFileType == CEditor::FILETYPE_IMG && (Length < 4 || str_comp(pName+Length-4, ".png")))))) return; CEditor::CFilelistItem Item; From c45dc374ff585732b51e5a72b8fdf7ce2293c991 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 17 Nov 2010 19:05:19 +0100 Subject: [PATCH 09/11] decreased the default value for maximum players with same IP a bit --- src/engine/shared/config_variables.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 54895b7c0..91d6add26 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -65,7 +65,7 @@ MACRO_CONFIG_INT(SvPort, sv_port, 8303, 0, 0, CFGFLAG_SERVER, "Port to use for t MACRO_CONFIG_INT(SvExternalPort, sv_external_port, 0, 0, 0, CFGFLAG_SERVER, "External port to report to the master servers") MACRO_CONFIG_STR(SvMap, sv_map, 128, "dm1", CFGFLAG_SERVER, "Map to use on the server") MACRO_CONFIG_INT(SvMaxClients, sv_max_clients, 8, 1, MAX_CLIENTS, CFGFLAG_SERVER, "Maximum number of clients that are allowed on a server") -MACRO_CONFIG_INT(SvMaxClientsPerIP, sv_max_clients_per_ip, 8, 1, MAX_CLIENTS, CFGFLAG_SERVER, "Maximum number of clients with the same IP that can connect to the server") +MACRO_CONFIG_INT(SvMaxClientsPerIP, sv_max_clients_per_ip, 4, 1, MAX_CLIENTS, CFGFLAG_SERVER, "Maximum number of clients with the same IP that can connect to the server") MACRO_CONFIG_INT(SvHighBandwidth, sv_high_bandwidth, 0, 0, 1, CFGFLAG_SERVER, "Use high bandwidth mode. Doubles the bandwidth required for the server. LAN use only") MACRO_CONFIG_INT(SvRegister, sv_register, 1, 0, 1, CFGFLAG_SERVER, "Register server with master server for public listing") MACRO_CONFIG_STR(SvRconPassword, sv_rcon_password, 32, "", CFGFLAG_SERVER, "Remote console password") From 4383e1093398816a925794c1778974e29a35983c Mon Sep 17 00:00:00 2001 From: Choupom Date: Mon, 1 Nov 2010 11:42:43 +0100 Subject: [PATCH 10/11] clients are now dropped if they don't act as normal clients (fixes #235) --- src/engine/shared/network_conn.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/engine/shared/network_conn.cpp b/src/engine/shared/network_conn.cpp index b97575000..aaab73694 100644 --- a/src/engine/shared/network_conn.cpp +++ b/src/engine/shared/network_conn.cpp @@ -194,7 +194,6 @@ void CNetConnection::Disconnect(const char *pReason) int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr) { int64 Now = time_get(); - m_LastRecvTime = Now; // check if resend is requested if(pPacket->m_Flags&NET_PACKETFLAG_RESEND) @@ -256,27 +255,20 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr) // connection made if(CtrlMsg == NET_CTRLMSG_CONNECTACCEPT) { + m_LastRecvTime = Now; SendControl(NET_CTRLMSG_ACCEPT, 0, 0); m_State = NET_CONNSTATE_ONLINE; if(g_Config.m_Debug) dbg_msg("connection", "got connect+accept, sending accept. connection online"); } } - else if(State() == NET_CONNSTATE_ONLINE) - { - // connection made - /* - if(ctrlmsg == NET_CTRLMSG_CONNECTACCEPT) - { - - }*/ - } } } else { if(State() == NET_CONNSTATE_PENDING) { + m_LastRecvTime = Now; m_State = NET_CONNSTATE_ONLINE; if(g_Config.m_Debug) dbg_msg("connection", "connecting online"); @@ -285,6 +277,7 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr) if(State() == NET_CONNSTATE_ONLINE) { + m_LastRecvTime = Now; AckChunks(pPacket->m_Ack); } From d94355729da4677f7bc7dcc59adcce33dfc7e2b4 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 17 Nov 2010 19:46:50 +0100 Subject: [PATCH 11/11] added icons in the demo browser and the editor's file dialog. Closes #209 --- datasrc/content.py | 10 ++++++++++ src/game/client/components/menus.cpp | 6 +++--- src/game/client/components/menus.h | 2 +- src/game/client/components/menus_browser.cpp | 6 +++--- src/game/client/components/menus_demo.cpp | 9 +++++++-- src/game/editor/ed_editor.cpp | 14 ++++++++++++-- 6 files changed, 36 insertions(+), 11 deletions(-) diff --git a/datasrc/content.py b/datasrc/content.py index 92e71b96e..a0917a9fb 100644 --- a/datasrc/content.py +++ b/datasrc/content.py @@ -226,6 +226,7 @@ image_game = Image("game", "game.png") image_browseicons = Image("browseicons", "browse_icons.png") image_emoticons = Image("emoticons", "emoticons.png") image_demobuttons = Image("demobuttons", "demo_buttons.png") +image_fileicons = Image("fileicons", "file_icons.png") container.images.Add(image_null) container.images.Add(image_game) @@ -237,6 +238,7 @@ container.images.Add(image_browseicons) container.images.Add(Image("console_bg", "console.png")) container.images.Add(Image("console_bar", "console_bar.png")) container.images.Add(image_demobuttons) +container.images.Add(image_fileicons) container.pickups.Add(Pickup("health")) container.pickups.Add(Pickup("armor")) @@ -249,6 +251,7 @@ set_tee = SpriteSet("tee", image_null, 8, 4) set_browseicons = SpriteSet("browseicons", image_browseicons, 4, 1) set_emoticons = SpriteSet("emoticons", image_emoticons, 4, 4) set_demobuttons = SpriteSet("demobuttons", image_demobuttons, 5, 1) +set_fileicons = SpriteSet("fileicons", image_fileicons, 8, 1) container.spritesets.Add(set_particles) container.spritesets.Add(set_game) @@ -256,6 +259,7 @@ container.spritesets.Add(set_tee) container.spritesets.Add(set_browseicons) container.spritesets.Add(set_emoticons) container.spritesets.Add(set_demobuttons) +container.spritesets.Add(set_fileicons) container.sprites.Add(Sprite("part_slice", set_particles, 0,0,1,1)) container.sprites.Add(Sprite("part_ball", set_particles, 1,0,1,1)) @@ -372,6 +376,12 @@ container.sprites.Add(Sprite("demobutton_stop", set_demobuttons, 2,0,1,1)) container.sprites.Add(Sprite("demobutton_slower", set_demobuttons, 3,0,1,1)) container.sprites.Add(Sprite("demobutton_faster", set_demobuttons, 4,0,1,1)) +container.sprites.Add(Sprite("file_demo1", set_fileicons, 0,0,1,1)) +container.sprites.Add(Sprite("file_demo2", set_fileicons, 1,0,1,1)) +container.sprites.Add(Sprite("file_folder", set_fileicons, 2,0,1,1)) +container.sprites.Add(Sprite("file_map1", set_fileicons, 5,0,1,1)) +container.sprites.Add(Sprite("file_map2", set_fileicons, 6,0,1,1)) + anim = Animation("base") anim.body.frames.Add(AnimKeyframe(0, 0, -4, 0)) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 8e7d9eb51..67010c91c 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -112,12 +112,12 @@ vec4 CMenus::ButtonColorMul(const void *pID) return vec4(1,1,1,1); } -int CMenus::DoButton_BrowseIcon(int What, const CUIRect *pRect) +int CMenus::DoButton_Icon(int ImageId, int SpriteId, const CUIRect *pRect) { - Graphics()->TextureSet(g_pData->m_aImages[IMAGE_BROWSEICONS].m_Id); + Graphics()->TextureSet(g_pData->m_aImages[ImageId].m_Id); Graphics()->QuadsBegin(); - RenderTools()->SelectSprite(What); + RenderTools()->SelectSprite(SpriteId); IGraphics::CQuadItem QuadItem(pRect->x, pRect->y, pRect->w, pRect->h); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 7b661360d..9b7647b1f 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -47,7 +47,7 @@ class CMenus : public CComponent static void ui_draw_settings_tab_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); */ - int DoButton_BrowseIcon(int Checked, const CUIRect *pRect); + int DoButton_Icon(int ImageId, int SpriteId, const CUIRect *pRect); int DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect); //static void ui_draw_browse_icon(int what, const CUIRect *r); diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 507e99d6e..32f16daf0 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -273,7 +273,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) if(Id == COL_FLAG_LOCK) { if(pItem->m_Flags & SERVER_FLAG_PASSWORD) - DoButton_BrowseIcon(SPRITE_BROWSE_LOCK, &Button); + DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_LOCK, &Button); } else if(Id == COL_FLAG_PURE) { @@ -286,13 +286,13 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) else { // unpure - DoButton_BrowseIcon(SPRITE_BROWSE_UNPURE, &Button); + DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_UNPURE, &Button); } } else if(Id == COL_FLAG_FAV) { if(pItem->m_Favorite) - DoButton_BrowseIcon(SPRITE_BROWSE_HEART, &Button); + DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_HEART, &Button); } else if(Id == COL_NAME) { diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 2b0cb946a..25ab02401 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -442,7 +442,7 @@ void CMenus::DemolistFetchCallback(const char *pName, int IsDir, int StorageType } else { - str_format(Item.m_aName, min(static_cast(sizeof(Item.m_aName)), Length), " %s", pName); + str_copy(Item.m_aName, pName, min(static_cast(sizeof(Item.m_aName)), Length)); char aBuffer[512]; str_format(aBuffer, sizeof(aBuffer), "%s/%s", pSelf->m_aCurrentDemoFolder, Item.m_aFilename); // TODO: many items slow this down, don't load the info from every file when making the filelist @@ -509,7 +509,7 @@ void CMenus::RenderDemoList(CUIRect MainView) RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f); MainView.Margin(10.0f, &MainView); - CUIRect ButtonBar, RefreshRect, PlayRect, DeleteRect; + CUIRect ButtonBar, RefreshRect, PlayRect, DeleteRect, FileIcon; MainView.HSplitBottom(ms_ButtonHeight+5.0f, &MainView, &ButtonBar); ButtonBar.HSplitTop(5.0f, 0, &ButtonBar); ButtonBar.VSplitRight(130.0f, &ButtonBar, &PlayRect); @@ -524,7 +524,12 @@ void CMenus::RenderDemoList(CUIRect MainView) { CListboxItem Item = UiDoListboxNextItem((void*)(&r.front())); if(Item.m_Visible) + { + Item.m_Rect.VSplitLeft(Item.m_Rect.h, &FileIcon, &Item.m_Rect); + Item.m_Rect.VSplitLeft(5.0f, 0, &Item.m_Rect); + DoButton_Icon(IMAGE_FILEICONS, r.front().m_IsDir?SPRITE_FILE_FOLDER:SPRITE_FILE_DEMO1, &FileIcon); UI()->DoLabel(&Item.m_Rect, r.front().m_aName, Item.m_Rect.h*ms_FontmodHeight, -1); + } } bool Activated = false; m_DemolistSelectedIndex = UiDoListboxEnd(&s_ScrollValue, &Activated); diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 867049e14..8beb6339f 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "ed_editor.h" #include @@ -2136,7 +2137,7 @@ static void EditorListdirCallback(const char *pName, int IsDir, int StorageType, if(IsDir) str_format(Item.m_aName, sizeof(Item.m_aName), "%s/", pName); else - str_format(Item.m_aName, min(static_cast(sizeof(Item.m_aName)), Length+1), " %s", pName); + str_copy(Item.m_aName, pName, min(static_cast(sizeof(Item.m_aName)), Length+1)); Item.m_IsDir = IsDir != 0; Item.m_IsLink = false; Item.m_StorageType = StorageType; @@ -2149,9 +2150,18 @@ void CEditor::AddFileDialogEntry(int Index, CUIRect *pView) if(m_FilesCur-1 < m_FilesStartAt || m_FilesCur >= m_FilesStopAt) return; - CUIRect Button; + CUIRect Button, FileIcon; pView->HSplitTop(15.0f, &Button, pView); pView->HSplitTop(2.0f, 0, pView); + Button.VSplitLeft(Button.h, &FileIcon, &Button); + Button.VSplitLeft(5.0f, 0, &Button); + + Graphics()->TextureSet(g_pData->m_aImages[IMAGE_FILEICONS].m_Id); + Graphics()->QuadsBegin(); + RenderTools()->SelectSprite(m_FileList[Index].m_IsDir?SPRITE_FILE_FOLDER:SPRITE_FILE_MAP2); + IGraphics::CQuadItem QuadItem(FileIcon.x, FileIcon.y, FileIcon.w, FileIcon.h); + Graphics()->QuadsDrawTL(&QuadItem, 1); + Graphics()->QuadsEnd(); if(DoButton_File((void*)(10+(int)Button.y), m_FileList[Index].m_aName, m_FilesSelectedIndex == Index, &Button, 0, 0)) {