From e291a60e7e5c52e8a6d0117fd2ef3b38521cb81c Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 15 Feb 2012 01:40:40 +0100 Subject: fixed map initialisation. Closes #64 --- src/game/client/render.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/client/render.cpp b/src/game/client/render.cpp index 278ed51a..71589191 100644 --- a/src/game/client/render.cpp +++ b/src/game/client/render.cpp @@ -314,7 +314,7 @@ void CRenderTools::RenderTilemapGenerateSkip(class CLayers *pLayers) CTile *pTiles = (CTile *)pLayers->Map()->GetData(pTmap->m_Data); for(int y = 0; y < pTmap->m_Height; y++) { - for(int x = 1; x < pTmap->m_Width; x++) + for(int x = 1; x < pTmap->m_Width;) { int sx; for(sx = 1; x+sx < pTmap->m_Width && sx < 255; sx++) @@ -324,6 +324,7 @@ void CRenderTools::RenderTilemapGenerateSkip(class CLayers *pLayers) } pTiles[y*pTmap->m_Width+x].m_Skip = sx-1; + x += sx; } } } -- cgit 1.4.1 From ffa93a007ced9553cc35ce8372bd8ab59039e6f9 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Feb 2013 17:24:12 +0100 Subject: fixed a bug with spectating a player --- src/game/server/player.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/game') diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 75c2c1c6..4b37385f 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -259,6 +259,7 @@ void CPlayer::SetTeam(int Team, bool DoChatMsg) m_Team = Team; m_LastActionTick = Server()->Tick(); + m_SpectatorID = SPEC_FREEVIEW; // we got to wait 0.5 secs before respawning m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2; str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' m_Team=%d", m_ClientID, Server()->ClientName(m_ClientID), m_Team); -- cgit 1.4.1 From 2f86ad3c4baab2709f224f0ff7cf9ca46d4b1f52 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 4 Mar 2012 12:46:38 +0100 Subject: fixed chat ignore feature --- src/game/client/components/menus_ingame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index a9cf35e9..084520d9 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -183,7 +183,7 @@ void CMenus::RenderPlayers(CUIRect MainView) ButtonBar.VSplitLeft(Width, &Button, &ButtonBar); Button.VSplitLeft((Width-Button.h)/4.0f, 0, &Button); Button.VSplitLeft(Button.h, &Button, 0); - if(&g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[Index].m_Friend) + if(g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[Index].m_Friend) DoButton_Toggle(&s_aPlayerIDs[Index][0], 1, &Button, false); else if(DoButton_Toggle(&s_aPlayerIDs[Index][0], m_pClient->m_aClients[Index].m_ChatIgnore, &Button, true)) -- cgit 1.4.1 From 5de2763f827d04eef2b50ddf8a228db8591ec310 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 01:04:12 +0200 Subject: skip auto screenshot when the editor is active. #931 --- src/game/client/gameclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 86fb5ad0..4b90d9b1 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -571,7 +571,7 @@ void CGameClient::OnEnterGame() {} void CGameClient::OnGameOver() { - if(Client()->State() != IClient::STATE_DEMOPLAYBACK) + if(Client()->State() != IClient::STATE_DEMOPLAYBACK && g_Config.m_ClEditor == 0) Client()->AutoScreenshot_Start(); } -- cgit 1.4.1 From 76d7569e15b2b99faa54371007196afaba5e3dbb Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 01:09:49 +0200 Subject: limit the number of chat messages a player can queue to 3 --- src/game/client/components/chat.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/game') diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 340b9da1..78b90e93 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -112,13 +112,25 @@ bool CChat::OnInput(IInput::CEvent Event) { if(m_Input.GetString()[0]) { + bool AddEntry = false; + if(m_LastChatSend+time_freq() < time_get()) + { Say(m_Mode == MODE_ALL ? 0 : 1, m_Input.GetString()); - else + AddEntry = true; + } + else if(m_PendingChatCounter < 3) + { ++m_PendingChatCounter; - CHistoryEntry *pEntry = m_History.Allocate(sizeof(CHistoryEntry)+m_Input.GetLength()); - pEntry->m_Team = m_Mode == MODE_ALL ? 0 : 1; - mem_copy(pEntry->m_aText, m_Input.GetString(), m_Input.GetLength()+1); + AddEntry = true; + } + + if(AddEntry) + { + CHistoryEntry *pEntry = m_History.Allocate(sizeof(CHistoryEntry)+m_Input.GetLength()); + pEntry->m_Team = m_Mode == MODE_ALL ? 0 : 1; + mem_copy(pEntry->m_aText, m_Input.GetString(), m_Input.GetLength()+1); + } } m_pHistoryEntry = 0x0; m_Mode = MODE_NONE; -- cgit 1.4.1 From 32c8dd6cf5c8bdcbd08c4f4cf1bd97c17d0167d9 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 01:11:32 +0200 Subject: increased time for client info resend to prevent possible overlap --- src/game/client/gameclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 4b90d9b1..f9b8b671 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -449,7 +449,7 @@ void CGameClient::OnRender() m_NewPredictedTick = false; // check if client info has to be resent - if(m_LastSendInfo && Client()->State() == IClient::STATE_ONLINE && m_Snap.m_LocalClientID >= 0 && !m_pMenus->IsActive() && m_LastSendInfo+time_freq()*5 < time_get()) + if(m_LastSendInfo && Client()->State() == IClient::STATE_ONLINE && m_Snap.m_LocalClientID >= 0 && !m_pMenus->IsActive() && m_LastSendInfo+time_freq()*6 < time_get()) { // resend if client info differs if(str_comp(g_Config.m_PlayerName, m_aClients[m_Snap.m_LocalClientID].m_aName) || -- cgit 1.4.1 From 0036a07ce7bb34c86f25e7b1c4a28a621c8911fe Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 01:13:51 +0200 Subject: fixed that client displays active vote after connecting to a server --- src/game/client/components/voting.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index 675d6770..13dbc8a2 100644 --- a/src/game/client/components/voting.cpp +++ b/src/game/client/components/voting.cpp @@ -120,7 +120,12 @@ void CVoting::Vote(int v) CVoting::CVoting() { ClearOptions(); - OnReset(); + + m_Closetime = 0; + m_aDescription[0] = 0; + m_aReason[0] = 0; + m_Yes = m_No = m_Pass = m_Total = 0; + m_Voted = 0; } void CVoting::AddOption(const char *pDescription) @@ -164,6 +169,9 @@ void CVoting::ClearOptions() void CVoting::OnReset() { + if(Client()->State() == IClient::STATE_LOADING) // do not reset active vote while connecting + return; + m_Closetime = 0; m_aDescription[0] = 0; m_aReason[0] = 0; -- cgit 1.4.1 From 4d36c0f77e03475b4057f2de3383105283653230 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 01:50:16 +0200 Subject: prevent that you can play the music ingame. Closes #947 --- src/game/client/components/menus_settings.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/game') diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 553195b1..13993783 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -781,10 +781,13 @@ void CMenus::RenderSettingsSound(CUIRect MainView) if(DoButton_CheckBox(&g_Config.m_SndMusic, Localize("Play background music"), g_Config.m_SndMusic, &Button)) { g_Config.m_SndMusic ^= 1; - if(g_Config.m_SndMusic) - m_pClient->m_pSounds->Play(CSounds::CHN_MUSIC, SOUND_MENU, 1.0f); - else - m_pClient->m_pSounds->Stop(SOUND_MENU); + if(Client()->State() == IClient::STATE_OFFLINE) + { + if(g_Config.m_SndMusic) + m_pClient->m_pSounds->Play(CSounds::CHN_MUSIC, SOUND_MENU, 1.0f); + else + m_pClient->m_pSounds->Stop(SOUND_MENU); + } } MainView.HSplitTop(20.0f, &Button, &MainView); -- cgit 1.4.1 From 0bce750a33576a48b11defb12f73a671c3de5c10 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 21:50:25 +0200 Subject: count spectators in the server browser when 'count players only'-filter is disabled --- src/game/client/components/menus_browser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index a9c434b3..b560b8cd 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -225,7 +225,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) { int ItemIndex = i; const CServerInfo *pItem = ServerBrowser()->SortedGet(ItemIndex); - NumPlayers += pItem->m_NumPlayers; + NumPlayers += g_Config.m_BrFilterSpectators ? pItem->m_NumPlayers : pItem->m_NumClients; CUIRect Row; CUIRect SelectHitBox; -- cgit 1.4.1 From 86708818e9012a59cb00f6d836000a5c72850195 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 22:11:41 +0200 Subject: fixed wrong map download speed when switching to the editor while downloading. Closes #951 --- src/game/client/components/menus.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index d27307f4..8d0bdb16 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1045,7 +1045,7 @@ int CMenus::Render() } // update download speed - float Diff = Client()->MapDownloadAmount()-m_DownloadLastCheckSize; + float Diff = (Client()->MapDownloadAmount()-m_DownloadLastCheckSize)/((int)((Now-m_DownloadLastCheckTime)/time_freq())); float StartDiff = m_DownloadLastCheckSize-0.0f; if(StartDiff+Diff > 0.0f) m_DownloadSpeed = (Diff/(StartDiff+Diff))*(Diff/1.0f) + (StartDiff/(Diff+StartDiff))*m_DownloadSpeed; -- cgit 1.4.1 From 86cd0cefd7cdefd7443cb9602b3c834fa85134e1 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 21 Apr 2012 00:23:48 +0200 Subject: fixed wrapping problems when rendering console input --- src/engine/client/text.cpp | 2 +- src/game/client/components/console.cpp | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src/game') diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index af06fc11..d838ef29 100644 --- a/src/engine/client/text.cpp +++ b/src/engine/client/text.cpp @@ -639,7 +639,7 @@ public: Compare.m_Y = DrawY; Compare.m_Flags &= ~TEXTFLAG_RENDER; Compare.m_LineWidth = -1; - TextEx(&Compare, pText, Wlen); + TextEx(&Compare, pCurrent, Wlen); if(Compare.m_X-DrawX > pCursor->m_LineWidth) { diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index d16d56cd..01bf5351 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -434,12 +434,6 @@ void CGameConsole::OnRender() x = Cursor.m_X; - // render console input (wrap line) - int Lines = TextRender()->TextLineCount(0, FontSize, pConsole->m_Input.GetString(), Screen.w - 10.0f - x); - y -= (Lines - 1) * FontSize; - TextRender()->SetCursor(&Cursor, x, y, FontSize, TEXTFLAG_RENDER); - Cursor.m_LineWidth = Screen.w - 10.0f - x; - //hide rcon password char aInputString[256]; str_copy(aInputString, pConsole->m_Input.GetString(), sizeof(aInputString)); @@ -449,10 +443,22 @@ void CGameConsole::OnRender() aInputString[i] = '*'; } + // render console input (wrap line) + TextRender()->SetCursor(&Cursor, x, y, FontSize, 0); + Cursor.m_LineWidth = Screen.w - 10.0f - x; + TextRender()->TextEx(&Cursor, aInputString, pConsole->m_Input.GetCursorOffset()); + TextRender()->TextEx(&Cursor, aInputString+pConsole->m_Input.GetCursorOffset(), -1); + int Lines = Cursor.m_LineCount; + + y -= (Lines - 1) * FontSize; + TextRender()->SetCursor(&Cursor, x, y, FontSize, TEXTFLAG_RENDER); + Cursor.m_LineWidth = Screen.w - 10.0f - x; + TextRender()->TextEx(&Cursor, aInputString, pConsole->m_Input.GetCursorOffset()); static float MarkerOffset = TextRender()->TextWidth(0, FontSize, "|", -1)/3; CTextCursor Marker = Cursor; Marker.m_X -= MarkerOffset; + Marker.m_LineWidth = -1; TextRender()->TextEx(&Marker, "|", -1); TextRender()->TextEx(&Cursor, aInputString+pConsole->m_Input.GetCursorOffset(), -1); -- cgit 1.4.1 From 4e4019986a763326952719f26798f3184325ce40 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 10 Jun 2012 13:07:31 +0200 Subject: made the client not play the chat sound for empty chat messages. Closes #967 --- src/game/client/components/chat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/game') diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 78b90e93..f3370f94 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -277,9 +277,9 @@ void CChat::OnMessage(int MsgType, void *pRawMsg) void CChat::AddLine(int ClientID, int Team, const char *pLine) { - if(ClientID != -1 && (m_pClient->m_aClients[ClientID].m_aName[0] == '\0' || // unknown client + if(*pLine == 0 || (ClientID != -1 && (m_pClient->m_aClients[ClientID].m_aName[0] == '\0' || // unknown client m_pClient->m_aClients[ClientID].m_ChatIgnore || - (m_pClient->m_Snap.m_LocalClientID != ClientID && g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[ClientID].m_Friend))) + (m_pClient->m_Snap.m_LocalClientID != ClientID && g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[ClientID].m_Friend)))) return; bool Highlighted = false; -- cgit 1.4.1 From 7b545f3ed941d45c3a42016b9de667a08f8d4dc6 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Wed, 27 Jun 2012 11:46:11 +0200 Subject: Added borderless window functionality This might become handy for users with multiple monitors, might resolve other issues aswell --- src/engine/client/backend_sdl.cpp | 7 +++++++ src/engine/client/graphics.cpp | 10 +++++++++- src/engine/client/graphics_threaded.cpp | 9 ++++++++- src/engine/client/graphics_threaded.h | 1 + src/engine/shared/config_variables.h | 1 + src/game/client/components/menus_settings.cpp | 13 +++++++++++++ 6 files changed, 39 insertions(+), 2 deletions(-) (limited to 'src/game') diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index b04b729e..18f1cee6 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -427,6 +427,13 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height if(pInfo->blit_hw) // ignore_convention SdlFlags |= SDL_HWACCEL; + dbg_assert(!(Flags&IGraphicsBackend::INITFLAG_BORDERLESS) + || !(Flags&IGraphicsBackend::INITFLAG_FULLSCREEN), + "only one of borderless and fullscreen may be activated at the same time"); + + if(Flags&IGraphicsBackend::INITFLAG_BORDERLESS) + SdlFlags |= SDL_NOFRAME; + if(Flags&IGraphicsBackend::INITFLAG_FULLSCREEN) SdlFlags |= SDL_FULLSCREEN; diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index 8816e1ed..314669e2 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -801,7 +801,15 @@ int CGraphics_SDL::TryInit() if(pInfo->blit_hw) // ignore_convention Flags |= SDL_HWACCEL; - if(g_Config.m_GfxFullscreen) + if(g_Config.m_GfxBorderless && g_Config.m_GfxFullscreen) + { + dbg_msg("gfx", "both borderless and fullscreen activated, disabling borderless"); + g_Config.m_GfxBorderless = 0; + } + + if(g_Config.m_GfxBorderless) + Flags |= SDL_NOFRAME; + else if(g_Config.m_GfxFullscreen) Flags |= SDL_FULLSCREEN; // set gl attributes diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 0c99ebf7..f67753fb 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -712,7 +712,14 @@ void CGraphics_Threaded::QuadsText(float x, float y, float Size, float r, float int CGraphics_Threaded::IssueInit() { int Flags = 0; - if(g_Config.m_GfxFullscreen) Flags |= IGraphicsBackend::INITFLAG_FULLSCREEN; + if(g_Config.m_GfxBorderless && g_Config.m_GfxFullscreen) + { + dbg_msg("gfx", "both borderless and fullscreen activated, disabling borderless"); + g_Config.m_GfxBorderless = 0; + } + + if(g_Config.m_GfxBorderless) Flags |= IGraphicsBackend::INITFLAG_BORDERLESS; + else if(g_Config.m_GfxFullscreen) Flags |= IGraphicsBackend::INITFLAG_FULLSCREEN; if(g_Config.m_GfxVsync) Flags |= IGraphicsBackend::INITFLAG_VSYNC; if(g_Config.m_DbgResizable) Flags |= IGraphicsBackend::INITFLAG_RESIZABLE; diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index d3ccc61e..253059ec 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -300,6 +300,7 @@ public: INITFLAG_FULLSCREEN = 1, INITFLAG_VSYNC = 2, INITFLAG_RESIZABLE = 4, + INITFLAG_BORDERLESS = 8, }; virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags) = 0; diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 2bee031d..659d1087 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -59,6 +59,7 @@ MACRO_CONFIG_INT(SndNonactiveMute, snd_nonactive_mute, 0, 0, 1, CFGFLAG_SAVE|CFG MACRO_CONFIG_INT(GfxScreenWidth, gfx_screen_width, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Screen resolution width") MACRO_CONFIG_INT(GfxScreenHeight, gfx_screen_height, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Screen resolution height") +MACRO_CONFIG_INT(GfxBorderless, gfx_borderless, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Borderless window (not to be used with fullscreen)") MACRO_CONFIG_INT(GfxFullscreen, gfx_fullscreen, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Fullscreen") MACRO_CONFIG_INT(GfxAlphabits, gfx_alphabits, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Alpha bits for framebuffer (fullscreen only)") MACRO_CONFIG_INT(GfxColorDepth, gfx_color_depth, 24, 16, 24, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Colors bits for framebuffer (fullscreen only)") diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 13993783..467ef500 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -613,6 +613,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) static int s_GfxScreenWidth = g_Config.m_GfxScreenWidth; static int s_GfxScreenHeight = g_Config.m_GfxScreenHeight; static int s_GfxColorDepth = g_Config.m_GfxColorDepth; + static int s_GfxBorderless = g_Config.m_GfxBorderless; static int s_GfxFullscreen = g_Config.m_GfxFullscreen; static int s_GfxVsync = g_Config.m_GfxVsync; static int s_GfxFsaaSamples = g_Config.m_GfxFsaaSamples; @@ -667,10 +668,21 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) } // switches + MainView.HSplitTop(20.0f, &Button, &MainView); + if(DoButton_CheckBox(&g_Config.m_GfxBorderless, Localize("Borderless window"), g_Config.m_GfxBorderless, &Button)) + { + g_Config.m_GfxBorderless ^= 1; + if(g_Config.m_GfxBorderless && g_Config.m_GfxFullscreen) + g_Config.m_GfxFullscreen = 0; + CheckSettings = true; + } + MainView.HSplitTop(20.0f, &Button, &MainView); if(DoButton_CheckBox(&g_Config.m_GfxFullscreen, Localize("Fullscreen"), g_Config.m_GfxFullscreen, &Button)) { g_Config.m_GfxFullscreen ^= 1; + if(g_Config.m_GfxFullscreen && g_Config.m_GfxBorderless) + g_Config.m_GfxBorderless = 0; CheckSettings = true; } @@ -713,6 +725,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) if(s_GfxScreenWidth == g_Config.m_GfxScreenWidth && s_GfxScreenHeight == g_Config.m_GfxScreenHeight && s_GfxColorDepth == g_Config.m_GfxColorDepth && + s_GfxBorderless == g_Config.m_GfxBorderless && s_GfxFullscreen == g_Config.m_GfxFullscreen && s_GfxVsync == g_Config.m_GfxVsync && s_GfxFsaaSamples == g_Config.m_GfxFsaaSamples && -- cgit 1.4.1 From ff75c3ba2d1df54ec5f53da2ce502cfd33c182e0 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 8 Jul 2012 13:13:21 +0200 Subject: fixed some memory leaks in the map editor --- src/game/editor/editor.cpp | 11 +++++++++++ src/game/editor/io.cpp | 2 ++ 2 files changed, 13 insertions(+) (limited to 'src/game') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index fa1024e0..2c67c021 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -37,6 +37,11 @@ enum CEditorImage::~CEditorImage() { m_pEditor->Graphics()->UnloadTexture(m_TexID); + if(m_pData) + { + mem_free(m_pData); + m_pData = 0; + } } CLayerGroup::CLayerGroup() @@ -2423,6 +2428,11 @@ void CEditor::ReplaceImage(const char *pFileName, int StorageType, void *pUser) CEditorImage *pImg = pEditor->m_Map.m_lImages[pEditor->m_SelectedImage]; int External = pImg->m_External; pEditor->Graphics()->UnloadTexture(pImg->m_TexID); + if(pImg->m_pData) + { + mem_free(pImg->m_pData); + pImg->m_pData = 0; + } *pImg = ImgInfo; pImg->m_External = External; pEditor->ExtractName(pFileName, pImg->m_aName, sizeof(pImg->m_aName)); @@ -2456,6 +2466,7 @@ void CEditor::AddImage(const char *pFileName, int StorageType, void *pUser) CEditorImage *pImg = new CEditorImage(pEditor); *pImg = ImgInfo; pImg->m_TexID = pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0); + ImgInfo.m_pData = 0; pImg->m_External = 1; // external by default str_copy(pImg->m_aName, aBuf, sizeof(pImg->m_aName)); pImg->m_AutoMapper.Load(pImg->m_aName); diff --git a/src/game/editor/io.cpp b/src/game/editor/io.cpp index 463147e1..529638cf 100644 --- a/src/game/editor/io.cpp +++ b/src/game/editor/io.cpp @@ -391,6 +391,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) } df.AddItem(MAPITEMTYPE_ENVPOINTS, 0, TotalSize, pPoints); + mem_free(pPoints); // finish the data file df.Finish(); @@ -479,6 +480,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag { *pImg = ImgInfo; pImg->m_TexID = m_pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0); + ImgInfo.m_pData = 0; pImg->m_External = 1; } } -- cgit 1.4.1 From 4fb57dea91557cb1bd5da22a98e0531e83ee1471 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 22 Jul 2012 10:43:19 +0200 Subject: fixed editor crash on replacing images. Closes #981 --- src/game/editor/editor.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/game') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 2c67c021..ee26a3f0 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -2438,6 +2438,7 @@ void CEditor::ReplaceImage(const char *pFileName, int StorageType, void *pUser) pEditor->ExtractName(pFileName, pImg->m_aName, sizeof(pImg->m_aName)); pImg->m_AutoMapper.Load(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); + ImgInfo.m_pData = 0; pEditor->SortImages(); for(int i = 0; i < pEditor->m_Map.m_lImages.size(); ++i) { -- cgit 1.4.1 From 1711be955b54b9d12431b341ea290bad406023cc Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Fri, 17 Aug 2012 18:32:56 +0200 Subject: fixed all the errors that the clang static analayzer found --- src/base/system.c | 4 +++- src/base/system.h | 7 +++++++ src/engine/client/client.cpp | 3 +-- src/engine/shared/console.cpp | 2 +- src/engine/shared/snapshot.cpp | 7 ++++--- src/game/editor/editor.cpp | 4 ---- src/game/editor/popups.cpp | 1 - src/game/server/gamecontext.cpp | 10 ++++++---- src/game/server/gamecontroller.cpp | 4 ++-- 9 files changed, 24 insertions(+), 18 deletions(-) (limited to 'src/game') diff --git a/src/base/system.c b/src/base/system.c index a849e807..410cb699 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -80,7 +80,7 @@ void dbg_assert_imp(const char *filename, int line, int test, const char *msg) void dbg_break() { - *((unsigned*)0) = 0x0; + *((volatile unsigned*)0) = 0x0; } void dbg_msg(const char *sys, const char *fmt, ...) @@ -166,6 +166,8 @@ void *mem_alloc_debug(const char *filename, int line, unsigned size, unsigned al MEMTAIL *tail; MEMHEADER *header = (struct MEMHEADER *)malloc(size+sizeof(MEMHEADER)+sizeof(MEMTAIL)); dbg_assert(header != 0, "mem_alloc failure"); + if(!header) + return NULL; tail = (struct MEMTAIL *)(((char*)(header+1))+size); header->size = size; header->filename = filename; diff --git a/src/base/system.h b/src/base/system.h index 032cf785..7ba0c0a0 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -33,6 +33,13 @@ void dbg_assert(int test, const char *msg); #define dbg_assert(test,msg) dbg_assert_imp(__FILE__, __LINE__, test, msg) void dbg_assert_imp(const char *filename, int line, int test, const char *msg); + +#ifdef __clang_analyzer__ +#include +#undef dbg_assert +#define dbg_assert(test,msg) assert(test) +#endif + /* Function: dbg_break Breaks into the debugger. diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 6d1d8f4f..a88fe3cb 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1310,7 +1310,6 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket) } // unpack delta - PurgeTick = DeltaTick; SnapSize = m_SnapshotDelta.UnpackDelta(pDeltaShot, pTmpBuffer3, pDeltaData, DeltaSize); if(SnapSize < 0) { @@ -1349,7 +1348,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket) if(m_aSnapshots[SNAP_PREV] && m_aSnapshots[SNAP_PREV]->m_Tick < PurgeTick) PurgeTick = m_aSnapshots[SNAP_PREV]->m_Tick; if(m_aSnapshots[SNAP_CURRENT] && m_aSnapshots[SNAP_CURRENT]->m_Tick < PurgeTick) - PurgeTick = m_aSnapshots[SNAP_PREV]->m_Tick; + PurgeTick = m_aSnapshots[SNAP_CURRENT]->m_Tick; m_SnapshotStorage.PurgeUntil(PurgeTick); // add new diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp index 3ff3c5b3..399f5323 100644 --- a/src/engine/shared/console.cpp +++ b/src/engine/shared/console.cpp @@ -68,7 +68,7 @@ int CConsole::ParseStart(CResult *pResult, const char *pString, int Length) if(Length < Len) Len = Length; - str_copy(pResult->m_aStringStorage, pString, Length); + str_copy(pResult->m_aStringStorage, pString, Len); pStr = pResult->m_aStringStorage; // get command diff --git a/src/engine/shared/snapshot.cpp b/src/engine/shared/snapshot.cpp index 9ef8fdc3..1514278b 100644 --- a/src/engine/shared/snapshot.cpp +++ b/src/engine/shared/snapshot.cpp @@ -195,13 +195,14 @@ int CSnapshotDelta::CreateDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pDstData // fetch previous indices // we do this as a separate pass because it helps the cache - for(i = 0; i < pTo->NumItems(); i++) + const int NumItems = pTo->NumItems(); + for(i = 0; i < NumItems; i++) { pCurItem = pTo->GetItem(i); // O(1) .. O(n) aPastIndecies[i] = GetItemIndexHashed(pCurItem->Key(), Hashlist); // O(n) .. O(n^n) } - for(i = 0; i < pTo->NumItems(); i++) + for(i = 0; i < NumItems; i++) { // do delta ItemSize = pTo->GetItemSize(i); // O(1) .. O(n) @@ -474,7 +475,7 @@ int CSnapshotStorage::Get(int Tick, int64 *pTagtime, CSnapshot **ppData, CSnapsh if(ppData) *ppData = pHolder->m_pSnap; if(ppAltData) - *ppData = pHolder->m_pAltSnap; + *ppAltData = pHolder->m_pAltSnap; return pHolder->m_SnapSize; } diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index ee26a3f0..7109adca 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -2292,8 +2292,6 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN)) s_ScrollValue = clamp(s_ScrollValue + 1.0f/ScrollNum, 0.0f, 1.0f); } - else - ScrollNum = 0; } } @@ -2615,8 +2613,6 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN)) s_ScrollValue = clamp(s_ScrollValue + 1.0f/ScrollNum, 0.0f, 1.0f); } - else - ScrollNum = 0; } } diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 2382823d..f281c6aa 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -554,7 +554,6 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View) { if(pEditor->m_SelectedPoints&(1<m_aColors[v].r = (NewVal>>24)&0xff; pQuad->m_aColors[v].g = (NewVal>>16)&0xff; pQuad->m_aColors[v].b = (NewVal>>8)&0xff; diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 5d2f22b8..bab48308 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -599,9 +599,12 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) if(!pRawMsg) { - char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgID), MsgID, m_NetObjHandler.FailedMsgOn()); - Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf); + if(g_Config.m_Debug) + { + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgID), MsgID, m_NetObjHandler.FailedMsgOn()); + Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf); + } return; } @@ -940,7 +943,6 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) { OptionMsg.m_NumOptions = NumOptions; Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID); - NumOptions = 0; } // send tuning parameters to client diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 7001ca32..0ee250e8 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -281,8 +281,8 @@ void IGameController::CycleMap() pNextMap = pMapRotation; // cut out the next map - char aBuf[512]; - for(int i = 0; i < 512; i++) + char aBuf[512] = {0}; + for(int i = 0; i < 511; i++) { aBuf[i] = pNextMap[i]; if(IsSeparator(pNextMap[i]) || pNextMap[i] == 0) -- cgit 1.4.1 From dfd15bc899b0bcf91f454b1b52b26bd471f653e8 Mon Sep 17 00:00:00 2001 From: BeaR Date: Mon, 13 Aug 2012 12:57:40 +0200 Subject: Fix Renderingbug: If u change the alpha value inside a colorenvelope, the tileset-/quad-rendering is messed sometimes http://i.solidfiles.net/580a9699c4.png(map: run_exchange by delo) --- src/game/client/render_map.cpp | 5 +++-- src/game/editor/layer_quads.cpp | 5 ++++- src/game/editor/layer_tiles.cpp | 6 +++++- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/game') diff --git a/src/game/client/render_map.cpp b/src/game/client/render_map.cpp index 23fa42e0..3b409fb8 100644 --- a/src/game/client/render_map.cpp +++ b/src/game/client/render_map.cpp @@ -99,9 +99,10 @@ void CRenderTools::RenderQuads(CQuad *pQuads, int NumQuads, int RenderFlags, ENV } bool Opaque = false; + /* TODO: Analyze quadtexture if(a < 0.01f || (q->m_aColors[0].a < 0.01f && q->m_aColors[1].a < 0.01f && q->m_aColors[2].a < 0.01f && q->m_aColors[3].a < 0.01f)) Opaque = true; - + */ if(Opaque && !(RenderFlags&LAYERRENDERFLAG_OPAQUE)) continue; if(!Opaque && !(RenderFlags&LAYERRENDERFLAG_TRANSPARENT)) @@ -236,7 +237,7 @@ void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, vec4 unsigned char Flags = pTiles[c].m_Flags; bool Render = false; - if(Flags&TILEFLAG_OPAQUE) + if(Flags&TILEFLAG_OPAQUE && Color.a*a > 250/255.0f) { if(RenderFlags&LAYERRENDERFLAG_OPAQUE) Render = true; diff --git a/src/game/editor/layer_quads.cpp b/src/game/editor/layer_quads.cpp index d0b66405..321a28f8 100644 --- a/src/game/editor/layer_quads.cpp +++ b/src/game/editor/layer_quads.cpp @@ -27,7 +27,10 @@ void CLayerQuads::Render() if(m_Image >= 0 && m_Image < m_pEditor->m_Map.m_lImages.size()) Graphics()->TextureSet(m_pEditor->m_Map.m_lImages[m_Image]->m_TexID); - m_pEditor->RenderTools()->RenderQuads(m_lQuads.base_ptr(), m_lQuads.size(), LAYERRENDERFLAG_OPAQUE|LAYERRENDERFLAG_TRANSPARENT, m_pEditor->EnvelopeEval, m_pEditor); + Graphics()->BlendNone(); + m_pEditor->RenderTools()->RenderQuads(m_lQuads.base_ptr(), m_lQuads.size(), LAYERRENDERFLAG_OPAQUE, m_pEditor->EnvelopeEval, m_pEditor); + Graphics()->BlendNormal(); + m_pEditor->RenderTools()->RenderQuads(m_lQuads.base_ptr(), m_lQuads.size(), LAYERRENDERFLAG_TRANSPARENT, m_pEditor->EnvelopeEval, m_pEditor); } CQuad *CLayerQuads::NewQuad() diff --git a/src/game/editor/layer_tiles.cpp b/src/game/editor/layer_tiles.cpp index 9a21e5ce..325d527b 100644 --- a/src/game/editor/layer_tiles.cpp +++ b/src/game/editor/layer_tiles.cpp @@ -64,7 +64,11 @@ void CLayerTiles::Render() m_TexID = m_pEditor->m_Map.m_lImages[m_Image]->m_TexID; Graphics()->TextureSet(m_TexID); vec4 Color = vec4(m_Color.r/255.0f, m_Color.g/255.0f, m_Color.b/255.0f, m_Color.a/255.0f); - m_pEditor->RenderTools()->RenderTilemap(m_pTiles, m_Width, m_Height, 32.0f, Color, LAYERRENDERFLAG_OPAQUE|LAYERRENDERFLAG_TRANSPARENT, + Graphics()->BlendNone(); + m_pEditor->RenderTools()->RenderTilemap(m_pTiles, m_Width, m_Height, 32.0f, Color, LAYERRENDERFLAG_OPAQUE, + m_pEditor->EnvelopeEval, m_pEditor, m_ColorEnv, m_ColorEnvOffset); + Graphics()->BlendNormal(); + m_pEditor->RenderTools()->RenderTilemap(m_pTiles, m_Width, m_Height, 32.0f, Color, LAYERRENDERFLAG_TRANSPARENT, m_pEditor->EnvelopeEval, m_pEditor, m_ColorEnv, m_ColorEnvOffset); } -- cgit 1.4.1 From d8ff437c5ecc4cc3e7f627d6ac6f20447e6efaf6 Mon Sep 17 00:00:00 2001 From: BeaR Date: Fri, 17 Aug 2012 10:44:51 +0200 Subject: Set value higher --- src/game/client/render_map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/client/render_map.cpp b/src/game/client/render_map.cpp index 3b409fb8..a854b4a7 100644 --- a/src/game/client/render_map.cpp +++ b/src/game/client/render_map.cpp @@ -237,7 +237,7 @@ void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, vec4 unsigned char Flags = pTiles[c].m_Flags; bool Render = false; - if(Flags&TILEFLAG_OPAQUE && Color.a*a > 250/255.0f) + if(Flags&TILEFLAG_OPAQUE && Color.a*a > 254.0f/255.0f) { if(RenderFlags&LAYERRENDERFLAG_OPAQUE) Render = true; -- cgit 1.4.1 From 7eddbe0dc9297e795ffdac65914f70ffcd43325a Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 6 Oct 2012 13:47:37 +0200 Subject: play only one weapon no ammo sound per second. #993 --- src/game/server/entities/character.cpp | 7 ++++++- src/game/server/entities/character.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 1c76f655..6794429d 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -56,6 +56,7 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos) { m_EmoteStop = -1; m_LastAction = -1; + m_LastNoAmmoSound = -1; m_ActiveWeapon = WEAPON_GUN; m_LastWeapon = WEAPON_HAMMER; m_QueuedWeapon = -1; @@ -270,7 +271,11 @@ void CCharacter::FireWeapon() { // 125ms is a magical limit of how fast a human can click m_ReloadTimer = 125 * Server()->TickSpeed() / 1000; - GameServer()->CreateSound(m_Pos, SOUND_WEAPON_NOAMMO); + if(m_LastNoAmmoSound+Server()->TickSpeed() <= Server()->Tick()) + { + GameServer()->CreateSound(m_Pos, SOUND_WEAPON_NOAMMO); + m_LastNoAmmoSound = Server()->Tick(); + } return; } diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index aa127979..d799d8a7 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -97,6 +97,7 @@ private: // last tick that the player took any action ie some input int m_LastAction; + int m_LastNoAmmoSound; // these are non-heldback inputs CNetObj_PlayerInput m_LatestPrevInput; -- cgit 1.4.1 From d58afefaae99f239151483025e516e8da5b6dd17 Mon Sep 17 00:00:00 2001 From: BeaR Date: Sun, 14 Oct 2012 14:04:48 +0200 Subject: Some graphic batching: Speed up for displaying debugtext and envelopepreview (This reduces the performance hit especially for the 'Show Info' mode in the editor) Conflicts: src/engine/client/client.cpp src/game/editor/editor.cpp src/game/editor/editor.h --- src/engine/client/client.cpp | 18 ++-- src/engine/client/graphics_threaded.cpp | 7 +- src/engine/client/graphics_threaded.h | 2 +- src/engine/graphics.h | 2 +- src/game/editor/editor.cpp | 183 +++++++++++++++++++------------- src/game/editor/editor.h | 2 +- src/game/editor/layer_tiles.cpp | 6 +- 7 files changed, 128 insertions(+), 92 deletions(-) (limited to 'src/game') diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index a88fe3cb..c481102b 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -137,14 +137,16 @@ void CGraph::Render(IGraphics *pGraphics, int Font, float x, float y, float w, f pGraphics->LinesEnd(); pGraphics->TextureSet(Font); - pGraphics->QuadsText(x+2, y+h-16, 16, 1,1,1,1, pDescription); + pGraphics->QuadsBegin(); + pGraphics->QuadsText(x+2, y+h-16, 16, pDescription); char aBuf[32]; str_format(aBuf, sizeof(aBuf), "%.2f", m_Max); - pGraphics->QuadsText(x+w-8*str_length(aBuf)-8, y+2, 16, 1,1,1,1, aBuf); + pGraphics->QuadsText(x+w-8*str_length(aBuf)-8, y+2, 16, aBuf); str_format(aBuf, sizeof(aBuf), "%.2f", m_Min); - pGraphics->QuadsText(x+w-8*str_length(aBuf)-8, y+h-16, 16, 1,1,1,1, aBuf); + pGraphics->QuadsText(x+w-8*str_length(aBuf)-8, y+h-16, 16, aBuf); + pGraphics->QuadsEnd(); } @@ -678,6 +680,7 @@ void CClient::DebugRender() //m_pGraphics->BlendNormal(); Graphics()->TextureSet(m_DebugFont); Graphics()->MapScreen(0,0,Graphics()->ScreenWidth(),Graphics()->ScreenHeight()); + Graphics()->QuadsBegin(); if(time_get()-LastSnap > time_freq()) { @@ -699,7 +702,7 @@ void CClient::DebugRender() mem_stats()->total_allocations, Graphics()->MemoryUsage()/1024, (int)(1.0f/FrameTimeAvg + 0.5f)); - Graphics()->QuadsText(2, 2, 16, 1,1,1,1, aBuffer); + Graphics()->QuadsText(2, 2, 16, aBuffer); { @@ -715,7 +718,7 @@ void CClient::DebugRender() str_format(aBuffer, sizeof(aBuffer), "send: %3d %5d+%4d=%5d (%3d kbps) avg: %5d\nrecv: %3d %5d+%4d=%5d (%3d kbps) avg: %5d", SendPackets, SendBytes, SendPackets*42, SendTotal, (SendTotal*8)/1024, SendBytes/SendPackets, RecvPackets, RecvBytes, RecvPackets*42, RecvTotal, (RecvTotal*8)/1024, RecvBytes/RecvPackets); - Graphics()->QuadsText(2, 14, 16, 1,1,1,1, aBuffer); + Graphics()->QuadsText(2, 14, 16, aBuffer); } // render rates @@ -728,7 +731,7 @@ void CClient::DebugRender() { str_format(aBuffer, sizeof(aBuffer), "%4d %20s: %8d %8d %8d", i, GameClient()->GetItemName(i), m_SnapshotDelta.GetDataRate(i)/8, m_SnapshotDelta.GetDataUpdates(i), (m_SnapshotDelta.GetDataRate(i)/m_SnapshotDelta.GetDataUpdates(i))/8); - Graphics()->QuadsText(2, 100+y*12, 16, 1,1,1,1, aBuffer); + Graphics()->QuadsText(2, 100+y*12, 16, aBuffer); y++; } } @@ -736,7 +739,8 @@ void CClient::DebugRender() str_format(aBuffer, sizeof(aBuffer), "pred: %d ms", (int)((m_PredictedTime.Get(Now)-m_GameTime.Get(Now))*1000/(float)time_freq())); - Graphics()->QuadsText(2, 70, 16, 1,1,1,1, aBuffer); + Graphics()->QuadsText(2, 70, 16, aBuffer); + Graphics()->QuadsEnd(); // render graphs if(g_Config.m_DbgGraphs) diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 7a2687c5..8a3e4f50 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -629,13 +629,10 @@ void CGraphics_Threaded::QuadsDrawFreeform(const CFreeformItem *pArray, int Num) AddVertices(4*Num); } -void CGraphics_Threaded::QuadsText(float x, float y, float Size, float r, float g, float b, float a, const char *pText) +void CGraphics_Threaded::QuadsText(float x, float y, float Size, const char *pText) { float StartX = x; - QuadsBegin(); - SetColor(r,g,b,a); - while(*pText) { char c = *pText; @@ -659,8 +656,6 @@ void CGraphics_Threaded::QuadsText(float x, float y, float Size, float r, float x += Size/2; } } - - QuadsEnd(); } int CGraphics_Threaded::IssueInit() diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 809a383a..ff03c6bb 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -419,7 +419,7 @@ public: virtual void QuadsDraw(CQuadItem *pArray, int Num); virtual void QuadsDrawTL(const CQuadItem *pArray, int Num); virtual void QuadsDrawFreeform(const CFreeformItem *pArray, int Num); - virtual void QuadsText(float x, float y, float Size, float r, float g, float b, float a, const char *pText); + virtual void QuadsText(float x, float y, float Size, const char *pText); virtual void Minimize(); virtual void Maximize(); diff --git a/src/engine/graphics.h b/src/engine/graphics.h index 7f272497..a2fe4741 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -120,7 +120,7 @@ public: : m_X0(x0), m_Y0(y0), m_X1(x1), m_Y1(y1), m_X2(x2), m_Y2(y2), m_X3(x3), m_Y3(y3) {} }; virtual void QuadsDrawFreeform(const CFreeformItem *pArray, int Num) = 0; - virtual void QuadsText(float x, float y, float Size, float r, float g, float b, float a, const char *pText) = 0; + virtual void QuadsText(float x, float y, float Size, const char *pText) = 0; struct CColorVertex { diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 7109adca..07f50110 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1408,96 +1408,131 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) Graphics()->QuadsDraw(&QuadItem, 1); } -void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Index, int TexID) +void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Num, int TexID) { - CEnvelope *pEnvelope = 0x0; - if(pQuad->m_PosEnv >= 0 && pQuad->m_PosEnv < m_Map.m_lEnvelopes.size()) - pEnvelope = m_Map.m_lEnvelopes[pQuad->m_PosEnv]; - if (!pEnvelope) - return; - - //QuadParams - CPoint *pPoints = pQuad->m_aPoints; + CEnvelope **apEnvelope = new CEnvelope*[Num](); + for(int i = 0; i < Num; i++) + { + if((m_ShowEnvelopePreview == 1 && pQuad[i].m_PosEnv == m_SelectedEnvelope) || m_ShowEnvelopePreview == 2) + if(pQuad[i].m_PosEnv >= 0 && pQuad[i].m_PosEnv < m_Map.m_lEnvelopes.size()) + apEnvelope[i] = m_Map.m_lEnvelopes[pQuad[i].m_PosEnv]; + } //Draw Lines Graphics()->TextureSet(-1); Graphics()->LinesBegin(); - Graphics()->SetColor(80.0f/255, 150.0f/255, 230.f/255, 0.5f); - for(int i = 0; i < pEnvelope->m_lPoints.size()-1; i++) + Graphics()->SetColor(80.0f/255, 150.0f/255, 230.f/255, 0.5f); + for(int j = 0; j < Num; j++) + { + if(!apEnvelope[j]) + continue; + + //QuadParams + CPoint *pPoints = pQuad[j].m_aPoints; + for(int i = 0; i < apEnvelope[j]->m_lPoints.size()-1; i++) { - float OffsetX = fx2f(pEnvelope->m_lPoints[i].m_aValues[0]); - float OffsetY = fx2f(pEnvelope->m_lPoints[i].m_aValues[1]); + float OffsetX = fx2f(apEnvelope[j]->m_lPoints[i].m_aValues[0]); + float OffsetY = fx2f(apEnvelope[j]->m_lPoints[i].m_aValues[1]); vec2 Pos0 = vec2(fx2f(pPoints[4].x)+OffsetX, fx2f(pPoints[4].y)+OffsetY); - OffsetX = fx2f(pEnvelope->m_lPoints[i+1].m_aValues[0]); - OffsetY = fx2f(pEnvelope->m_lPoints[i+1].m_aValues[1]); + OffsetX = fx2f(apEnvelope[j]->m_lPoints[i+1].m_aValues[0]); + OffsetY = fx2f(apEnvelope[j]->m_lPoints[i+1].m_aValues[1]); vec2 Pos1 = vec2(fx2f(pPoints[4].x)+OffsetX, fx2f(pPoints[4].y)+OffsetY); IGraphics::CLineItem Line = IGraphics::CLineItem(Pos0.x, Pos0.y, Pos1.x, Pos1.y); Graphics()->LinesDraw(&Line, 1); } - Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); + } + Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); Graphics()->LinesEnd(); //Draw Quads - for(int i = 0; i < pEnvelope->m_lPoints.size(); i++) + Graphics()->TextureSet(Texture); + Graphics()->QuadsBegin(); + + for(int j = 0; j < Num; j++) { - Graphics()->TextureSet(TexID); - Graphics()->QuadsBegin(); - - //Calc Env Position - float OffsetX = fx2f(pEnvelope->m_lPoints[i].m_aValues[0]); - float OffsetY = fx2f(pEnvelope->m_lPoints[i].m_aValues[1]); - float Rot = fx2f(pEnvelope->m_lPoints[i].m_aValues[2])/360.0f*pi*2; - - //Set Colours - float Alpha = (m_SelectedQuadEnvelope == pQuad->m_PosEnv && m_SelectedEnvelopePoint == i) ? 0.65f : 0.35f; - IGraphics::CColorVertex aArray[4] = { - IGraphics::CColorVertex(0, pQuad->m_aColors[0].r, pQuad->m_aColors[0].g, pQuad->m_aColors[0].b, Alpha), - IGraphics::CColorVertex(1, pQuad->m_aColors[1].r, pQuad->m_aColors[1].g, pQuad->m_aColors[1].b, Alpha), - IGraphics::CColorVertex(2, pQuad->m_aColors[2].r, pQuad->m_aColors[2].g, pQuad->m_aColors[2].b, Alpha), - IGraphics::CColorVertex(3, pQuad->m_aColors[3].r, pQuad->m_aColors[3].g, pQuad->m_aColors[3].b, Alpha)}; - Graphics()->SetColorVertex(aArray, 4); - - //Rotation - if(Rot != 0) - { - static CPoint aRotated[4]; - aRotated[0] = pQuad->m_aPoints[0]; - aRotated[1] = pQuad->m_aPoints[1]; - aRotated[2] = pQuad->m_aPoints[2]; - aRotated[3] = pQuad->m_aPoints[3]; - pPoints = aRotated; - - Rotate(&pQuad->m_aPoints[4], &aRotated[0], Rot); - Rotate(&pQuad->m_aPoints[4], &aRotated[1], Rot); - Rotate(&pQuad->m_aPoints[4], &aRotated[2], Rot); - Rotate(&pQuad->m_aPoints[4], &aRotated[3], Rot); - } - - //Set Texture Coords - Graphics()->QuadsSetSubsetFree( - fx2f(pQuad->m_aTexcoords[0].x), fx2f(pQuad->m_aTexcoords[0].y), - fx2f(pQuad->m_aTexcoords[1].x), fx2f(pQuad->m_aTexcoords[1].y), - fx2f(pQuad->m_aTexcoords[2].x), fx2f(pQuad->m_aTexcoords[2].y), - fx2f(pQuad->m_aTexcoords[3].x), fx2f(pQuad->m_aTexcoords[3].y) - ); - - //Set Quad Coords & Draw - IGraphics::CFreeformItem Freeform( - fx2f(pPoints[0].x)+OffsetX, fx2f(pPoints[0].y)+OffsetY, - fx2f(pPoints[1].x)+OffsetX, fx2f(pPoints[1].y)+OffsetY, - fx2f(pPoints[2].x)+OffsetX, fx2f(pPoints[2].y)+OffsetY, - fx2f(pPoints[3].x)+OffsetX, fx2f(pPoints[3].y)+OffsetY); - Graphics()->QuadsDrawFreeform(&Freeform, 1); + if(!apEnvelope[j]) + continue; - Graphics()->QuadsEnd(); - - Graphics()->TextureSet(-1); - Graphics()->QuadsBegin(); - DoQuadEnvPoint(pQuad, Index, i); - Graphics()->QuadsEnd(); + //QuadParams + CPoint *pPoints = pQuad[j].m_aPoints; + + for(int i = 0; i < apEnvelope[j]->m_lPoints.size(); i++) + { + //Calc Env Position + float OffsetX = fx2f(apEnvelope[j]->m_lPoints[i].m_aValues[0]); + float OffsetY = fx2f(apEnvelope[j]->m_lPoints[i].m_aValues[1]); + float Rot = fx2f(apEnvelope[j]->m_lPoints[i].m_aValues[2])/360.0f*pi*2; + + //Set Colours + float Alpha = (m_SelectedQuadEnvelope == pQuad[j].m_PosEnv && m_SelectedEnvelopePoint == i) ? 0.65f : 0.35f; + IGraphics::CColorVertex aArray[4] = { + IGraphics::CColorVertex(0, pQuad[j].m_aColors[0].r, pQuad[j].m_aColors[0].g, pQuad[j].m_aColors[0].b, Alpha), + IGraphics::CColorVertex(1, pQuad[j].m_aColors[1].r, pQuad[j].m_aColors[1].g, pQuad[j].m_aColors[1].b, Alpha), + IGraphics::CColorVertex(2, pQuad[j].m_aColors[2].r, pQuad[j].m_aColors[2].g, pQuad[j].m_aColors[2].b, Alpha), + IGraphics::CColorVertex(3, pQuad[j].m_aColors[3].r, pQuad[j].m_aColors[3].g, pQuad[j].m_aColors[3].b, Alpha)}; + Graphics()->SetColorVertex(aArray, 4); + + //Rotation + if(Rot != 0) + { + static CPoint aRotated[4]; + aRotated[0] = pQuad[j].m_aPoints[0]; + aRotated[1] = pQuad[j].m_aPoints[1]; + aRotated[2] = pQuad[j].m_aPoints[2]; + aRotated[3] = pQuad[j].m_aPoints[3]; + pPoints = aRotated; + + Rotate(&pQuad[j].m_aPoints[4], &aRotated[0], Rot); + Rotate(&pQuad[j].m_aPoints[4], &aRotated[1], Rot); + Rotate(&pQuad[j].m_aPoints[4], &aRotated[2], Rot); + Rotate(&pQuad[j].m_aPoints[4], &aRotated[3], Rot); + } + + //Set Texture Coords + Graphics()->QuadsSetSubsetFree( + fx2f(pQuad[j].m_aTexcoords[0].x), fx2f(pQuad[j].m_aTexcoords[0].y), + fx2f(pQuad[j].m_aTexcoords[1].x), fx2f(pQuad[j].m_aTexcoords[1].y), + fx2f(pQuad[j].m_aTexcoords[2].x), fx2f(pQuad[j].m_aTexcoords[2].y), + fx2f(pQuad[j].m_aTexcoords[3].x), fx2f(pQuad[j].m_aTexcoords[3].y) + ); + + //Set Quad Coords & Draw + IGraphics::CFreeformItem Freeform( + fx2f(pPoints[0].x)+OffsetX, fx2f(pPoints[0].y)+OffsetY, + fx2f(pPoints[1].x)+OffsetX, fx2f(pPoints[1].y)+OffsetY, + fx2f(pPoints[2].x)+OffsetX, fx2f(pPoints[2].y)+OffsetY, + fx2f(pPoints[3].x)+OffsetX, fx2f(pPoints[3].y)+OffsetY); + Graphics()->QuadsDrawFreeform(&Freeform, 1); + } + } + Graphics()->QuadsEnd(); + Graphics()->TextureClear(); + Graphics()->QuadsBegin(); + + // Draw QuadPoints + for(int j = 0; j < Num; j++) + { + if(!apEnvelope[j]) + continue; + + //QuadParams + CPoint *pPoints = pQuad[j].m_aPoints; + for(int i = 0; i < apEnvelope[j]->m_lPoints.size()-1; i++) + { + float OffsetX = fx2f(apEnvelope[j]->m_lPoints[i].m_aValues[0]); + float OffsetY = fx2f(apEnvelope[j]->m_lPoints[i].m_aValues[1]); + vec2 Pos0 = vec2(fx2f(pPoints[4].x)+OffsetX, fx2f(pPoints[4].y)+OffsetY); + + OffsetX = fx2f(apEnvelope[j]->m_lPoints[i+1].m_aValues[0]); + OffsetY = fx2f(apEnvelope[j]->m_lPoints[i+1].m_aValues[1]); + vec2 Pos1 = vec2(fx2f(pPoints[4].x)+OffsetX, fx2f(pPoints[4].y)+OffsetY); + + DoQuadEnvPoint(&pQuad[j], j, i); + } } + Graphics()->QuadsEnd(); } void CEditor::DoQuadEnvPoint(CQuad *pQuad, int QIndex, int PIndex) @@ -2093,12 +2128,12 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) if(pLayer->m_Image >= 0 && pLayer->m_Image < m_Map.m_lImages.size()) TexID = m_Map.m_lImages[pLayer->m_Image]->m_TexID; - for(int i = 0; i < pLayer->m_lQuads.size(); i++) + /*for(int i = 0; i < pLayer->m_lQuads.size(); i++) { if((m_ShowEnvelopePreview == 1 && pLayer->m_lQuads[i].m_PosEnv == m_SelectedEnvelope) || m_ShowEnvelopePreview == 2) DoQuadEnvelopes(&pLayer->m_lQuads[i], i, TexID); - } - + }*/ + DoQuadEnvelopes(&pLayer->m_lQuads[0], pLayer->m_lQuads.size(), TexID); m_ShowEnvelopePreview = 0; } diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index a81474d9..2807d35c 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -761,7 +761,7 @@ public: vec4 ButtonColorMul(const void *pID); - void DoQuadEnvelopes(CQuad *pQuad, int Index, int TexID = -1); + void DoQuadEnvelopes(CQuad *pQuad, int Num, int TexID = -1); void DoQuadEnvPoint(CQuad *pQuad, int QIndex, int pIndex); void DoQuadPoint(CQuad *pQuad, int QuadIndex, int v); diff --git a/src/game/editor/layer_tiles.cpp b/src/game/editor/layer_tiles.cpp index 325d527b..032f391f 100644 --- a/src/game/editor/layer_tiles.cpp +++ b/src/game/editor/layer_tiles.cpp @@ -338,6 +338,7 @@ void CLayerTiles::ShowInfo() float ScreenX0, ScreenY0, ScreenX1, ScreenY1; Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); Graphics()->TextureSet(m_pEditor->Client()->GetDebugFont()); + Graphics()->QuadsBegin(); int StartY = max(0, (int)(ScreenY0/32.0f)-1); int StartX = max(0, (int)(ScreenX0/32.0f)-1); @@ -352,17 +353,18 @@ void CLayerTiles::ShowInfo() { char aBuf[64]; str_format(aBuf, sizeof(aBuf), "%i", m_pTiles[c].m_Index); - m_pEditor->Graphics()->QuadsText(x*32, y*32, 16.0f, 1,1,1,1, aBuf); + m_pEditor->Graphics()->QuadsText(x*32, y*32, 16.0f, aBuf); char aFlags[4] = { m_pTiles[c].m_Flags&TILEFLAG_VFLIP ? 'V' : ' ', m_pTiles[c].m_Flags&TILEFLAG_HFLIP ? 'H' : ' ', m_pTiles[c].m_Flags&TILEFLAG_ROTATE? 'R' : ' ', 0}; - m_pEditor->Graphics()->QuadsText(x*32, y*32+16, 16.0f, 1,1,1,1, aFlags); + m_pEditor->Graphics()->QuadsText(x*32, y*32+16, 16.0f, aFlags); } x += m_pTiles[c].m_Skip; } + Graphics()->QuadsEnd(); Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); } -- cgit 1.4.1 From 8b4026cbbfb2cf04da8ee47f0b6b30d228cfebaf Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 21 Oct 2012 14:49:26 +0200 Subject: fixed last commit Conflicts: src/game/editor/editor.cpp src/game/editor/editor.h --- src/game/editor/editor.cpp | 75 +++++++++++++++++++--------------------------- src/game/editor/editor.h | 4 +-- 2 files changed, 33 insertions(+), 46 deletions(-) (limited to 'src/game') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 07f50110..ccd1757f 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1018,7 +1018,7 @@ void CEditor::DoToolbar(CUIRect ToolBar) } } -static void Rotate(CPoint *pCenter, CPoint *pPoint, float Rotation) +static void Rotate(const CPoint *pCenter, CPoint *pPoint, float Rotation) { int x = pPoint->x - pCenter->x; int y = pPoint->y - pCenter->y; @@ -1408,14 +1408,16 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) Graphics()->QuadsDraw(&QuadItem, 1); } -void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Num, int TexID) +void CEditor::DoQuadEnvelopes(const array &lQuads, int TexID) { - CEnvelope **apEnvelope = new CEnvelope*[Num](); + int Num = lQuads.size(); + CEnvelope **apEnvelope = new CEnvelope*[Num]; + mem_zero(apEnvelope, sizeof(CEnvelope*)*Num); for(int i = 0; i < Num; i++) { - if((m_ShowEnvelopePreview == 1 && pQuad[i].m_PosEnv == m_SelectedEnvelope) || m_ShowEnvelopePreview == 2) - if(pQuad[i].m_PosEnv >= 0 && pQuad[i].m_PosEnv < m_Map.m_lEnvelopes.size()) - apEnvelope[i] = m_Map.m_lEnvelopes[pQuad[i].m_PosEnv]; + if((m_ShowEnvelopePreview == 1 && lQuads[i].m_PosEnv == m_SelectedEnvelope) || m_ShowEnvelopePreview == 2) + if(lQuads[i].m_PosEnv >= 0 && lQuads[i].m_PosEnv < m_Map.m_lEnvelopes.size()) + apEnvelope[i] = m_Map.m_lEnvelopes[lQuads[i].m_PosEnv]; } //Draw Lines @@ -1428,7 +1430,7 @@ void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Num, int TexID) continue; //QuadParams - CPoint *pPoints = pQuad[j].m_aPoints; + const CPoint *pPoints = lQuads[j].m_aPoints; for(int i = 0; i < apEnvelope[j]->m_lPoints.size()-1; i++) { float OffsetX = fx2f(apEnvelope[j]->m_lPoints[i].m_aValues[0]); @@ -1456,7 +1458,7 @@ void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Num, int TexID) continue; //QuadParams - CPoint *pPoints = pQuad[j].m_aPoints; + const CPoint *pPoints = lQuads[j].m_aPoints; for(int i = 0; i < apEnvelope[j]->m_lPoints.size(); i++) { @@ -1466,36 +1468,36 @@ void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Num, int TexID) float Rot = fx2f(apEnvelope[j]->m_lPoints[i].m_aValues[2])/360.0f*pi*2; //Set Colours - float Alpha = (m_SelectedQuadEnvelope == pQuad[j].m_PosEnv && m_SelectedEnvelopePoint == i) ? 0.65f : 0.35f; + float Alpha = (m_SelectedQuadEnvelope == lQuads[j].m_PosEnv && m_SelectedEnvelopePoint == i) ? 0.65f : 0.35f; IGraphics::CColorVertex aArray[4] = { - IGraphics::CColorVertex(0, pQuad[j].m_aColors[0].r, pQuad[j].m_aColors[0].g, pQuad[j].m_aColors[0].b, Alpha), - IGraphics::CColorVertex(1, pQuad[j].m_aColors[1].r, pQuad[j].m_aColors[1].g, pQuad[j].m_aColors[1].b, Alpha), - IGraphics::CColorVertex(2, pQuad[j].m_aColors[2].r, pQuad[j].m_aColors[2].g, pQuad[j].m_aColors[2].b, Alpha), - IGraphics::CColorVertex(3, pQuad[j].m_aColors[3].r, pQuad[j].m_aColors[3].g, pQuad[j].m_aColors[3].b, Alpha)}; + IGraphics::CColorVertex(0, lQuads[j].m_aColors[0].r, lQuads[j].m_aColors[0].g, lQuads[j].m_aColors[0].b, Alpha), + IGraphics::CColorVertex(1, lQuads[j].m_aColors[1].r, lQuads[j].m_aColors[1].g, lQuads[j].m_aColors[1].b, Alpha), + IGraphics::CColorVertex(2, lQuads[j].m_aColors[2].r, lQuads[j].m_aColors[2].g, lQuads[j].m_aColors[2].b, Alpha), + IGraphics::CColorVertex(3, lQuads[j].m_aColors[3].r, lQuads[j].m_aColors[3].g, lQuads[j].m_aColors[3].b, Alpha)}; Graphics()->SetColorVertex(aArray, 4); //Rotation if(Rot != 0) { static CPoint aRotated[4]; - aRotated[0] = pQuad[j].m_aPoints[0]; - aRotated[1] = pQuad[j].m_aPoints[1]; - aRotated[2] = pQuad[j].m_aPoints[2]; - aRotated[3] = pQuad[j].m_aPoints[3]; + aRotated[0] = lQuads[j].m_aPoints[0]; + aRotated[1] = lQuads[j].m_aPoints[1]; + aRotated[2] = lQuads[j].m_aPoints[2]; + aRotated[3] = lQuads[j].m_aPoints[3]; pPoints = aRotated; - Rotate(&pQuad[j].m_aPoints[4], &aRotated[0], Rot); - Rotate(&pQuad[j].m_aPoints[4], &aRotated[1], Rot); - Rotate(&pQuad[j].m_aPoints[4], &aRotated[2], Rot); - Rotate(&pQuad[j].m_aPoints[4], &aRotated[3], Rot); + Rotate(&lQuads[j].m_aPoints[4], &aRotated[0], Rot); + Rotate(&lQuads[j].m_aPoints[4], &aRotated[1], Rot); + Rotate(&lQuads[j].m_aPoints[4], &aRotated[2], Rot); + Rotate(&lQuads[j].m_aPoints[4], &aRotated[3], Rot); } //Set Texture Coords Graphics()->QuadsSetSubsetFree( - fx2f(pQuad[j].m_aTexcoords[0].x), fx2f(pQuad[j].m_aTexcoords[0].y), - fx2f(pQuad[j].m_aTexcoords[1].x), fx2f(pQuad[j].m_aTexcoords[1].y), - fx2f(pQuad[j].m_aTexcoords[2].x), fx2f(pQuad[j].m_aTexcoords[2].y), - fx2f(pQuad[j].m_aTexcoords[3].x), fx2f(pQuad[j].m_aTexcoords[3].y) + fx2f(lQuads[j].m_aTexcoords[0].x), fx2f(lQuads[j].m_aTexcoords[0].y), + fx2f(lQuads[j].m_aTexcoords[1].x), fx2f(lQuads[j].m_aTexcoords[1].y), + fx2f(lQuads[j].m_aTexcoords[2].x), fx2f(lQuads[j].m_aTexcoords[2].y), + fx2f(lQuads[j].m_aTexcoords[3].x), fx2f(lQuads[j].m_aTexcoords[3].y) ); //Set Quad Coords & Draw @@ -1518,24 +1520,14 @@ void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Num, int TexID) continue; //QuadParams - CPoint *pPoints = pQuad[j].m_aPoints; for(int i = 0; i < apEnvelope[j]->m_lPoints.size()-1; i++) - { - float OffsetX = fx2f(apEnvelope[j]->m_lPoints[i].m_aValues[0]); - float OffsetY = fx2f(apEnvelope[j]->m_lPoints[i].m_aValues[1]); - vec2 Pos0 = vec2(fx2f(pPoints[4].x)+OffsetX, fx2f(pPoints[4].y)+OffsetY); - - OffsetX = fx2f(apEnvelope[j]->m_lPoints[i+1].m_aValues[0]); - OffsetY = fx2f(apEnvelope[j]->m_lPoints[i+1].m_aValues[1]); - vec2 Pos1 = vec2(fx2f(pPoints[4].x)+OffsetX, fx2f(pPoints[4].y)+OffsetY); - - DoQuadEnvPoint(&pQuad[j], j, i); - } + DoQuadEnvPoint(&lQuads[j], j, i); } Graphics()->QuadsEnd(); + delete[] apEnvelope; } -void CEditor::DoQuadEnvPoint(CQuad *pQuad, int QIndex, int PIndex) +void CEditor::DoQuadEnvPoint(const CQuad *pQuad, int QIndex, int PIndex) { enum { @@ -2128,12 +2120,7 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) if(pLayer->m_Image >= 0 && pLayer->m_Image < m_Map.m_lImages.size()) TexID = m_Map.m_lImages[pLayer->m_Image]->m_TexID; - /*for(int i = 0; i < pLayer->m_lQuads.size(); i++) - { - if((m_ShowEnvelopePreview == 1 && pLayer->m_lQuads[i].m_PosEnv == m_SelectedEnvelope) || m_ShowEnvelopePreview == 2) - DoQuadEnvelopes(&pLayer->m_lQuads[i], i, TexID); - }*/ - DoQuadEnvelopes(&pLayer->m_lQuads[0], pLayer->m_lQuads.size(), TexID); + DoQuadEnvelopes(pLayer->m_lQuads, TexID); m_ShowEnvelopePreview = 0; } diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 2807d35c..19a8752e 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -761,8 +761,8 @@ public: vec4 ButtonColorMul(const void *pID); - void DoQuadEnvelopes(CQuad *pQuad, int Num, int TexID = -1); - void DoQuadEnvPoint(CQuad *pQuad, int QIndex, int pIndex); + void DoQuadEnvelopes(const array &m_lQuads, int TexID = -1); + void DoQuadEnvPoint(const CQuad *pQuad, int QIndex, int pIndex); void DoQuadPoint(CQuad *pQuad, int QuadIndex, int v); void DoMapEditor(CUIRect View, CUIRect Toolbar); -- cgit 1.4.1 From 0e92dd560300a0b255b5c173e715f2714e7c1765 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Feb 2013 18:55:55 +0100 Subject: fixed some merge problems --- src/engine/client/graphics.cpp | 7 +------ src/engine/client/graphics.h | 2 +- src/engine/client/graphics_threaded.cpp | 2 +- src/game/editor/editor.cpp | 4 ++-- src/game/server/gamemodes/ctf.cpp | 2 +- src/versionsrv/versionsrv.cpp | 1 + 6 files changed, 7 insertions(+), 11 deletions(-) (limited to 'src/game') diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index 314669e2..3168903d 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -700,13 +700,10 @@ void CGraphics_OpenGL::QuadsDrawFreeform(const CFreeformItem *pArray, int Num) AddVertices(4*Num); } -void CGraphics_OpenGL::QuadsText(float x, float y, float Size, float r, float g, float b, float a, const char *pText) +void CGraphics_OpenGL::QuadsText(float x, float y, float Size, const char *pText) { float StartX = x; - QuadsBegin(); - SetColor(r,g,b,a); - while(*pText) { char c = *pText; @@ -730,8 +727,6 @@ void CGraphics_OpenGL::QuadsText(float x, float y, float Size, float r, float g, x += Size/2; } } - - QuadsEnd(); } int CGraphics_OpenGL::Init() diff --git a/src/engine/client/graphics.h b/src/engine/client/graphics.h index fdd83aa7..670c22b4 100644 --- a/src/engine/client/graphics.h +++ b/src/engine/client/graphics.h @@ -119,7 +119,7 @@ public: virtual void QuadsDraw(CQuadItem *pArray, int Num); virtual void QuadsDrawTL(const CQuadItem *pArray, int Num); virtual void QuadsDrawFreeform(const CFreeformItem *pArray, int Num); - virtual void QuadsText(float x, float y, float Size, float r, float g, float b, float a, const char *pText); + virtual void QuadsText(float x, float y, float Size, const char *pText); virtual int Init(); }; diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 0357c41a..e34b7259 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -277,7 +277,7 @@ int CGraphics_Threaded::UnloadTexture(int Index) Cmd.m_Slot = Index; m_pCommandBuffer->AddCommand(Cmd); - m_aTextures[Index] = m_FirstFreeTexture; + m_aTextureIndices[Index] = m_FirstFreeTexture; m_FirstFreeTexture = Index; return 0; } diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index ccd1757f..28a4eda9 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1449,7 +1449,7 @@ void CEditor::DoQuadEnvelopes(const array &lQuads, int TexID) Graphics()->LinesEnd(); //Draw Quads - Graphics()->TextureSet(Texture); + Graphics()->TextureSet(TexID); Graphics()->QuadsBegin(); for(int j = 0; j < Num; j++) @@ -1510,7 +1510,7 @@ void CEditor::DoQuadEnvelopes(const array &lQuads, int TexID) } } Graphics()->QuadsEnd(); - Graphics()->TextureClear(); + Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); // Draw QuadPoints diff --git a/src/game/server/gamemodes/ctf.cpp b/src/game/server/gamemodes/ctf.cpp index 9e45c1fe..140dadf9 100644 --- a/src/game/server/gamemodes/ctf.cpp +++ b/src/game/server/gamemodes/ctf.cpp @@ -98,7 +98,7 @@ bool CGameControllerCTF::CanBeMovedOnBalance(int ClientID) for(int fi = 0; fi < 2; fi++) { CFlag *F = m_apFlags[fi]; - if(F->m_pCarryingCharacter == Character) + if(F && F->m_pCarryingCharacter == Character) return false; } } diff --git a/src/versionsrv/versionsrv.cpp b/src/versionsrv/versionsrv.cpp index da55e717..9d6e2960 100644 --- a/src/versionsrv/versionsrv.cpp +++ b/src/versionsrv/versionsrv.cpp @@ -7,6 +7,7 @@ #include #include "versionsrv.h" +#include "mapversions.h" enum { MAX_MAPS_PER_PACKET=48, -- cgit 1.4.1 From f010791231c95eed49c63ce3f2e6809b8c932f27 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Feb 2013 19:43:09 +0100 Subject: added options for the threaded stuff in the menu and set version --- src/game/client/components/menus_settings.cpp | 27 +++++++++++++++++++++++++-- src/game/version.h | 4 ++-- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'src/game') diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 467ef500..b2434d91 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -619,6 +619,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) static int s_GfxFsaaSamples = g_Config.m_GfxFsaaSamples; static int s_GfxTextureQuality = g_Config.m_GfxTextureQuality; static int s_GfxTextureCompression = g_Config.m_GfxTextureCompression; + static int s_GfxThreaded = g_Config.m_GfxThreaded; CUIRect ModeList; MainView.VSplitLeft(300.0f, &MainView, &ModeList); @@ -699,8 +700,25 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) g_Config.m_GfxFsaaSamples = (g_Config.m_GfxFsaaSamples+1)%17; CheckSettings = true; } + + MainView.HSplitTop(20.0f, &Button, &MainView); + if(DoButton_CheckBox(&g_Config.m_GfxThreaded, Localize("Threaded rendering"), g_Config.m_GfxThreaded, &Button)) + { + g_Config.m_GfxThreaded ^= 1; + CheckSettings = true; + } - MainView.HSplitTop(40.0f, &Button, &MainView); + MainView.HSplitTop(20.0f, &Button, &MainView); + if(g_Config.m_GfxThreaded) + { + Button.VSplitLeft(20.0f, 0, &Button); + if(DoButton_CheckBox(&g_Config.m_GfxAsyncRender, Localize("Handle rendering async from updates"), g_Config.m_GfxAsyncRender, &Button)) + { + g_Config.m_GfxAsyncRender ^= 1; + CheckSettings = true; + } + } + MainView.HSplitTop(20.0f, &Button, &MainView); if(DoButton_CheckBox(&g_Config.m_GfxTextureQuality, Localize("Quality Textures"), g_Config.m_GfxTextureQuality, &Button)) { @@ -730,7 +748,8 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) s_GfxVsync == g_Config.m_GfxVsync && s_GfxFsaaSamples == g_Config.m_GfxFsaaSamples && s_GfxTextureQuality == g_Config.m_GfxTextureQuality && - s_GfxTextureCompression == g_Config.m_GfxTextureCompression) + s_GfxTextureCompression == g_Config.m_GfxTextureCompression && + s_GfxThreaded == g_Config.m_GfxThreaded) m_NeedRestartGraphics = false; else m_NeedRestartGraphics = true; @@ -807,6 +826,10 @@ void CMenus::RenderSettingsSound(CUIRect MainView) if(DoButton_CheckBox(&g_Config.m_SndNonactiveMute, Localize("Mute when not active"), g_Config.m_SndNonactiveMute, &Button)) g_Config.m_SndNonactiveMute ^= 1; + MainView.HSplitTop(20.0f, &Button, &MainView); + if(DoButton_CheckBox(&g_Config.m_ClThreadsoundloading, Localize("Threaded sound loading"), g_Config.m_ClThreadsoundloading, &Button)) + g_Config.m_ClThreadsoundloading ^= 1; + // sample rate box { char aBuf[64]; diff --git a/src/game/version.h b/src/game/version.h index 3d909e36..ee41dbe8 100644 --- a/src/game/version.h +++ b/src/game/version.h @@ -3,7 +3,7 @@ #ifndef GAME_VERSION_H #define GAME_VERSION_H #include "generated/nethash.cpp" -#define GAME_VERSION "0.6 trunk" +#define GAME_VERSION "0.6.2" #define GAME_NETVERSION "0.6 " GAME_NETVERSION_HASH -static const char GAME_RELEASE_VERSION[8] = {'0', '.', '6', '1', 0}; +static const char GAME_RELEASE_VERSION[8] = {'0', '.', '6', '2', 0}; #endif -- cgit 1.4.1 From 2f1389e5cd45722863b877adf7031c585dfcf44b Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 25 Feb 2013 22:31:30 +0100 Subject: fixed version string of the versionserver --- src/game/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/version.h b/src/game/version.h index ee41dbe8..76d95dd0 100644 --- a/src/game/version.h +++ b/src/game/version.h @@ -5,5 +5,5 @@ #include "generated/nethash.cpp" #define GAME_VERSION "0.6.2" #define GAME_NETVERSION "0.6 " GAME_NETVERSION_HASH -static const char GAME_RELEASE_VERSION[8] = {'0', '.', '6', '2', 0}; +static const char GAME_RELEASE_VERSION[8] = {'0', '.', '6', '.', '2', 0}; #endif -- cgit 1.4.1