diff --git a/data/file_icons.png b/data/file_icons.png new file mode 100644 index 000000000..92c32601f Binary files /dev/null and b/data/file_icons.png differ diff --git a/datasrc/content.py b/datasrc/content.py index fef4815d3..88876387f 100644 --- a/datasrc/content.py +++ b/datasrc/content.py @@ -227,6 +227,7 @@ image_browseicons = Image("browseicons", "browse_icons.png") image_emoticons = Image("emoticons", "emoticons.png") image_speedup_arrow = Image("speedup_arrow", "editor/speed_arrow.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) @@ -239,6 +240,7 @@ container.images.Add(Image("console_bg", "console.png")) container.images.Add(Image("console_bar", "console_bar.png")) container.images.Add(image_speedup_arrow) container.images.Add(image_demobuttons) +container.images.Add(image_fileicons) container.pickups.Add(Pickup("health")) container.pickups.Add(Pickup("armor")) @@ -252,6 +254,7 @@ set_browseicons = SpriteSet("browseicons", image_browseicons, 4, 1) set_emoticons = SpriteSet("emoticons", image_emoticons, 4, 4) set_speedup_arrow = SpriteSet("speedup_arrow", image_speedup_arrow, 1, 1) 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) @@ -260,6 +263,7 @@ container.spritesets.Add(set_browseicons) container.spritesets.Add(set_emoticons) container.spritesets.Add(set_speedup_arrow) 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)) @@ -378,6 +382,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/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/srvbrowse.cpp b/src/engine/client/srvbrowse.cpp index 7f4c3ca34..ecc07201f 100644 --- a/src/engine/client/srvbrowse.cpp +++ b/src/engine/client/srvbrowse.cpp @@ -624,7 +624,6 @@ void CServerBrowser::Update() { // timeout RemoveRequest(pEntry); - m_NumRequests--; } pEntry = pNext; @@ -717,6 +716,10 @@ void CServerBrowser::RemoveFavorite(const NETADDR &Addr) } } +bool CServerBrowser::IsRefreshing() const +{ + return m_pFirstReqServer != 0; +} bool CServerBrowser::IsRefreshingMasters() const { @@ -724,6 +727,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..20e8bd46a 100644 --- a/src/engine/client/srvbrowse.h +++ b/src/engine/client/srvbrowse.h @@ -29,7 +29,9 @@ public: // interface functions void Refresh(int Type); + bool IsRefreshing() const; bool IsRefreshingMasters() const; + int LoadingProgression() const; int NumServers() const { return m_NumServers; } 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/serverbrowser.h b/src/engine/serverbrowser.h index 43732f131..d140df25c 100644 --- a/src/engine/serverbrowser.h +++ b/src/engine/serverbrowser.h @@ -78,7 +78,9 @@ public: }; virtual void Refresh(int Type) = 0; + virtual bool IsRefreshing() const = 0; virtual bool IsRefreshingMasters() const = 0; + virtual int LoadingProgression() const = 0; virtual int NumServers() const = 0; 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/engine/shared/network_conn.cpp b/src/engine/shared/network_conn.cpp index f47191276..8cc10b4e7 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); } diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 476d9bc5c..ff81bed30 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, 4, -1); 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, int ClientID) { - ((CGameConsole *)pUserData)->Toggle(0); + ((CGameConsole *)pUserData)->Toggle(CONSOLETYPE_LOCAL); } void CGameConsole::ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUserData, int ClientID) { - ((CGameConsole *)pUserData)->Toggle(1); + ((CGameConsole *)pUserData)->Toggle(CONSOLETYPE_REMOTE); } void CGameConsole::ConClearLocalConsole(IConsole::IResult *pResult, void *pUserData, int ClientID) @@ -644,12 +644,12 @@ void CGameConsole::ConClearRemoteConsole(IConsole::IResult *pResult, void *pUser void CGameConsole::ConDumpLocalConsole(IConsole::IResult *pResult, void *pUserData, int ClientID) { - ((CGameConsole *)pUserData)->Dump(0); + ((CGameConsole *)pUserData)->Dump(CONSOLETYPE_LOCAL); } void CGameConsole::ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData, int ClientID) { - ((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 10cf4c25a..f3c7ba307 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, int ClientID); public: + enum + { + CONSOLETYPE_LOCAL=0, + CONSOLETYPE_REMOTE, + }; + CGameConsole(); void PrintLine(int Type, const char *pLine); diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 78dadc16e..99f0dd273 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 56fc6cd6d..3a5213155 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 2954fbbe8..cd5137db4 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) { @@ -392,10 +392,13 @@ 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); + 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); } 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/client/gameclient.cpp b/src/game/client/gameclient.cpp index e2c7ef405..fd9019f2f 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -192,7 +192,7 @@ void CGameClient::OnConsoleInit() Console()->Register("tune", "si", CFGFLAG_SERVER, ConServerDummy, 0, "Tune variable to value", 0); Console()->Register("tune_reset", "", CFGFLAG_SERVER, ConServerDummy, 0, "Reset tuning", 0); Console()->Register("tune_dump", "", CFGFLAG_SERVER, ConServerDummy, 0, "Dump tuning", 0); - Console()->Register("change_map", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Change map", 0); + Console()->Register("change_map", "?r", CFGFLAG_SERVER, ConServerDummy, 0, "Change map", 0); Console()->Register("restart", "?i", CFGFLAG_SERVER, ConServerDummy, 0, "Restart in x seconds", 0); Console()->Register("broadcast", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Broadcast message", 0); Console()->Register("say", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Say in chat", 0); @@ -623,7 +623,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() 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 4be75e80d..ea0cdb9ac 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 @@ -1910,22 +1911,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; @@ -1938,7 +1923,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) @@ -2203,8 +2188,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; @@ -2212,7 +2197,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; @@ -2225,9 +2210,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)) { diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h index 23a9ed977..aba858647 100644 --- a/src/game/editor/ed_editor.h +++ b/src/game/editor/ed_editor.h @@ -762,6 +762,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); + } unsigned char m_TeleNum; diff --git a/src/game/editor/ed_io.cpp b/src/game/editor/ed_io.cpp index 35be9a627..571430608 100644 --- a/src/game/editor/ed_io.cpp +++ b/src/game/editor/ed_io.cpp @@ -1,5 +1,7 @@ +#include #include #include +#include #include #include #include "ed_editor.h" @@ -401,11 +403,15 @@ 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()) + if(m_pEditor->Client()->RconAuthed()) { - Client()->Rcon("sv_map_reload 1"); - }*/ + 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; } diff --git a/src/game/server/ddracecommands.cpp b/src/game/server/ddracecommands.cpp index 173760b74..f52ee8c59 100644 --- a/src/game/server/ddracecommands.cpp +++ b/src/game/server/ddracecommands.cpp @@ -47,7 +47,7 @@ void CGameContext::ConTuneDump(IConsole::IResult *pResult, void *pUserData, int void CGameContext::ConChangeMap(IConsole::IResult *pResult, void *pUserData, int ClientId) { 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, int ClientId) diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index e6ce79a03..e5bc2c371 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -1125,7 +1125,7 @@ void CGameContext::OnConsoleInit() m_pServer = Kernel()->RequestInterface(); m_pConsole = Kernel()->RequestInterface(); - Console()->Register("change_map", "r", CFGFLAG_SERVER, ConChangeMap, this, "Changes the map to r", 3); + Console()->Register("change_map", "?r", CFGFLAG_SERVER, ConChangeMap, this, "Changes the map to r", 3); Console()->Register("restart", "?i", CFGFLAG_SERVER, ConRestart, this, "Kills all players", 3); Console()->Register("broadcast", "r", CFGFLAG_SERVER, ConBroadcast, this, "Changes the broadcast message for a moment", 3); Console()->Register("say", "r", CFGFLAG_SERVER, ConSay, this, "Sends a server message to all players", 3);