From b4ed006f836e8b15f27352a8403b7cdeb7576c5b Mon Sep 17 00:00:00 2001 From: Teetime Date: Mon, 13 Feb 2012 23:22:40 +0100 Subject: [PATCH 01/84] fix for saving bans in a file --- src/engine/shared/netban.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/shared/netban.cpp b/src/engine/shared/netban.cpp index ee3b057e1..d26d64d4e 100644 --- a/src/engine/shared/netban.cpp +++ b/src/engine/shared/netban.cpp @@ -583,7 +583,7 @@ void CNetBan::ConBansSave(IConsole::IResult *pResult, void *pUser) { int Min = pBan->m_Info.m_Expires>-1 ? (pBan->m_Info.m_Expires-Now+59)/60 : -1; net_addr_str(&pBan->m_Data, aAddrStr1, sizeof(aAddrStr1), false); - str_format(aBuf, sizeof(aBuf), "ban_ip %s %i %s", aAddrStr1, Min, pBan->m_Info.m_aReason); + str_format(aBuf, sizeof(aBuf), "ban %s %i %s", aAddrStr1, Min, pBan->m_Info.m_aReason); io_write(File, aBuf, str_length(aBuf)); io_write_newline(File); } @@ -592,7 +592,7 @@ void CNetBan::ConBansSave(IConsole::IResult *pResult, void *pUser) int Min = pBan->m_Info.m_Expires>-1 ? (pBan->m_Info.m_Expires-Now+59)/60 : -1; net_addr_str(&pBan->m_Data.m_LB, aAddrStr1, sizeof(aAddrStr1), false); net_addr_str(&pBan->m_Data.m_UB, aAddrStr2, sizeof(aAddrStr2), false); - str_format(aBuf, sizeof(aBuf), "ban_range %s %i %s", aAddrStr1, aAddrStr2, Min, pBan->m_Info.m_aReason); + str_format(aBuf, sizeof(aBuf), "ban_range %s %s %i %s", aAddrStr1, aAddrStr2, Min, pBan->m_Info.m_aReason); io_write(File, aBuf, str_length(aBuf)); io_write_newline(File); } From e291a60e7e5c52e8a6d0117fd2ef3b38521cb81c Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 15 Feb 2012 01:40:40 +0100 Subject: [PATCH 02/84] fixed map initialisation. Closes #64 --- src/game/client/render.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/game/client/render.cpp b/src/game/client/render.cpp index 278ed51ac..715891911 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; } } } From 85271f2e7e0c78167288676982366eaafbe4368b Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Feb 2013 17:14:55 +0100 Subject: [PATCH 03/84] increased recv buffer size on windows --- src/base/system.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/base/system.c b/src/base/system.c index ed0f41ec4..7f98efe1a 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -903,6 +903,7 @@ NETSOCKET net_udp_create(NETADDR bindaddr) NETSOCKET sock = invalid_socket; NETADDR tmpbindaddr = bindaddr; int broadcast = 1; + int recvsize = 65536; if(bindaddr.type&NETTYPE_IPV4) { @@ -917,13 +918,13 @@ NETSOCKET net_udp_create(NETADDR bindaddr) { sock.type |= NETTYPE_IPV4; sock.ipv4sock = socket; + + /* set boardcast */ + setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)); + + /* set receive buffer size */ + setsockopt(socket, SOL_SOCKET, SO_RCVBUF, (char*)&recvsize, sizeof(recvsize)); } - - /* set non-blocking */ - net_set_non_blocking(sock); - - /* set boardcast */ - setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)); } if(bindaddr.type&NETTYPE_IPV6) @@ -939,15 +940,18 @@ NETSOCKET net_udp_create(NETADDR bindaddr) { sock.type |= NETTYPE_IPV6; sock.ipv6sock = socket; + + /* set boardcast */ + setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)); + + /* set receive buffer size */ + setsockopt(socket, SOL_SOCKET, SO_RCVBUF, (char*)&recvsize, sizeof(recvsize)); } - - /* set non-blocking */ - net_set_non_blocking(sock); - - /* set boardcast */ - setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)); } + /* set non-blocking */ + net_set_non_blocking(sock); + /* return */ return sock; } From ffa93a007ced9553cc35ce8372bd8ab59039e6f9 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Feb 2013 17:24:12 +0100 Subject: [PATCH 04/84] fixed a bug with spectating a player --- src/game/server/player.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 75c2c1c6a..4b37385f3 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); From 2f86ad3c4baab2709f224f0ff7cf9ca46d4b1f52 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 4 Mar 2012 12:46:38 +0100 Subject: [PATCH 05/84] fixed chat ignore feature --- src/game/client/components/menus_ingame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index a9cf35e9f..084520d9b 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)) From 38256d0d45ff929796cc85d0dfcb39242290f3ba Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 4 Mar 2012 12:46:46 +0100 Subject: [PATCH 06/84] skip screenshot when window isn't active. Closes #931 --- src/engine/client/graphics.cpp | 3 ++- src/engine/client/graphics_threaded.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index 2111703e1..ae0fcade0 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -929,7 +929,8 @@ void CGraphics_SDL::Swap() { if(m_DoScreenshot) { - ScreenshotDirect(m_aScreenshotName); + if(WindowActive()) + ScreenshotDirect(m_aScreenshotName); m_DoScreenshot = false; } diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index b19e8a836..846f03698 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -843,7 +843,8 @@ void CGraphics_Threaded::Swap() // TODO: screenshot support if(m_DoScreenshot) { - ScreenshotDirect(m_aScreenshotName); + if(WindowActive()) + ScreenshotDirect(m_aScreenshotName); m_DoScreenshot = false; } From 2a4af1573b385f1c30ce376eee1385581d42beab Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 4 Mar 2012 12:46:55 +0100 Subject: [PATCH 07/84] auto adjust the screen resolution on first start. Closes #921 --- src/engine/client/backend_sdl.cpp | 11 +++++++++-- src/engine/client/backend_sdl.h | 2 +- src/engine/client/graphics.cpp | 13 ++++++++++--- src/engine/client/graphics_threaded.cpp | 2 +- src/engine/client/graphics_threaded.h | 2 +- src/engine/shared/config_variables.h | 4 ++-- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index e7975aca4..b04b729eb 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -388,7 +388,7 @@ void CCommandProcessor_SDL_OpenGL::RunBuffer(CCommandBuffer *pBuffer) // ------------ CGraphicsBackend_SDL_OpenGL -int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int Width, int Height, int FsaaSamples, int Flags) +int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags) { if(!SDL_WasInit(SDL_INIT_VIDEO)) { @@ -407,6 +407,13 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int Width, int Height, const SDL_VideoInfo *pInfo = SDL_GetVideoInfo(); SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); // prevent stuck mouse cursor sdl-bug when loosing fullscreen focus in windows + // use current resolution as default + if(*Width == 0 || *Height == 0) + { + *Width = pInfo->current_w; + *Height = pInfo->current_h; + } + // set flags int SdlFlags = SDL_OPENGL; if(Flags&IGraphicsBackend::INITFLAG_RESIZABLE) @@ -442,7 +449,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int Width, int Height, SDL_WM_SetCaption(pName, pName); // create window - m_pScreenSurface = SDL_SetVideoMode(Width, Height, 0, SdlFlags); + m_pScreenSurface = SDL_SetVideoMode(*Width, *Height, 0, SdlFlags); if(!m_pScreenSurface) { dbg_msg("gfx", "unable to set video mode: %s", SDL_GetError()); diff --git a/src/engine/client/backend_sdl.h b/src/engine/client/backend_sdl.h index c6c2255ae..305453f24 100644 --- a/src/engine/client/backend_sdl.h +++ b/src/engine/client/backend_sdl.h @@ -188,7 +188,7 @@ class CGraphicsBackend_SDL_OpenGL : public CGraphicsBackend_Threaded ICommandProcessor *m_pProcessor; SGLContext m_GLContext; public: - virtual int Init(const char *pName, int Width, int Height, int FsaaSamples, int Flags); + virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags); virtual int Shutdown(); virtual void Minimize(); diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index ae0fcade0..bf432356d 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -761,12 +761,19 @@ int CGraphics_OpenGL::Init() int CGraphics_SDL::TryInit() { - m_ScreenWidth = g_Config.m_GfxScreenWidth; - m_ScreenHeight = g_Config.m_GfxScreenHeight; - const SDL_VideoInfo *pInfo = SDL_GetVideoInfo(); SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); // prevent stuck mouse cursor sdl-bug when loosing fullscreen focus in windows + // use current resolution as default + if(g_Config.m_GfxScreenWidth == 0 || g_Config.m_GfxScreenHeight == 0) + { + g_Config.m_GfxScreenWidth = pInfo->current_w; + g_Config.m_GfxScreenHeight = pInfo->current_h; + } + + m_ScreenWidth = g_Config.m_GfxScreenWidth; + m_ScreenHeight = g_Config.m_GfxScreenHeight; + // set flags int Flags = SDL_OPENGL; if(g_Config.m_DbgResizable) diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 846f03698..0c99ebf7a 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -716,7 +716,7 @@ int CGraphics_Threaded::IssueInit() if(g_Config.m_GfxVsync) Flags |= IGraphicsBackend::INITFLAG_VSYNC; if(g_Config.m_DbgResizable) Flags |= IGraphicsBackend::INITFLAG_RESIZABLE; - return m_pBackend->Init("Teeworlds", g_Config.m_GfxScreenWidth, g_Config.m_GfxScreenHeight, g_Config.m_GfxFsaaSamples, Flags); + return m_pBackend->Init("Teeworlds", &g_Config.m_GfxScreenWidth, &g_Config.m_GfxScreenHeight, g_Config.m_GfxFsaaSamples, Flags); } int CGraphics_Threaded::InitWindow() diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index f90f818d9..d3ccc61e0 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -302,7 +302,7 @@ public: INITFLAG_RESIZABLE = 4, }; - virtual int Init(const char *pName, int Width, int Height, int FsaaSamples, int Flags) = 0; + virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags) = 0; virtual int Shutdown() = 0; virtual void Minimize() = 0; diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index ac913162a..2bee031d0 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -57,8 +57,8 @@ MACRO_CONFIG_INT(SndDevice, snd_device, -1, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, " MACRO_CONFIG_INT(SndNonactiveMute, snd_nonactive_mute, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "") -MACRO_CONFIG_INT(GfxScreenWidth, gfx_screen_width, 800, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Screen resolution width") -MACRO_CONFIG_INT(GfxScreenHeight, gfx_screen_height, 600, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Screen resolution height") +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(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)") From fa85cede5336c399f9b12efde169bad6f6842d8d Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 4 Mar 2012 12:47:02 +0100 Subject: [PATCH 08/84] reset rcon AuthTries on logout. Closes #941 --- src/engine/server/server.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index a231d1e8d..f7b54df56 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1544,6 +1544,7 @@ void CServer::ConLogout(IConsole::IResult *pResult, void *pUser) pServer->SendMsgEx(&Msg, MSGFLAG_VITAL, pServer->m_RconClientID, true); pServer->m_aClients[pServer->m_RconClientID].m_Authed = AUTHED_NO; + pServer->m_aClients[pServer->m_RconClientID].m_AuthTries = 0; pServer->m_aClients[pServer->m_RconClientID].m_pRconCmdToSend = 0; pServer->SendRconLine(pServer->m_RconClientID, "Logout successful."); char aBuf[32]; From ffd89938d7caebe2ecd7bf18d00283e6aadea981 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 4 Mar 2012 12:47:09 +0100 Subject: [PATCH 09/84] fixed registering of ban commands. Closes #942 --- src/engine/server/server.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index f7b54df56..34eaddc44 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1255,10 +1255,6 @@ void CServer::InitRegister(CNetServer *pNetServer, IEngineMasterServer *pMasterS int CServer::Run() { - m_pGameServer = Kernel()->RequestInterface(); - m_pMap = Kernel()->RequestInterface(); - m_pStorage = Kernel()->RequestInterface(); - // m_PrintCBIndex = Console()->RegisterPrintCallback(g_Config.m_ConsoleOutputLevel, SendRconLineAuthed, this); @@ -1291,7 +1287,6 @@ int CServer::Run() m_NetServer.SetCallbacks(NewClientCallback, DelClientCallback, this); - m_ServerBan.Init(Console(), Storage(), this); m_Econ.Init(Console(), &m_ServerBan); char aBuf[256]; @@ -1609,7 +1604,11 @@ void CServer::ConchainConsoleOutputLevelUpdate(IConsole::IResult *pResult, void void CServer::RegisterCommands() { m_pConsole = Kernel()->RequestInterface(); + m_pGameServer = Kernel()->RequestInterface(); + m_pMap = Kernel()->RequestInterface(); + m_pStorage = Kernel()->RequestInterface(); + // register console commands Console()->Register("kick", "i?r", CFGFLAG_SERVER, ConKick, this, "Kick player with specified id for any reason"); Console()->Register("status", "", CFGFLAG_SERVER, ConStatus, this, "List players"); Console()->Register("shutdown", "", CFGFLAG_SERVER, ConShutdown, this, "Shut down"); @@ -1626,6 +1625,10 @@ void CServer::RegisterCommands() Console()->Chain("sv_max_clients_per_ip", ConchainMaxclientsperipUpdate, this); Console()->Chain("mod_command", ConchainModCommandUpdate, this); Console()->Chain("console_output_level", ConchainConsoleOutputLevelUpdate, this); + + // register console commands in sub parts + m_ServerBan.Init(Console(), Storage(), this); + m_pGameServer->OnConsoleInit(); } @@ -1706,7 +1709,6 @@ int main(int argc, const char **argv) // ignore_convention // register all console commands pServer->RegisterCommands(); - pGameServer->OnConsoleInit(); // execute autoexec file pConsole->ExecuteFile("autoexec.cfg"); From 13d06e45ac14d5f584462d0611f85a4e1dafcf17 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 4 Mar 2012 12:47:16 +0100 Subject: [PATCH 10/84] fixed used nettype in server browser and try to use ipv4 and ipv6 socket when using a bindaddr. Closes #940 --- src/engine/client/client.cpp | 9 +++++++-- src/engine/client/serverbrowser.cpp | 2 +- src/engine/server/server.cpp | 1 + src/engine/shared/econ.cpp | 4 ++++ src/engine/shared/network.h | 2 +- src/mastersrv/mastersrv.cpp | 4 ++++ 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index d5da647bf..6d1d8f4f8 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1746,14 +1746,19 @@ void CClient::Run() // open socket { NETADDR BindAddr; - if(g_Config.m_Bindaddr[0] == 0 || net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) != 0) + if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) == 0) + { + // got bindaddr + BindAddr.type = NETTYPE_ALL; + } + else { mem_zero(&BindAddr, sizeof(BindAddr)); BindAddr.type = NETTYPE_ALL; } if(!m_NetClient.Open(BindAddr, 0)) { - dbg_msg("client", "couldn't start network"); + dbg_msg("client", "couldn't open socket"); return; } } diff --git a/src/engine/client/serverbrowser.cpp b/src/engine/client/serverbrowser.cpp index 4dda9da98..588194ea9 100644 --- a/src/engine/client/serverbrowser.cpp +++ b/src/engine/client/serverbrowser.cpp @@ -495,7 +495,7 @@ void CServerBrowser::Refresh(int Type) /* do the broadcast version */ Packet.m_ClientID = -1; mem_zero(&Packet, sizeof(Packet)); - Packet.m_Address.type = NETTYPE_ALL|NETTYPE_LINK_BROADCAST; + Packet.m_Address.type = m_pNetClient->NetType()|NETTYPE_LINK_BROADCAST; Packet.m_Flags = NETSENDFLAG_CONNLESS; Packet.m_DataSize = sizeof(Buffer); Packet.m_pData = Buffer; diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 34eaddc44..704d4e378 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1270,6 +1270,7 @@ int CServer::Run() if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) == 0) { // sweet! + BindAddr.type = NETTYPE_ALL; BindAddr.port = g_Config.m_SvPort; } else diff --git a/src/engine/shared/econ.cpp b/src/engine/shared/econ.cpp index eb7df872f..e0df8635b 100644 --- a/src/engine/shared/econ.cpp +++ b/src/engine/shared/econ.cpp @@ -75,7 +75,11 @@ void CEcon::Init(IConsole *pConsole, CNetBan *pNetBan) NETADDR BindAddr; if(g_Config.m_EcBindaddr[0] && net_host_lookup(g_Config.m_EcBindaddr, &BindAddr, NETTYPE_ALL) == 0) + { + // got bindaddr + BindAddr.type = NETTYPE_ALL; BindAddr.port = g_Config.m_EcPort; + } else { mem_zero(&BindAddr, sizeof(BindAddr)); diff --git a/src/engine/shared/network.h b/src/engine/shared/network.h index dd43389ec..d633c3fc5 100644 --- a/src/engine/shared/network.h +++ b/src/engine/shared/network.h @@ -353,7 +353,7 @@ public: int ResetErrorString(); // error and state - int NetType() { return m_Socket.type; } + int NetType() const { return m_Socket.type; } int State(); int GotProblems(); const char *ErrorString(); diff --git a/src/mastersrv/mastersrv.cpp b/src/mastersrv/mastersrv.cpp index c88a9e78c..922577ca2 100644 --- a/src/mastersrv/mastersrv.cpp +++ b/src/mastersrv/mastersrv.cpp @@ -348,7 +348,11 @@ int main(int argc, const char **argv) // ignore_convention m_pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) == 0) + { + // got bindaddr + BindAddr.type = NETTYPE_ALL; BindAddr.port = MASTERSERVER_PORT; + } else { mem_zero(&BindAddr, sizeof(BindAddr)); From 5de2763f827d04eef2b50ddf8a228db8591ec310 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 01:04:12 +0200 Subject: [PATCH 11/84] skip auto screenshot when the editor is active. #931 --- src/game/client/gameclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 86fb5ad0f..4b90d9b1a 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(); } From 76d7569e15b2b99faa54371007196afaba5e3dbb Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 01:09:49 +0200 Subject: [PATCH 12/84] 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(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 340b9da18..78b90e933 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; From 32c8dd6cf5c8bdcbd08c4f4cf1bd97c17d0167d9 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 01:11:32 +0200 Subject: [PATCH 13/84] increased time for client info resend to prevent possible overlap --- src/game/client/gameclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 4b90d9b1a..f9b8b671a 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) || From 0036a07ce7bb34c86f25e7b1c4a28a621c8911fe Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 01:13:51 +0200 Subject: [PATCH 14/84] 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(-) diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index 675d67705..13dbc8a26 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; From 0e40ab434a2416b685027f401251b28b0e935efc Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Feb 2013 17:31:57 +0100 Subject: [PATCH 15/84] fixed a check --- src/engine/shared/netban.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/shared/netban.cpp b/src/engine/shared/netban.cpp index d26d64d4e..707b709b4 100644 --- a/src/engine/shared/netban.cpp +++ b/src/engine/shared/netban.cpp @@ -243,7 +243,7 @@ typename CNetBan::CBan *CNetBan::CBanPool::Get(int Index) const template void CNetBan::MakeBanInfo(const CBan *pBan, char *pBuf, unsigned BuffSize, int Type) const { - if(pBan == 0) + if(pBan == 0 || pBuf == 0) { if(BuffSize > 0) pBuf[0] = 0; From 4d36c0f77e03475b4057f2de3383105283653230 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 01:50:16 +0200 Subject: [PATCH 16/84] 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(-) diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 553195b11..139937833 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); From f1fc3337f5cc5ac3b89da80a1fdff5251f130cb5 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 21:39:49 +0200 Subject: [PATCH 17/84] prevent that the server uses close messages from clients. Closes #950 --- src/engine/shared/network.h | 3 ++- src/engine/shared/network_client.cpp | 2 +- src/engine/shared/network_conn.cpp | 30 ++++++++++++++++------------ src/engine/shared/network_server.cpp | 2 +- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/engine/shared/network.h b/src/engine/shared/network.h index d633c3fc5..fbe4d3919 100644 --- a/src/engine/shared/network.h +++ b/src/engine/shared/network.h @@ -140,6 +140,7 @@ private: int m_Token; int m_RemoteClosed; + bool m_BlockCloseMsg; TStaticRingBuffer m_Buffer; @@ -167,7 +168,7 @@ private: void Resend(); public: - void Init(NETSOCKET Socket); + void Init(NETSOCKET Socket, bool BlockCloseMsg); int Connect(NETADDR *pAddr); void Disconnect(const char *pReason); diff --git a/src/engine/shared/network_client.cpp b/src/engine/shared/network_client.cpp index 2c0356061..8e0e29106 100644 --- a/src/engine/shared/network_client.cpp +++ b/src/engine/shared/network_client.cpp @@ -16,7 +16,7 @@ bool CNetClient::Open(NETADDR BindAddr, int Flags) // init m_Socket = Socket; - m_Connection.Init(m_Socket); + m_Connection.Init(m_Socket, false); return true; } diff --git a/src/engine/shared/network_conn.cpp b/src/engine/shared/network_conn.cpp index 6531f5aab..32fa159fa 100644 --- a/src/engine/shared/network_conn.cpp +++ b/src/engine/shared/network_conn.cpp @@ -37,12 +37,13 @@ void CNetConnection::SetError(const char *pString) str_copy(m_ErrorString, pString, sizeof(m_ErrorString)); } -void CNetConnection::Init(NETSOCKET Socket) +void CNetConnection::Init(NETSOCKET Socket, bool BlockCloseMsg) { Reset(); ResetStats(); m_Socket = Socket; + m_BlockCloseMsg = BlockCloseMsg; mem_zero(m_ErrorString, sizeof(m_ErrorString)); } @@ -213,21 +214,24 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr) m_State = NET_CONNSTATE_ERROR; m_RemoteClosed = 1; - if(pPacket->m_DataSize) + if(!m_BlockCloseMsg) { - // make sure to sanitize the error string form the other party - char Str[128]; - if(pPacket->m_DataSize < 128) - str_copy(Str, (char *)pPacket->m_aChunkData, pPacket->m_DataSize); - else - str_copy(Str, (char *)pPacket->m_aChunkData, sizeof(Str)); - str_sanitize_strong(Str); + if(pPacket->m_DataSize) + { + // make sure to sanitize the error string form the other party + char Str[128]; + if(pPacket->m_DataSize < 128) + str_copy(Str, (char *)pPacket->m_aChunkData, pPacket->m_DataSize); + else + str_copy(Str, (char *)pPacket->m_aChunkData, sizeof(Str)); + str_sanitize_strong(Str); - // set the error string - SetError(Str); + // set the error string + SetError(Str); + } + else + SetError("No reason given"); } - else - SetError("No reason given"); if(g_Config.m_Debug) dbg_msg("conn", "closed reason='%s'", ErrorString()); diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index 1264a4a5a..add51c9bb 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -30,7 +30,7 @@ bool CNetServer::Open(NETADDR BindAddr, CNetBan *pNetBan, int MaxClients, int Ma m_MaxClientsPerIP = MaxClientsPerIP; for(int i = 0; i < NET_MAX_CLIENTS; i++) - m_aSlots[i].m_Connection.Init(m_Socket); + m_aSlots[i].m_Connection.Init(m_Socket, true); return true; } From 0bce750a33576a48b11defb12f73a671c3de5c10 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 21:50:25 +0200 Subject: [PATCH 18/84] 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(-) diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index a9c434b38..b560b8cd2 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; From 86708818e9012a59cb00f6d836000a5c72850195 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 22:11:41 +0200 Subject: [PATCH 19/84] 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(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index d27307f4c..8d0bdb16f 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; From 14cd83de10e5725db6f159a9cfe8d0c8d7bd9b59 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 20 Apr 2012 22:20:11 +0200 Subject: [PATCH 20/84] fixed ban range check to make sure the whole ip matches and not just rely on the hash. Closes #946 --- src/engine/shared/netban.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/shared/netban.h b/src/engine/shared/netban.h index 447a838d1..6d690164d 100644 --- a/src/engine/shared/netban.h +++ b/src/engine/shared/netban.h @@ -34,7 +34,7 @@ protected: bool NetMatch(const CNetRange *pRange, const NETADDR *pAddr, int Start, int Length) const { - return pRange->m_LB.type == pAddr->type && + return pRange->m_LB.type == pAddr->type && (Start == 0 || mem_comp(&pRange->m_LB.ip[0], &pAddr->ip[0], Start) == 0) && mem_comp(&pRange->m_LB.ip[Start], &pAddr->ip[Start], Length-Start) <= 0 && mem_comp(&pRange->m_UB.ip[Start], &pAddr->ip[Start], Length-Start) >= 0; } From 86cd0cefd7cdefd7443cb9602b3c834fa85134e1 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 21 Apr 2012 00:23:48 +0200 Subject: [PATCH 21/84] 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(-) diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index af06fc118..d838ef291 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 d16d56cdf..01bf5351f 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); From 7be3c2e634b04008c1df3b9ee04c09a13f753794 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 21 Apr 2012 18:20:41 +0200 Subject: [PATCH 22/84] fixed resetting the error string of a net connection. Closes #954 --- src/engine/shared/network_conn.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/shared/network_conn.cpp b/src/engine/shared/network_conn.cpp index 32fa159fa..6a63f82d0 100644 --- a/src/engine/shared/network_conn.cpp +++ b/src/engine/shared/network_conn.cpp @@ -25,6 +25,8 @@ void CNetConnection::Reset() m_Buffer.Init(); mem_zero(&m_Construct, sizeof(m_Construct)); + + mem_zero(m_ErrorString, sizeof(m_ErrorString)); } const char *CNetConnection::ErrorString() @@ -44,7 +46,6 @@ void CNetConnection::Init(NETSOCKET Socket, bool BlockCloseMsg) m_Socket = Socket; m_BlockCloseMsg = BlockCloseMsg; - mem_zero(m_ErrorString, sizeof(m_ErrorString)); } void CNetConnection::AckChunks(int Ack) @@ -168,7 +169,6 @@ int CNetConnection::Connect(NETADDR *pAddr) // init connection Reset(); m_PeerAddr = *pAddr; - mem_zero(m_ErrorString, sizeof(m_ErrorString)); m_State = NET_CONNSTATE_CONNECT; SendControl(NET_CTRLMSG_CONNECT, 0, 0); return 0; From 1a62770a5691157f83061eedd2e3ce7d3fa33f62 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 12 May 2012 12:13:09 +0200 Subject: [PATCH 23/84] fixed banning on the master server --- src/mastersrv/mastersrv.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mastersrv/mastersrv.cpp b/src/mastersrv/mastersrv.cpp index 922577ca2..1098123b4 100644 --- a/src/mastersrv/mastersrv.cpp +++ b/src/mastersrv/mastersrv.cpp @@ -372,6 +372,9 @@ int main(int argc, const char **argv) // ignore_convention return -1; } + // process pending commands + m_pConsole->StoreCommands(false); + dbg_msg("mastersrv", "started"); while(1) From b7e5bb54ad77545ae139115a1a64f9ebb7160006 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 10 Jun 2012 12:14:41 +0200 Subject: [PATCH 24/84] fixed semaphore on macosx --- src/base/system.c | 26 ++++++++++++++------------ src/base/system.h | 26 ++++++++++++++------------ src/base/tl/threading.h | 24 +++++++++++++++--------- src/engine/client/backend_sdl.h | 10 ++++++++++ src/engine/client/client.h | 2 -- src/engine/client/graphics.cpp | 14 ++++++++++++++ 6 files changed, 67 insertions(+), 35 deletions(-) diff --git a/src/base/system.c b/src/base/system.c index 7f98efe1a..1c4d3a484 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -505,18 +505,20 @@ void lock_release(LOCK lock) #endif } -#if defined(CONF_FAMILY_UNIX) -void semaphore_init(SEMAPHORE *sem) { sem_init(sem, 0, 0); } -void semaphore_wait(SEMAPHORE *sem) { sem_wait(sem); } -void semaphore_signal(SEMAPHORE *sem) { sem_post(sem); } -void semaphore_destroy(SEMAPHORE *sem) { sem_destroy(sem); } -#elif defined(CONF_FAMILY_WINDOWS) -void semaphore_init(SEMAPHORE *sem) { *sem = CreateSemaphore(0, 0, 10000, 0); } -void semaphore_wait(SEMAPHORE *sem) { WaitForSingleObject((HANDLE)*sem, 0L); } -void semaphore_signal(SEMAPHORE *sem) { ReleaseSemaphore((HANDLE)*sem, 1, NULL); } -void semaphore_destroy(SEMAPHORE *sem) { CloseHandle((HANDLE)*sem); } -#else - #error not implemented on this platform +#if !defined(CONF_PLATFORM_MACOSX) + #if defined(CONF_FAMILY_UNIX) + void semaphore_init(SEMAPHORE *sem) { sem_init(sem, 0, 0); } + void semaphore_wait(SEMAPHORE *sem) { sem_wait(sem); } + void semaphore_signal(SEMAPHORE *sem) { sem_post(sem); } + void semaphore_destroy(SEMAPHORE *sem) { sem_destroy(sem); } + #elif defined(CONF_FAMILY_WINDOWS) + void semaphore_init(SEMAPHORE *sem) { *sem = CreateSemaphore(0, 0, 10000, 0); } + void semaphore_wait(SEMAPHORE *sem) { WaitForSingleObject((HANDLE)*sem, 0L); } + void semaphore_signal(SEMAPHORE *sem) { ReleaseSemaphore((HANDLE)*sem, 1, NULL); } + void semaphore_destroy(SEMAPHORE *sem) { CloseHandle((HANDLE)*sem); } + #else + #error not implemented on this platform + #endif #endif diff --git a/src/base/system.h b/src/base/system.h index b3588dbf1..032cf7857 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -403,19 +403,21 @@ void lock_release(LOCK lock); /* Group: Semaphores */ -#if defined(CONF_FAMILY_UNIX) - #include - typedef sem_t SEMAPHORE; -#elif defined(CONF_FAMILY_WINDOWS) - typedef void* SEMAPHORE; -#else - #error missing sempahore implementation -#endif +#if !defined(CONF_PLATFORM_MACOSX) + #if defined(CONF_FAMILY_UNIX) + #include + typedef sem_t SEMAPHORE; + #elif defined(CONF_FAMILY_WINDOWS) + typedef void* SEMAPHORE; + #else + #error missing sempahore implementation + #endif -void semaphore_init(SEMAPHORE *sem); -void semaphore_wait(SEMAPHORE *sem); -void semaphore_signal(SEMAPHORE *sem); -void semaphore_destroy(SEMAPHORE *sem); + void semaphore_init(SEMAPHORE *sem); + void semaphore_wait(SEMAPHORE *sem); + void semaphore_signal(SEMAPHORE *sem); + void semaphore_destroy(SEMAPHORE *sem); +#endif /* Group: Timer */ #ifdef __GNUC__ diff --git a/src/base/tl/threading.h b/src/base/tl/threading.h index dbf788cdc..5caf8588b 100644 --- a/src/base/tl/threading.h +++ b/src/base/tl/threading.h @@ -58,15 +58,21 @@ #error missing atomic implementation for this compiler #endif -class semaphore -{ - SEMAPHORE sem; -public: - semaphore() { semaphore_init(&sem); } - ~semaphore() { semaphore_destroy(&sem); } - void wait() { semaphore_wait(&sem); } - void signal() { semaphore_signal(&sem); } -}; +#if defined(CONF_PLATFORM_MACOSX) + /* + use semaphore provided by SDL on macosx + */ +#else + class semaphore + { + SEMAPHORE sem; + public: + semaphore() { semaphore_init(&sem); } + ~semaphore() { semaphore_destroy(&sem); } + void wait() { semaphore_wait(&sem); } + void signal() { semaphore_signal(&sem); } + }; +#endif class lock { diff --git a/src/engine/client/backend_sdl.h b/src/engine/client/backend_sdl.h index 305453f24..2ef04a1f8 100644 --- a/src/engine/client/backend_sdl.h +++ b/src/engine/client/backend_sdl.h @@ -30,6 +30,16 @@ #include + class semaphore + { + SDL_sem *sem; + public: + semaphore() { sem = SDL_CreateSemaphore(0); } + ~semaphore() { SDL_DestroySemaphore(sem); } + void wait() { SDL_SemWait(sem); } + void signal() { SDL_SemPost(sem); } + }; + struct SGLContext { AGLContext m_Context; diff --git a/src/engine/client/client.h b/src/engine/client/client.h index d958b49ae..87e2bc701 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -175,8 +175,6 @@ class CClient : public IClient, public CDemoPlayer::IListner class CHostLookup m_VersionServeraddr; } m_VersionInfo; - semaphore m_GfxRenderSemaphore; - semaphore m_GfxStateSemaphore; volatile int m_GfxState; static void GraphicsThreadProxy(void *pThis) { ((CClient*)pThis)->GraphicsThread(); } void GraphicsThread(); diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index bf432356d..8816e1eda 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -22,6 +22,20 @@ #include "graphics.h" +#if defined(CONF_PLATFORM_MACOSX) + + class semaphore + { + SDL_sem *sem; + public: + semaphore() { sem = SDL_CreateSemaphore(0); } + ~semaphore() { SDL_DestroySemaphore(sem); } + void wait() { SDL_SemWait(sem); } + void signal() { SDL_SemPost(sem); } + }; +#endif + + static CVideoMode g_aFakeModes[] = { {320,240,8,8,8}, {400,300,8,8,8}, {640,480,8,8,8}, {720,400,8,8,8}, {768,576,8,8,8}, {800,600,8,8,8}, From cc048315a99070f6f93b4a9b620df0aeb3bffa47 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 10 Jun 2012 12:22:40 +0200 Subject: [PATCH 25/84] fixed some targets within mac building --- bam.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bam.lua b/bam.lua index da893e10c..9585bac81 100644 --- a/bam.lua +++ b/bam.lua @@ -369,9 +369,9 @@ if platform == "macosx" then PseudoTarget("release", ppc_r, x86_r, x86_64_r) PseudoTarget("debug", ppc_d, x86_d, x86_64_d) PseudoTarget("server_release", "server_release_x86", "server_release_x86_64", "server_release_ppc") - PseudoTarget("server_debug", "server_debug_x86", "server_release_x86_64", "server_debug_ppc") - PseudoTarget("client_release", "client_release_x86", "server_release_x86_64", "client_release_ppc") - PseudoTarget("client_debug", "client_debug_x86", "server_release_x86_64", "client_debug_ppc") + PseudoTarget("server_debug", "server_debug_x86", "server_debug_x86_64", "server_debug_ppc") + PseudoTarget("client_release", "client_release_x86", "client_release_x86_64", "client_release_ppc") + PseudoTarget("client_debug", "client_debug_x86", "client_debug_x86_64", "client_debug_ppc") else PseudoTarget("release", ppc_r) PseudoTarget("debug", ppc_d) From 4e4019986a763326952719f26798f3184325ce40 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 10 Jun 2012 13:07:31 +0200 Subject: [PATCH 26/84] 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(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 78b90e933..f3370f94e 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; From 56ae76f46574506fa2b28fbf2fdf5672ae5866c6 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 10 Jun 2012 19:56:23 +0200 Subject: [PATCH 27/84] made building tw with the SDK of the minimum mac os x version a config option. #964 --- bam.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bam.lua b/bam.lua index 9585bac81..c81574262 100644 --- a/bam.lua +++ b/bam.lua @@ -8,6 +8,7 @@ Import("other/freetype/freetype.lua") config = NewConfig() config:Add(OptCCompiler("compiler")) config:Add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-protector -fstack-protector-all")) +config:Add(OptTestCompileC("minmacosxsdk", "int main(){return 0;}", "-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk")) config:Add(OptLibrary("zlib", "zlib.h", false)) config:Add(SDL.OptFind("sdl", true)) config:Add(FreeType.OptFind("freetype", true)) @@ -149,8 +150,12 @@ function build(settings) -- disable visibility attribute support for gcc on windows settings.cc.defines:Add("NO_VIZ") elseif platform == "macosx" then - settings.cc.flags:Add("-mmacosx-version-min=10.5", "-isysroot /Developer/SDKs/MacOSX10.5.sdk") - settings.link.flags:Add("-mmacosx-version-min=10.5", "-isysroot /Developer/SDKs/MacOSX10.5.sdk") + settings.cc.flags:Add("-mmacosx-version-min=10.5") + settings.link.flags:Add("-mmacosx-version-min=10.5") + if config.minmacosxsdk.value == 1 then + settings.cc.flags:Add("-isysroot /Developer/SDKs/MacOSX10.5.sdk") + settings.link.flags:Add("-isysroot /Developer/SDKs/MacOSX10.5.sdk") + end elseif config.stackprotector.value == 1 then settings.cc.flags:Add("-fstack-protector", "-fstack-protector-all") settings.link.flags:Add("-fstack-protector", "-fstack-protector-all") From 7b545f3ed941d45c3a42016b9de667a08f8d4dc6 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Wed, 27 Jun 2012 11:46:11 +0200 Subject: [PATCH 28/84] 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(-) diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index b04b729eb..18f1cee65 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 8816e1eda..314669e21 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 0c99ebf7a..f67753fbe 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 d3ccc61e0..253059ec2 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 2bee031d0..659d10877 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 139937833..467ef5001 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 && From 86fe9757c5ca48349bf6d4035ffa33f745026a7e Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Wed, 27 Jun 2012 11:47:31 +0200 Subject: [PATCH 29/84] Removed useless enum --- src/engine/client/backend_sdl.cpp | 2 +- src/engine/client/graphics_threaded.h | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 18f1cee65..cb865bae1 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -450,7 +450,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height } SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, Flags&CCommandBuffer::INITFLAG_VSYNC ? 1 : 0); + SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, Flags&IGraphicsBackend::INITFLAG_VSYNC ? 1 : 0); // set caption SDL_WM_SetCaption(pName, pName); diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 253059ec2..b88ee3cb1 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -96,13 +96,6 @@ public: TEXFLAG_NOMIPMAPS = 1, }; - enum - { - INITFLAG_FULLSCREEN = 1, - INITFLAG_VSYNC = 2, - INITFLAG_RESIZABLE = 4, - }; - enum { // From 0adaf8a75206bcc3cdba5c4eadd5014a3d696aff Mon Sep 17 00:00:00 2001 From: BeaR Date: Wed, 2 May 2012 13:53:28 +0200 Subject: [PATCH 30/84] #913 Fix Input Handling --- src/engine/client/input.cpp | 13 +++++++++---- src/engine/input.h | 7 ++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/engine/client/input.cpp b/src/engine/client/input.cpp index 0b4a44a45..7ff8d6fe2 100644 --- a/src/engine/client/input.cpp +++ b/src/engine/client/input.cpp @@ -35,6 +35,7 @@ CInput::CInput() m_InputCurrent = 0; m_InputGrabbed = 0; + m_InputDispatched = false; m_LastRelease = 0; m_ReleaseDelta = -1; @@ -116,10 +117,14 @@ int CInput::Update() /*if(!input_grabbed && Graphics()->WindowActive()) Input()->MouseModeRelative();*/ - // clear and begin count on the other one - m_InputCurrent^=1; - mem_zero(&m_aInputCount[m_InputCurrent], sizeof(m_aInputCount[m_InputCurrent])); - mem_zero(&m_aInputState[m_InputCurrent], sizeof(m_aInputState[m_InputCurrent])); + if(m_InputDispatched) + { + // clear and begin count on the other one + m_InputCurrent^=1; + mem_zero(&m_aInputCount[m_InputCurrent], sizeof(m_aInputCount[m_InputCurrent])); + mem_zero(&m_aInputState[m_InputCurrent], sizeof(m_aInputState[m_InputCurrent])); + m_InputDispatched = false; + } { int i; diff --git a/src/engine/input.h b/src/engine/input.h index 7d28be101..93ceccd20 100644 --- a/src/engine/input.h +++ b/src/engine/input.h @@ -38,6 +38,7 @@ protected: unsigned char m_aInputState[2][1024]; int m_InputCurrent; + bool m_InputDispatched; int KeyWasPressed(int Key) { return m_aInputState[m_InputCurrent^1][Key]; } @@ -51,7 +52,11 @@ public: // events int NumEvents() const { return m_NumEvents; } - void ClearEvents() { m_NumEvents = 0; } + void ClearEvents() + { + m_NumEvents = 0; + m_InputDispatched = true; + } CEvent GetEvent(int Index) const { if(Index < 0 || Index >= m_NumEvents) From 865d0f736588337fc7b8cc925eb84bc2dd2ae7f0 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 8 Jul 2012 11:40:23 +0200 Subject: [PATCH 31/84] limit characters within player names to ascii range to prevent utf8 impersonating --- src/engine/server/server.cpp | 72 +++++++++++++++--------------------- 1 file changed, 29 insertions(+), 43 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 704d4e378..611441d8e 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -36,45 +36,23 @@ #include #endif -static const char *StrUTF8Ltrim(const char *pStr) +static const char *StrLtrim(const char *pStr) { - while(*pStr) - { - const char *pStrOld = pStr; - int Code = str_utf8_decode(&pStr); - - // check if unicode is not empty - if(Code > 0x20 && Code != 0xA0 && Code != 0x034F && (Code < 0x2000 || Code > 0x200F) && (Code < 0x2028 || Code > 0x202F) && - (Code < 0x205F || Code > 0x2064) && (Code < 0x206A || Code > 0x206F) && (Code < 0xFE00 || Code > 0xFE0F) && - Code != 0xFEFF && (Code < 0xFFF9 || Code > 0xFFFC)) - { - return pStrOld; - } - } + while(*pStr && *pStr >= 0 && *pStr <= 32) + pStr++; return pStr; } -static void StrUTF8Rtrim(char *pStr) +static void StrRtrim(char *pStr) { - const char *p = pStr; - const char *pEnd = 0; - while(*p) + int i = str_length(pStr); + while(i >= 0) { - const char *pStrOld = p; - int Code = str_utf8_decode(&p); - - // check if unicode is not empty - if(Code > 0x20 && Code != 0xA0 && Code != 0x034F && (Code < 0x2000 || Code > 0x200F) && (Code < 0x2028 || Code > 0x202F) && - (Code < 0x205F || Code > 0x2064) && (Code < 0x206A || Code > 0x206F) && (Code < 0xFE00 || Code > 0xFE0F) && - Code != 0xFEFF && (Code < 0xFFF9 || Code > 0xFFFC)) - { - pEnd = 0; - } - else if(pEnd == 0) - pEnd = pStrOld; + if(pStr[i] < 0 || pStr[i] > 32) + break; + pStr[i] = 0; + i--; } - if(pEnd != 0) - *(const_cast(pEnd)) = 0; } @@ -316,8 +294,12 @@ int CServer::TrySetClientName(int ClientID, const char *pName) char aTrimmedName[64]; // trim the name - str_copy(aTrimmedName, StrUTF8Ltrim(pName), sizeof(aTrimmedName)); - StrUTF8Rtrim(aTrimmedName); + str_copy(aTrimmedName, StrLtrim(pName), sizeof(aTrimmedName)); + StrRtrim(aTrimmedName); + + // check for empty names + if(!aTrimmedName[0]) + return -1; // check if new and old name are the same if(m_aClients[ClientID].m_aName[0] && str_comp(m_aClients[ClientID].m_aName, aTrimmedName) == 0) @@ -328,11 +310,6 @@ int CServer::TrySetClientName(int ClientID, const char *pName) Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf); pName = aTrimmedName; - - // check for empty names - if(!pName[0]) - return -1; - // make sure that two clients doesn't have the same name for(int i = 0; i < MAX_CLIENTS; i++) if(i != ClientID && m_aClients[i].m_State >= CClient::STATE_READY) @@ -356,14 +333,23 @@ void CServer::SetClientName(int ClientID, const char *pName) if(!pName) return; - char aNameTry[MAX_NAME_LENGTH]; - str_copy(aNameTry, pName, MAX_NAME_LENGTH); - if(TrySetClientName(ClientID, aNameTry)) + char aCleanName[MAX_NAME_LENGTH]; + str_copy(aCleanName, pName, sizeof(aCleanName)); + + // clear name + for(char *p = aCleanName; *p; ++p) + { + if(*p < 32) + *p = ' '; + } + + if(TrySetClientName(ClientID, aCleanName)) { // auto rename for(int i = 1;; i++) { - str_format(aNameTry, MAX_NAME_LENGTH, "(%d)%s", i, pName); + char aNameTry[MAX_NAME_LENGTH]; + str_format(aNameTry, sizeof(aCleanName), "(%d)%s", i, aCleanName); if(TrySetClientName(ClientID, aNameTry) == 0) break; } From ff75c3ba2d1df54ec5f53da2ce502cfd33c182e0 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 8 Jul 2012 13:13:21 +0200 Subject: [PATCH 32/84] 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(+) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index fa1024e0e..2c67c0216 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 463147e18..529638cfb 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; } } From 521eaf038baeefe5aca026ba077c0ce7f72310b7 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 8 Jul 2012 18:37:32 +0200 Subject: [PATCH 33/84] fixed missing messages when net connection closes --- src/engine/shared/network_conn.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/engine/shared/network_conn.cpp b/src/engine/shared/network_conn.cpp index 6a63f82d0..24c8f066f 100644 --- a/src/engine/shared/network_conn.cpp +++ b/src/engine/shared/network_conn.cpp @@ -25,8 +25,6 @@ void CNetConnection::Reset() m_Buffer.Init(); mem_zero(&m_Construct, sizeof(m_Construct)); - - mem_zero(m_ErrorString, sizeof(m_ErrorString)); } const char *CNetConnection::ErrorString() @@ -46,6 +44,7 @@ void CNetConnection::Init(NETSOCKET Socket, bool BlockCloseMsg) m_Socket = Socket; m_BlockCloseMsg = BlockCloseMsg; + mem_zero(m_ErrorString, sizeof(m_ErrorString)); } void CNetConnection::AckChunks(int Ack) @@ -169,6 +168,7 @@ int CNetConnection::Connect(NETADDR *pAddr) // init connection Reset(); m_PeerAddr = *pAddr; + mem_zero(m_ErrorString, sizeof(m_ErrorString)); m_State = NET_CONNSTATE_CONNECT; SendControl(NET_CTRLMSG_CONNECT, 0, 0); return 0; @@ -248,6 +248,7 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr) Reset(); m_State = NET_CONNSTATE_PENDING; m_PeerAddr = *pAddr; + mem_zero(m_ErrorString, sizeof(m_ErrorString)); m_LastSendTime = Now; m_LastRecvTime = Now; m_LastUpdateTime = Now; From 6c8e097bb25d343883dd292f0db2de684a35fc86 Mon Sep 17 00:00:00 2001 From: oy Date: Thu, 19 Jul 2012 10:01:57 +0200 Subject: [PATCH 34/84] fixed try_lock on windows --- src/base/system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/system.c b/src/base/system.c index 1c4d3a484..f4ce8b37b 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -477,7 +477,7 @@ int lock_try(LOCK lock) #if defined(CONF_FAMILY_UNIX) return pthread_mutex_trylock((LOCKINTERNAL *)lock); #elif defined(CONF_FAMILY_WINDOWS) - return TryEnterCriticalSection((LPCRITICAL_SECTION)lock); + return !TryEnterCriticalSection((LPCRITICAL_SECTION)lock); #else #error not implemented on this platform #endif From 71907fbeb93267ecdb40747f9eb0aeb9c882917e Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 21 Jul 2012 18:53:09 +0200 Subject: [PATCH 35/84] fixed semaphore behavior on windows. Closes #926. Closes #934. --- src/base/system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/system.c b/src/base/system.c index f4ce8b37b..a849e807c 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -513,7 +513,7 @@ void lock_release(LOCK lock) void semaphore_destroy(SEMAPHORE *sem) { sem_destroy(sem); } #elif defined(CONF_FAMILY_WINDOWS) void semaphore_init(SEMAPHORE *sem) { *sem = CreateSemaphore(0, 0, 10000, 0); } - void semaphore_wait(SEMAPHORE *sem) { WaitForSingleObject((HANDLE)*sem, 0L); } + void semaphore_wait(SEMAPHORE *sem) { WaitForSingleObject((HANDLE)*sem, INFINITE); } void semaphore_signal(SEMAPHORE *sem) { ReleaseSemaphore((HANDLE)*sem, 1, NULL); } void semaphore_destroy(SEMAPHORE *sem) { CloseHandle((HANDLE)*sem); } #else From 4fb57dea91557cb1bd5da22a98e0531e83ee1471 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 22 Jul 2012 10:43:19 +0200 Subject: [PATCH 36/84] fixed editor crash on replacing images. Closes #981 --- src/game/editor/editor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 2c67c0216..ee26a3f08 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) { From 0a0c131cdc77a9bcd3643c3a8318f7d63541114c Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 22 Jul 2012 10:44:50 +0200 Subject: [PATCH 37/84] fixed compiler error. Closes #982 --- src/base/tl/base.h | 2 +- src/base/tl/range.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/base/tl/base.h b/src/base/tl/base.h index 2fcb14eb8..ce77db847 100644 --- a/src/base/tl/base.h +++ b/src/base/tl/base.h @@ -5,7 +5,7 @@ #include -inline void assert(bool statement) +inline void tl_assert(bool statement) { dbg_assert(statement, "assert!"); } diff --git a/src/base/tl/range.h b/src/base/tl/range.h index f05169fa1..f1fc070b2 100644 --- a/src/base/tl/range.h +++ b/src/base/tl/range.h @@ -150,11 +150,11 @@ public: } bool empty() const { return begin >= end; } - void pop_front() { assert(!empty()); begin++; } - void pop_back() { assert(!empty()); end--; } - T& front() { assert(!empty()); return *begin; } - T& back() { assert(!empty()); return *(end-1); } - T& index(unsigned i) { assert(i >= 0 && i < (unsigned)(end-begin)); return begin[i]; } + void pop_front() { tl_assert(!empty()); begin++; } + void pop_back() { tl_assert(!empty()); end--; } + T& front() { tl_assert(!empty()); return *begin; } + T& back() { tl_assert(!empty()); return *(end-1); } + T& index(unsigned i) { tl_assert(i >= 0 && i < (unsigned)(end-begin)); return begin[i]; } unsigned size() const { return (unsigned)(end-begin); } plain_range slice(unsigned startindex, unsigned endindex) { From 8ca79336533b891b0cc11ccccf178b661777185a Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 29 Jul 2012 12:17:16 +0200 Subject: [PATCH 38/84] Show user authlevel on status command. Closes #985 --- src/engine/server/server.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 611441d8e..3cad5d1c6 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1449,8 +1449,12 @@ void CServer::ConStatus(IConsole::IResult *pResult, void *pUser) { net_addr_str(pThis->m_NetServer.ClientAddr(i), aAddrStr, sizeof(aAddrStr), true); if(pThis->m_aClients[i].m_State == CClient::STATE_INGAME) - str_format(aBuf, sizeof(aBuf), "id=%d addr=%s name='%s' score=%d", i, aAddrStr, - pThis->m_aClients[i].m_aName, pThis->m_aClients[i].m_Score); + { + const char *pAuthStr = pThis->m_aClients[i].m_Authed == CServer::AUTHED_ADMIN ? "(Admin)" : + pThis->m_aClients[i].m_Authed == CServer::AUTHED_MOD ? "(Mod)" : ""; + str_format(aBuf, sizeof(aBuf), "id=%d addr=%s name='%s' score=%d %s", i, aAddrStr, + pThis->m_aClients[i].m_aName, pThis->m_aClients[i].m_Score, pAuthStr); + } else str_format(aBuf, sizeof(aBuf), "id=%d addr=%s connecting", i, aAddrStr); pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf); From 6af382ade1d350091545dd24ab79020bda7825f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Kochen?= Date: Sun, 20 May 2012 19:29:06 +0200 Subject: [PATCH 39/84] Clang driver support. --- configure.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.lua b/configure.lua index 26825b06f..2db70cc4d 100644 --- a/configure.lua +++ b/configure.lua @@ -376,6 +376,8 @@ function OptCCompiler(name, default_driver, default_c, default_cxx, desc) SetDriversCL(settings) elseif option.driver == "gcc" then SetDriversGCC(settings) + elseif option.driver == "clang" then + SetDriversClang(settings) else error(option.driver.." is not a known c/c++ compile driver") end @@ -393,7 +395,7 @@ function OptCCompiler(name, default_driver, default_c, default_cxx, desc) local printhelp = function(option) local a = "" if option.desc then a = "for "..option.desc end - print("\t"..option.name.."=gcc|cl") + print("\t"..option.name.."=gcc|cl|clang") print("\t\twhat c/c++ compile driver to use"..a) print("\t"..option.name..".c=FILENAME") print("\t\twhat c compiler executable to use"..a) From 98042012a6c6e639c9736b32518dd082ca539615 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Fri, 17 Aug 2012 00:03:53 +0200 Subject: [PATCH 40/84] cleaned up warnings that clang spits out. some bugs found with it. Conflicts: src/game/server/gamemodes/ctf.cpp src/game/server/gamemodes/ctf.h --- src/base/tl/range.h | 2 +- src/engine/client/graphics_threaded.h | 2 ++ src/engine/server/server.cpp | 4 ++-- src/engine/server/server.h | 6 +++--- src/engine/shared/console.cpp | 6 +++--- src/engine/shared/mapchecker.cpp | 1 + src/engine/shared/netban.h | 2 +- src/versionsrv/mapversions.h | 22 ++++++++++++++++++++++ src/versionsrv/versionsrv.h | 17 ----------------- 9 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 src/versionsrv/mapversions.h diff --git a/src/base/tl/range.h b/src/base/tl/range.h index f1fc070b2..1d225f491 100644 --- a/src/base/tl/range.h +++ b/src/base/tl/range.h @@ -154,7 +154,7 @@ public: void pop_back() { tl_assert(!empty()); end--; } T& front() { tl_assert(!empty()); return *begin; } T& back() { tl_assert(!empty()); return *(end-1); } - T& index(unsigned i) { tl_assert(i >= 0 && i < (unsigned)(end-begin)); return begin[i]; } + T& index(unsigned i) { tl_assert(i < (unsigned)(end-begin)); return begin[i]; } unsigned size() const { return (unsigned)(end-begin); } plain_range slice(unsigned startindex, unsigned endindex) { diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index b88ee3cb1..5c15d0629 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -296,6 +296,8 @@ public: INITFLAG_BORDERLESS = 8, }; + virtual ~IGraphicsBackend() {} + virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags) = 0; virtual int Shutdown() = 0; diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 3cad5d1c6..4b7f63329 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -145,7 +145,7 @@ void CSnapIDPool::FreeID(int ID) } -void CServerBan::Init(IConsole *pConsole, IStorage *pStorage, CServer* pServer) +void CServerBan::InitServerBan(IConsole *pConsole, IStorage *pStorage, CServer* pServer) { CNetBan::Init(pConsole, pStorage); @@ -1618,7 +1618,7 @@ void CServer::RegisterCommands() Console()->Chain("console_output_level", ConchainConsoleOutputLevelUpdate, this); // register console commands in sub parts - m_ServerBan.Init(Console(), Storage(), this); + m_ServerBan.InitServerBan(Console(), Storage(), this); m_pGameServer->OnConsoleInit(); } diff --git a/src/engine/server/server.h b/src/engine/server/server.h index 696b472da..c3c1794dc 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -50,10 +50,10 @@ class CServerBan : public CNetBan public: class CServer *Server() const { return m_pServer; } - void Init(class IConsole *pConsole, class IStorage *pStorage, class CServer* pServer); + void InitServerBan(class IConsole *pConsole, class IStorage *pStorage, class CServer* pServer); - int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason); - int BanRange(const CNetRange *pRange, int Seconds, const char *pReason); + virtual int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason); + virtual int BanRange(const CNetRange *pRange, int Seconds, const char *pReason); static void ConBanExt(class IConsole::IResult *pResult, void *pUser); }; diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp index 443c59047..3ff3c5b3c 100644 --- a/src/engine/shared/console.cpp +++ b/src/engine/shared/console.cpp @@ -16,21 +16,21 @@ const char *CConsole::CResult::GetString(unsigned Index) { - if (Index < 0 || Index >= m_NumArgs) + if (Index >= m_NumArgs) return ""; return m_apArgs[Index]; } int CConsole::CResult::GetInteger(unsigned Index) { - if (Index < 0 || Index >= m_NumArgs) + if (Index >= m_NumArgs) return 0; return str_toint(m_apArgs[Index]); } float CConsole::CResult::GetFloat(unsigned Index) { - if (Index < 0 || Index >= m_NumArgs) + if (Index >= m_NumArgs) return 0.0f; return str_tofloat(m_apArgs[Index]); } diff --git a/src/engine/shared/mapchecker.cpp b/src/engine/shared/mapchecker.cpp index f8ba30ae5..5a7d062f1 100644 --- a/src/engine/shared/mapchecker.cpp +++ b/src/engine/shared/mapchecker.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "datafile.h" #include "memheap.h" diff --git a/src/engine/shared/netban.h b/src/engine/shared/netban.h index 6d690164d..701648327 100644 --- a/src/engine/shared/netban.h +++ b/src/engine/shared/netban.h @@ -170,7 +170,7 @@ public: class IStorage *Storage() const { return m_pStorage; } virtual ~CNetBan() {} - virtual void Init(class IConsole *pConsole, class IStorage *pStorage); + void Init(class IConsole *pConsole, class IStorage *pStorage); void Update(); virtual int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason); diff --git a/src/versionsrv/mapversions.h b/src/versionsrv/mapversions.h new file mode 100644 index 000000000..fe9e42295 --- /dev/null +++ b/src/versionsrv/mapversions.h @@ -0,0 +1,22 @@ +/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ +/* If you are missing that file, acquire a complete release at teeworlds.com. */ +#ifndef VERSIONSRV_MAPVERSIONS_H +#define VERSIONSRV_MAPVERSIONS_H + +static CMapVersion s_aMapVersionList[] = { + {"ctf1", {0x06, 0xb5, 0xf1, 0x17}, {0x00, 0x00, 0x12, 0x38}}, + {"ctf2", {0x27, 0xbc, 0x5e, 0xac}, {0x00, 0x00, 0x64, 0x1a}}, + {"ctf3", {0xa3, 0x73, 0x9d, 0x41}, {0x00, 0x00, 0x17, 0x0f}}, + {"ctf4", {0xbe, 0x7c, 0x4d, 0xb9}, {0x00, 0x00, 0x2e, 0xfe}}, + {"ctf5", {0xd9, 0x21, 0x29, 0xa0}, {0x00, 0x00, 0x2f, 0x4c}}, + {"ctf6", {0x28, 0xc8, 0x43, 0x51}, {0x00, 0x00, 0x69, 0x2f}}, + {"ctf7", {0x1d, 0x35, 0x98, 0x72}, {0x00, 0x00, 0x15, 0x87}}, + {"dm1", {0xf2, 0x15, 0x9e, 0x6e}, {0x00, 0x00, 0x16, 0xad}}, + {"dm2", {0x71, 0x83, 0x98, 0x78}, {0x00, 0x00, 0x21, 0xdf}}, + {"dm6", {0x47, 0x4d, 0xa2, 0x35}, {0x00, 0x00, 0x1e, 0x95}}, + {"dm7", {0x42, 0x6d, 0xa1, 0x67}, {0x00, 0x00, 0x27, 0x2a}}, + {"dm8", {0x85, 0xf1, 0x1e, 0xd6}, {0x00, 0x00, 0x9e, 0xbd}}, + {"dm9", {0x42, 0xd4, 0x77, 0x7e}, {0x00, 0x00, 0x20, 0x11}}, +}; +static const int s_NumMapVersionItems = sizeof(s_aMapVersionList)/sizeof(CMapVersion); +#endif diff --git a/src/versionsrv/versionsrv.h b/src/versionsrv/versionsrv.h index 383f1ac43..46f64251e 100644 --- a/src/versionsrv/versionsrv.h +++ b/src/versionsrv/versionsrv.h @@ -11,23 +11,6 @@ struct CMapVersion unsigned char m_aSize[4]; }; -static CMapVersion s_aMapVersionList[] = { - {"ctf1", {0x06, 0xb5, 0xf1, 0x17}, {0x00, 0x00, 0x12, 0x38}}, - {"ctf2", {0x27, 0xbc, 0x5e, 0xac}, {0x00, 0x00, 0x64, 0x1a}}, - {"ctf3", {0xa3, 0x73, 0x9d, 0x41}, {0x00, 0x00, 0x17, 0x0f}}, - {"ctf4", {0xbe, 0x7c, 0x4d, 0xb9}, {0x00, 0x00, 0x2e, 0xfe}}, - {"ctf5", {0xd9, 0x21, 0x29, 0xa0}, {0x00, 0x00, 0x2f, 0x4c}}, - {"ctf6", {0x28, 0xc8, 0x43, 0x51}, {0x00, 0x00, 0x69, 0x2f}}, - {"ctf7", {0x1d, 0x35, 0x98, 0x72}, {0x00, 0x00, 0x15, 0x87}}, - {"dm1", {0xf2, 0x15, 0x9e, 0x6e}, {0x00, 0x00, 0x16, 0xad}}, - {"dm2", {0x71, 0x83, 0x98, 0x78}, {0x00, 0x00, 0x21, 0xdf}}, - {"dm6", {0x47, 0x4d, 0xa2, 0x35}, {0x00, 0x00, 0x1e, 0x95}}, - {"dm7", {0x42, 0x6d, 0xa1, 0x67}, {0x00, 0x00, 0x27, 0x2a}}, - {"dm8", {0x85, 0xf1, 0x1e, 0xd6}, {0x00, 0x00, 0x9e, 0xbd}}, - {"dm9", {0x42, 0xd4, 0x77, 0x7e}, {0x00, 0x00, 0x20, 0x11}}, -}; -static const int s_NumMapVersionItems = sizeof(s_aMapVersionList)/sizeof(CMapVersion); - static const unsigned char VERSIONSRV_GETVERSION[] = {255, 255, 255, 255, 'v', 'e', 'r', 'g'}; static const unsigned char VERSIONSRV_VERSION[] = {255, 255, 255, 255, 'v', 'e', 'r', 's'}; From 1711be955b54b9d12431b341ea290bad406023cc Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Fri, 17 Aug 2012 18:32:56 +0200 Subject: [PATCH 41/84] 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(-) diff --git a/src/base/system.c b/src/base/system.c index a849e807c..410cb699a 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 032cf7857..7ba0c0a09 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 6d1d8f4f8..a88fe3cbe 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 3ff3c5b3c..399f53230 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 9ef8fdc31..1514278b9 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 ee26a3f08..7109adcaf 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 2382823db..f281c6aa3 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 5d2f22b8d..bab48308f 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 7001ca326..0ee250e8a 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) From dfd15bc899b0bcf91f454b1b52b26bd471f653e8 Mon Sep 17 00:00:00 2001 From: BeaR Date: Mon, 13 Aug 2012 12:57:40 +0200 Subject: [PATCH 42/84] 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(-) diff --git a/src/game/client/render_map.cpp b/src/game/client/render_map.cpp index 23fa42e02..3b409fb89 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 d0b66405c..321a28f8c 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 9a21e5ce3..325d527b7 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); } From d8ff437c5ecc4cc3e7f627d6ac6f20447e6efaf6 Mon Sep 17 00:00:00 2001 From: BeaR Date: Fri, 17 Aug 2012 10:44:51 +0200 Subject: [PATCH 43/84] Set value higher --- src/game/client/render_map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/render_map.cpp b/src/game/client/render_map.cpp index 3b409fb89..a854b4a7b 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; From 678b6faceb8f8bd550de32b8fe59f7c34e2a3172 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 26 Aug 2012 20:02:04 +0200 Subject: [PATCH 44/84] Fixed threaded gfx and building on Mac OS X --- src/engine/client/backend_sdl.cpp | 3 ++ src/engine/client/backend_sdl.h | 52 ++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index cb865bae1..22c48e53d 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -11,6 +11,9 @@ void CGraphicsBackend_Threaded::ThreadFunc(void *pUser) { + #ifdef CONF_PLATFORM_MACOSX + CAutoreleasePool AutoreleasePool; + #endif CGraphicsBackend_Threaded *pThis = (CGraphicsBackend_Threaded *)pUser; while(!pThis->m_Shutdown) diff --git a/src/engine/client/backend_sdl.h b/src/engine/client/backend_sdl.h index 2ef04a1f8..619ba84dd 100644 --- a/src/engine/client/backend_sdl.h +++ b/src/engine/client/backend_sdl.h @@ -28,7 +28,7 @@ static void GL_SwapBuffers(const SGLContext &Context) { SwapBuffers(Context.m_hDC); } #elif defined(CONF_PLATFORM_MACOSX) - #include + #include class semaphore { @@ -42,20 +42,58 @@ struct SGLContext { - AGLContext m_Context; + id m_Context; }; static SGLContext GL_GetCurrentContext() { SGLContext Context; - Context.m_Context = aglGetCurrentContext(); + Class NSOpenGLContextClass = (Class) objc_getClass("NSOpenGLContext"); + SEL selector = sel_registerName("currentContext"); + Context.m_Context = objc_msgSend((objc_object*) NSOpenGLContextClass, selector); return Context; } - static void GL_MakeCurrent(const SGLContext &Context) { aglSetCurrentContext(Context.m_Context); } - static void GL_ReleaseContext(const SGLContext &Context) { aglSetCurrentContext(NULL); } - static void GL_SwapBuffers(const SGLContext &Context) { aglSwapBuffers(Context.m_Context); } - + static void GL_MakeCurrent(const SGLContext &Context) + { + SEL selector = sel_registerName("makeCurrentContext"); + objc_msgSend(Context.m_Context, selector); + } + + static void GL_ReleaseContext(const SGLContext &Context) + { + Class NSOpenGLContextClass = (Class) objc_getClass("NSOpenGLContext"); + SEL selector = sel_registerName("clearCurrentContext"); + objc_msgSend((objc_object*) NSOpenGLContextClass, selector); + } + + static void GL_SwapBuffers(const SGLContext &Context) + { + SEL selector = sel_registerName("flushBuffer"); + objc_msgSend(Context.m_Context, selector); + } + + class CAutoreleasePool + { + private: + id m_Pool; + + public: + CAutoreleasePool() + { + Class NSAutoreleasePoolClass = (Class) objc_getClass("NSAutoreleasePool"); + m_Pool = class_createInstance(NSAutoreleasePoolClass, 0); + SEL selector = sel_registerName("init"); + objc_msgSend(m_Pool, selector); + } + + ~CAutoreleasePool() + { + SEL selector = sel_registerName("drain"); + objc_msgSend(m_Pool, selector); + } + }; + #elif defined(CONF_FAMILY_UNIX) #include From c3dd09cebfeca29a33ab77dfcfb27ec7a64a9687 Mon Sep 17 00:00:00 2001 From: BeaR Date: Mon, 27 Aug 2012 18:58:30 +0200 Subject: [PATCH 45/84] Readded Texturecompression-support --- src/engine/client/backend_sdl.cpp | 10 ++++++++++ src/engine/client/graphics_threaded.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 22c48e53d..7fa1db77a 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -176,6 +176,16 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer:: int Oglformat = TexFormatToOpenGLFormat(pCommand->m_Format); int StoreOglformat = TexFormatToOpenGLFormat(pCommand->m_StoreFormat); + if(pCommand->m_Flags&CCommandBuffer::TEXFLAG_COMPRESSED) + { + switch(StoreOglformat) + { + case GL_RGB: StoreOglformat = GL_COMPRESSED_RGB_ARB; + case GL_ALPHA: StoreOglformat = GL_COMPRESSED_ALPHA_ARB; + case GL_RGBA: StoreOglformat = GL_COMPRESSED_RGBA_ARB; + default: StoreOglformat = GL_COMPRESSED_RGBA_ARB; + } + } glGenTextures(1, &m_aTextures[pCommand->m_Slot]); glBindTexture(GL_TEXTURE_2D, m_aTextures[pCommand->m_Slot]); diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 5c15d0629..e482f6e5d 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -94,6 +94,7 @@ public: TEXFORMAT_ALPHA, TEXFLAG_NOMIPMAPS = 1, + TEXFLAG_COMPRESSED = 2, }; enum From 1cfbfda6fa429ab0ee2e503262946a8adbfd9a2e Mon Sep 17 00:00:00 2001 From: BeaR Date: Mon, 3 Sep 2012 11:39:12 +0200 Subject: [PATCH 46/84] Missed a file.. --- src/engine/client/graphics_threaded.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index f67753fbe..8653b62a0 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -359,6 +359,8 @@ int CGraphics_Threaded::LoadTextureRaw(int Width, int Height, int Format, const Cmd.m_Flags = 0; if(Flags&IGraphics::TEXLOAD_NOMIPMAPS) Cmd.m_Flags |= CCommandBuffer::TEXFLAG_NOMIPMAPS; + if(g_Config.m_GfxTextureCompression) + Cmd.m_Flags |= CCommandBuffer::TEXFLAG_COMPRESSED; // calculate memory usage int PixelSize = 4; From 2948d2392b509c5cc743d517687a8d941e4ef9d0 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 6 Oct 2012 13:24:31 +0200 Subject: [PATCH 47/84] fixed last commit --- src/engine/client/backend_sdl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 7fa1db77a..5f57fa302 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -180,9 +180,9 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer:: { switch(StoreOglformat) { - case GL_RGB: StoreOglformat = GL_COMPRESSED_RGB_ARB; - case GL_ALPHA: StoreOglformat = GL_COMPRESSED_ALPHA_ARB; - case GL_RGBA: StoreOglformat = GL_COMPRESSED_RGBA_ARB; + case GL_RGB: StoreOglformat = GL_COMPRESSED_RGB_ARB; break; + case GL_ALPHA: StoreOglformat = GL_COMPRESSED_ALPHA_ARB; break; + case GL_RGBA: StoreOglformat = GL_COMPRESSED_RGBA_ARB; break; default: StoreOglformat = GL_COMPRESSED_RGBA_ARB; } } From 7eddbe0dc9297e795ffdac65914f70ffcd43325a Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 6 Oct 2012 13:47:37 +0200 Subject: [PATCH 48/84] 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(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 1c76f6556..6794429da 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 aa127979b..d799d8a7d 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; From 71af97a5e30739577bde35db24ec9f160b0bea65 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 6 Oct 2012 23:31:02 +0200 Subject: [PATCH 49/84] fixed texture memory usage calculation in graphics threaded Conflicts: src/engine/client/graphics_threaded.cpp --- src/engine/client/backend_sdl.cpp | 46 +++++++++++++++++---- src/engine/client/backend_sdl.h | 28 ++++++++++++- src/engine/client/graphics_threaded.cpp | 55 +++++++++---------------- src/engine/client/graphics_threaded.h | 16 +++---- 4 files changed, 89 insertions(+), 56 deletions(-) diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 5f57fa302..d99f765bf 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -133,7 +133,7 @@ void CCommandProcessorFragment_OpenGL::SetState(const CCommandBuffer::SState &St if(State.m_Texture >= 0 && State.m_Texture < CCommandBuffer::MAX_TEXTURES) { glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, m_aTextures[State.m_Texture]); + glBindTexture(GL_TEXTURE_2D, m_aTextures[State.m_Texture].m_Tex); } else glDisable(GL_TEXTURE_2D); @@ -158,9 +158,14 @@ void CCommandProcessorFragment_OpenGL::SetState(const CCommandBuffer::SState &St glOrtho(State.m_ScreenTL.x, State.m_ScreenBR.x, State.m_ScreenBR.y, State.m_ScreenTL.y, 1.0f, 10.f); } +void CCommandProcessorFragment_OpenGL::Cmd_Init(const SCommand_Init *pCommand) +{ + m_pTextureMemoryUsage = pCommand->m_pTextureMemoryUsage; +} + void CCommandProcessorFragment_OpenGL::Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand) { - glBindTexture(GL_TEXTURE_2D, m_aTextures[pCommand->m_Slot]); + glBindTexture(GL_TEXTURE_2D, m_aTextures[pCommand->m_Slot].m_Tex); glTexSubImage2D(GL_TEXTURE_2D, 0, pCommand->m_X, pCommand->m_Y, pCommand->m_Width, pCommand->m_Height, TexFormatToOpenGLFormat(pCommand->m_Format), GL_UNSIGNED_BYTE, pCommand->m_pData); mem_free(pCommand->m_pData); @@ -168,7 +173,8 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Update(const CCommandBuffer:: void CCommandProcessorFragment_OpenGL::Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand) { - glDeleteTextures(1, &m_aTextures[pCommand->m_Slot]); + glDeleteTextures(1, &m_aTextures[pCommand->m_Slot].m_Tex); + *m_pTextureMemoryUsage -= m_aTextures[pCommand->m_Slot].m_MemSize; } void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand) @@ -186,8 +192,8 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer:: default: StoreOglformat = GL_COMPRESSED_RGBA_ARB; } } - glGenTextures(1, &m_aTextures[pCommand->m_Slot]); - glBindTexture(GL_TEXTURE_2D, m_aTextures[pCommand->m_Slot]); + glGenTextures(1, &m_aTextures[pCommand->m_Slot].m_Tex); + glBindTexture(GL_TEXTURE_2D, m_aTextures[pCommand->m_Slot].m_Tex); if(pCommand->m_Flags&CCommandBuffer::TEXFLAG_NOMIPMAPS) { @@ -202,6 +208,18 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer:: gluBuild2DMipmaps(GL_TEXTURE_2D, StoreOglformat, pCommand->m_Width, pCommand->m_Height, Oglformat, GL_UNSIGNED_BYTE, pCommand->m_pData); } + // calculate memory usage + int Width = pCommand->m_Width; + int Height = pCommand->m_Height; + m_aTextures[pCommand->m_Slot].m_MemSize = Width*Height*pCommand->m_PixelSize; + while(Width > 2 && Height > 2) + { + Width>>=1; + Height>>=1; + m_aTextures[pCommand->m_Slot].m_MemSize += Width*Height*pCommand->m_PixelSize; + } + *m_pTextureMemoryUsage += m_aTextures[pCommand->m_Slot].m_MemSize; + mem_free(pCommand->m_pData); } @@ -273,12 +291,14 @@ void CCommandProcessorFragment_OpenGL::Cmd_Screenshot(const CCommandBuffer::SCom CCommandProcessorFragment_OpenGL::CCommandProcessorFragment_OpenGL() { mem_zero(m_aTextures, sizeof(m_aTextures)); + m_pTextureMemoryUsage = 0; } bool CCommandProcessorFragment_OpenGL::RunCommand(const CCommandBuffer::SCommand * pBaseCommand) { switch(pBaseCommand->m_Cmd) { + case CMD_INIT: Cmd_Init(static_cast(pBaseCommand)); break; case CCommandBuffer::CMD_TEXTURE_CREATE: Cmd_Texture_Create(static_cast(pBaseCommand)); break; case CCommandBuffer::CMD_TEXTURE_DESTROY: Cmd_Texture_Destroy(static_cast(pBaseCommand)); break; case CCommandBuffer::CMD_TEXTURE_UPDATE: Cmd_Texture_Update(static_cast(pBaseCommand)); break; @@ -487,11 +507,14 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height m_pProcessor = new CCommandProcessor_SDL_OpenGL; StartProcessor(m_pProcessor); - // issue a init command + // issue init commands for OpenGL and SDL CCommandBuffer CmdBuffer(1024, 512); - CCommandProcessorFragment_SDL::SCommand_Init Cmd; - Cmd.m_Context = m_GLContext; - CmdBuffer.AddCommand(Cmd); + CCommandProcessorFragment_OpenGL::SCommand_Init CmdOpenGL; + CmdOpenGL.m_pTextureMemoryUsage = &m_TextureMemoryUsage; + CmdBuffer.AddCommand(CmdOpenGL); + CCommandProcessorFragment_SDL::SCommand_Init CmdSDL; + CmdSDL.m_Context = m_GLContext; + CmdBuffer.AddCommand(CmdSDL); RunBuffer(&CmdBuffer); WaitForIdle(); @@ -517,6 +540,11 @@ int CGraphicsBackend_SDL_OpenGL::Shutdown() return 0; } +int CGraphicsBackend_SDL_OpenGL::MemoryUsage() const +{ + return m_TextureMemoryUsage; +} + void CGraphicsBackend_SDL_OpenGL::Minimize() { SDL_WM_IconifyWindow(); diff --git a/src/engine/client/backend_sdl.h b/src/engine/client/backend_sdl.h index 619ba84dd..e1fc60b0c 100644 --- a/src/engine/client/backend_sdl.h +++ b/src/engine/client/backend_sdl.h @@ -167,11 +167,32 @@ public: // takes care of opengl related rendering class CCommandProcessorFragment_OpenGL { - GLuint m_aTextures[CCommandBuffer::MAX_TEXTURES]; + struct CTexture + { + GLuint m_Tex; + int m_MemSize; + }; + CTexture m_aTextures[CCommandBuffer::MAX_TEXTURES]; + volatile int *m_pTextureMemoryUsage; + +public: + enum + { + CMD_INIT = CCommandBuffer::CMDGROUP_PLATFORM_OPENGL, + }; + + struct SCommand_Init : public CCommandBuffer::SCommand + { + SCommand_Init() : SCommand(CMD_INIT) {} + volatile int *m_pTextureMemoryUsage; + }; + +private: static int TexFormatToOpenGLFormat(int TexFormat); void SetState(const CCommandBuffer::SState &State); + void Cmd_Init(const SCommand_Init *pCommand); void Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand); void Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand); void Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand); @@ -193,7 +214,7 @@ class CCommandProcessorFragment_SDL public: enum { - CMD_INIT = CCommandBuffer::CMDGROUP_PLATFORM, + CMD_INIT = CCommandBuffer::CMDGROUP_PLATFORM_SDL, CMD_SHUTDOWN, }; @@ -235,10 +256,13 @@ class CGraphicsBackend_SDL_OpenGL : public CGraphicsBackend_Threaded SDL_Surface *m_pScreenSurface; ICommandProcessor *m_pProcessor; SGLContext m_GLContext; + volatile int m_TextureMemoryUsage; public: virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags); virtual int Shutdown(); + virtual int MemoryUsage() const; + virtual void Minimize(); virtual void Maximize(); virtual int WindowActive(); diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 8653b62a0..751e4ad2c 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -228,7 +228,7 @@ void CGraphics_Threaded::WrapClamp() int CGraphics_Threaded::MemoryUsage() const { - return m_TextureMemoryUsage; + return m_pBackend->MemoryUsage(); } void CGraphics_Threaded::MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY) @@ -293,8 +293,7 @@ int CGraphics_Threaded::UnloadTexture(int Index) Cmd.m_Slot = Index; m_pCommandBuffer->AddCommand(Cmd); - m_aTextures[Index].m_Next = m_FirstFreeTexture; - m_TextureMemoryUsage -= m_aTextures[Index].m_MemSize; + m_aTextures[Index] = m_FirstFreeTexture; m_FirstFreeTexture = Index; return 0; } @@ -307,6 +306,16 @@ static int ImageFormatToTexFormat(int Format) return CCommandBuffer::TEXFORMAT_RGBA; } +static int ImageFormatToPixelSize(int Format) +{ + switch(Format) + { + case CImageInfo::FORMAT_RGB: return 3; + case CImageInfo::FORMAT_ALPHA: return 1; + default: return 4; + } +} + int CGraphics_Threaded::LoadTextureRawSub(int TextureID, int x, int y, int Width, int Height, int Format, const void *pData) { @@ -319,13 +328,7 @@ int CGraphics_Threaded::LoadTextureRawSub(int TextureID, int x, int y, int Width Cmd.m_Format = ImageFormatToTexFormat(Format); // calculate memory usage - int PixelSize = 4; - if(Format == CImageInfo::FORMAT_RGB) - PixelSize = 3; - else if(Format == CImageInfo::FORMAT_ALPHA) - PixelSize = 1; - - int MemSize = Width*Height*PixelSize; + int MemSize = Width*Height*ImageFormatToPixelSize(Format); // copy texture data void *pTmpData = mem_alloc(MemSize, sizeof(void*)); @@ -345,13 +348,14 @@ int CGraphics_Threaded::LoadTextureRaw(int Width, int Height, int Format, const // grab texture int Tex = m_FirstFreeTexture; - m_FirstFreeTexture = m_aTextures[Tex].m_Next; - m_aTextures[Tex].m_Next = -1; + m_FirstFreeTexture = m_aTextureIndices[Tex]; + m_aTextureIndices[Tex] = -1; CCommandBuffer::SCommand_Texture_Create Cmd; Cmd.m_Slot = Tex; Cmd.m_Width = Width; Cmd.m_Height = Height; + Cmd.m_PixelSize = ImageFormatToPixelSize(Format); Cmd.m_Format = ImageFormatToTexFormat(Format); Cmd.m_StoreFormat = ImageFormatToTexFormat(StoreFormat); @@ -362,16 +366,8 @@ int CGraphics_Threaded::LoadTextureRaw(int Width, int Height, int Format, const if(g_Config.m_GfxTextureCompression) Cmd.m_Flags |= CCommandBuffer::TEXFLAG_COMPRESSED; - // calculate memory usage - int PixelSize = 4; - if(Format == CImageInfo::FORMAT_RGB) - PixelSize = 3; - else if(Format == CImageInfo::FORMAT_ALPHA) - PixelSize = 1; - - int MemSize = Width*Height*PixelSize; - // copy texture data + int MemSize = Width*Height*Cmd.m_PixelSize; void *pTmpData = mem_alloc(MemSize, sizeof(void*)); mem_copy(pTmpData, pData, MemSize); Cmd.m_pData = pTmpData; @@ -379,17 +375,6 @@ int CGraphics_Threaded::LoadTextureRaw(int Width, int Height, int Format, const // m_pCommandBuffer->AddCommand(Cmd); - // calculate memory usage - int MemUsage = MemSize; - while(Width > 2 && Height > 2) - { - Width>>=1; - Height>>=1; - MemUsage += Width*Height*PixelSize; - } - - m_TextureMemoryUsage += MemUsage; - //mem_free(pTmpData); return Tex; } @@ -775,9 +760,9 @@ int CGraphics_Threaded::Init() // init textures m_FirstFreeTexture = 0; - for(int i = 0; i < MAX_TEXTURES; i++) - m_aTextures[i].m_Next = i+1; - m_aTextures[MAX_TEXTURES-1].m_Next = -1; + for(int i = 0; i < MAX_TEXTURES-1; i++) + m_aTextureIndices[i] = i+1; + m_aTextureIndices[MAX_TEXTURES-1] = -1; m_pBackend = CreateGraphicsBackend(); if(InitWindow() != 0) diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index e482f6e5d..6b3963eea 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -57,7 +57,8 @@ public: { // commadn groups CMDGROUP_CORE = 0, // commands that everyone has to implement - CMDGROUP_PLATFORM = 10000, // commands specific to a platform + CMDGROUP_PLATFORM_OPENGL = 10000, // commands specific to a platform + CMDGROUP_PLATFORM_SDL = 20000, // CMD_NOP = CMDGROUP_CORE, @@ -211,6 +212,7 @@ public: int m_Width; int m_Height; + int m_PixelSize; int m_Format; int m_StoreFormat; int m_Flags; @@ -302,6 +304,8 @@ public: virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags) = 0; virtual int Shutdown() = 0; + virtual int MemoryUsage() const = 0; + virtual void Minimize() = 0; virtual void Maximize() = 0; virtual int WindowActive() = 0; @@ -351,15 +355,7 @@ class CGraphics_Threaded : public IEngineGraphics int m_InvalidTexture; - struct CTexture - { - int m_State; - int m_MemSize; - int m_Flags; - int m_Next; - }; - - CTexture m_aTextures[MAX_TEXTURES]; + int m_aTextureIndices[MAX_TEXTURES]; int m_FirstFreeTexture; int m_TextureMemoryUsage; From df5ab998c276e34a4870085d6ddafd812a9b1912 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 7 Oct 2012 11:22:49 +0200 Subject: [PATCH 50/84] readded texture resampling --- src/engine/client/backend_sdl.cpp | 76 +++++++++++++++++++++++-- src/engine/client/backend_sdl.h | 2 + src/engine/client/graphics_threaded.cpp | 37 +----------- src/engine/client/graphics_threaded.h | 4 +- 4 files changed, 76 insertions(+), 43 deletions(-) diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index d99f765bf..6fa6de017 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -100,6 +100,41 @@ int CCommandProcessorFragment_OpenGL::TexFormatToOpenGLFormat(int TexFormat) return GL_RGBA; } +unsigned char CCommandProcessorFragment_OpenGL::Sample(int w, int h, const unsigned char *pData, int u, int v, int Offset, int ScaleW, int ScaleH, int Bpp) +{ + int Value = 0; + for(int x = 0; x < ScaleW; x++) + for(int y = 0; y < ScaleH; y++) + Value += pData[((v+y)*w+(u+x))*Bpp+Offset]; + return Value/(ScaleW*ScaleH); +} + +void *CCommandProcessorFragment_OpenGL::Rescale(int Width, int Height, int NewWidth, int NewHeight, int Format, const unsigned char *pData) +{ + unsigned char *pTmpData; + int ScaleW = Width/NewWidth; + int ScaleH = Height/NewHeight; + + int Bpp = 3; + if(Format == CCommandBuffer::TEXFORMAT_RGBA) + Bpp = 4; + + pTmpData = (unsigned char *)mem_alloc(NewWidth*NewHeight*Bpp, 1); + + int c = 0; + for(int y = 0; y < NewHeight; y++) + for(int x = 0; x < NewWidth; x++, c++) + { + pTmpData[c*Bpp] = Sample(Width, Height, pData, x*ScaleW, y*ScaleH, 0, ScaleW, ScaleH, Bpp); + pTmpData[c*Bpp+1] = Sample(Width, Height, pData, x*ScaleW, y*ScaleH, 1, ScaleW, ScaleH, Bpp); + pTmpData[c*Bpp+2] = Sample(Width, Height, pData, x*ScaleW, y*ScaleH, 2, ScaleW, ScaleH, Bpp); + if(Bpp == 4) + pTmpData[c*Bpp+3] = Sample(Width, Height, pData, x*ScaleW, y*ScaleH, 3, ScaleW, ScaleH, Bpp); + } + + return pTmpData; +} + void CCommandProcessorFragment_OpenGL::SetState(const CCommandBuffer::SState &State) { // blend @@ -179,6 +214,39 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Destroy(const CCommandBuffer: void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand) { + int Width = pCommand->m_Width; + int Height = pCommand->m_Height; + void *pTexData = pCommand->m_pData; + + // resample if needed + if(pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGBA || pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGB) + { + int MaxTexSize; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &MaxTexSize); + if(Width > MaxTexSize || Height > MaxTexSize) + { + do + { + Width>>=1; + Height>>=1; + } + while(Width > MaxTexSize || Height > MaxTexSize); + + void *pTmpData = Rescale(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast(pCommand->m_pData)); + mem_free(pTexData); + pTexData = pTmpData; + } + else if(Width > 16 && Height > 16 && (pCommand->m_Flags&CCommandBuffer::TEXFLAG_QUALITY) == 0) + { + Width>>=1; + Height>>=1; + + void *pTmpData = Rescale(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast(pCommand->m_pData)); + mem_free(pTexData); + pTexData = pTmpData; + } + } + int Oglformat = TexFormatToOpenGLFormat(pCommand->m_Format); int StoreOglformat = TexFormatToOpenGLFormat(pCommand->m_StoreFormat); @@ -199,18 +267,16 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer:: { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, StoreOglformat, pCommand->m_Width, pCommand->m_Height, 0, Oglformat, GL_UNSIGNED_BYTE, pCommand->m_pData); + glTexImage2D(GL_TEXTURE_2D, 0, StoreOglformat, Width, Height, 0, Oglformat, GL_UNSIGNED_BYTE, pTexData); } else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); - gluBuild2DMipmaps(GL_TEXTURE_2D, StoreOglformat, pCommand->m_Width, pCommand->m_Height, Oglformat, GL_UNSIGNED_BYTE, pCommand->m_pData); + gluBuild2DMipmaps(GL_TEXTURE_2D, StoreOglformat, Width, Height, Oglformat, GL_UNSIGNED_BYTE, pTexData); } // calculate memory usage - int Width = pCommand->m_Width; - int Height = pCommand->m_Height; m_aTextures[pCommand->m_Slot].m_MemSize = Width*Height*pCommand->m_PixelSize; while(Width > 2 && Height > 2) { @@ -220,7 +286,7 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer:: } *m_pTextureMemoryUsage += m_aTextures[pCommand->m_Slot].m_MemSize; - mem_free(pCommand->m_pData); + mem_free(pTexData); } void CCommandProcessorFragment_OpenGL::Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand) diff --git a/src/engine/client/backend_sdl.h b/src/engine/client/backend_sdl.h index e1fc60b0c..e90f9455d 100644 --- a/src/engine/client/backend_sdl.h +++ b/src/engine/client/backend_sdl.h @@ -189,6 +189,8 @@ public: private: static int TexFormatToOpenGLFormat(int TexFormat); + static unsigned char Sample(int w, int h, const unsigned char *pData, int u, int v, int Offset, int ScaleW, int ScaleH, int Bpp); + static void *Rescale(int Width, int Height, int NewWidth, int NewHeight, int Format, const unsigned char *pData); void SetState(const CCommandBuffer::SState &State); diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 751e4ad2c..7a2687c51 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -107,41 +107,6 @@ void CGraphics_Threaded::Rotate4(const CCommandBuffer::SPoint &rCenter, CCommand } } -unsigned char CGraphics_Threaded::Sample(int w, int h, const unsigned char *pData, int u, int v, int Offset, int ScaleW, int ScaleH, int Bpp) -{ - int Value = 0; - for(int x = 0; x < ScaleW; x++) - for(int y = 0; y < ScaleH; y++) - Value += pData[((v+y)*w+(u+x))*Bpp+Offset]; - return Value/(ScaleW*ScaleH); -} - -unsigned char *CGraphics_Threaded::Rescale(int Width, int Height, int NewWidth, int NewHeight, int Format, const unsigned char *pData) -{ - unsigned char *pTmpData; - int ScaleW = Width/NewWidth; - int ScaleH = Height/NewHeight; - - int Bpp = 3; - if(Format == CImageInfo::FORMAT_RGBA) - Bpp = 4; - - pTmpData = (unsigned char *)mem_alloc(NewWidth*NewHeight*Bpp, 1); - - int c = 0; - for(int y = 0; y < NewHeight; y++) - for(int x = 0; x < NewWidth; x++, c++) - { - pTmpData[c*Bpp] = Sample(Width, Height, pData, x*ScaleW, y*ScaleH, 0, ScaleW, ScaleH, Bpp); - pTmpData[c*Bpp+1] = Sample(Width, Height, pData, x*ScaleW, y*ScaleH, 1, ScaleW, ScaleH, Bpp); - pTmpData[c*Bpp+2] = Sample(Width, Height, pData, x*ScaleW, y*ScaleH, 2, ScaleW, ScaleH, Bpp); - if(Bpp == 4) - pTmpData[c*Bpp+3] = Sample(Width, Height, pData, x*ScaleW, y*ScaleH, 3, ScaleW, ScaleH, Bpp); - } - - return pTmpData; -} - CGraphics_Threaded::CGraphics_Threaded() { m_State.m_ScreenTL.x = 0; @@ -365,6 +330,8 @@ int CGraphics_Threaded::LoadTextureRaw(int Width, int Height, int Format, const Cmd.m_Flags |= CCommandBuffer::TEXFLAG_NOMIPMAPS; if(g_Config.m_GfxTextureCompression) Cmd.m_Flags |= CCommandBuffer::TEXFLAG_COMPRESSED; + if(g_Config.m_GfxTextureQuality || Flags&TEXLOAD_NORESAMPLE) + Cmd.m_Flags |= CCommandBuffer::TEXFLAG_QUALITY; // copy texture data int MemSize = Width*Height*Cmd.m_PixelSize; diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 6b3963eea..809a383a0 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -96,6 +96,7 @@ public: TEXFLAG_NOMIPMAPS = 1, TEXFLAG_COMPRESSED = 2, + TEXFLAG_QUALITY = 4, }; enum @@ -363,9 +364,6 @@ class CGraphics_Threaded : public IEngineGraphics void AddVertices(int Count); void Rotate4(const CCommandBuffer::SPoint &rCenter, CCommandBuffer::SVertex *pPoints); - static unsigned char Sample(int w, int h, const unsigned char *pData, int u, int v, int Offset, int ScaleW, int ScaleH, int Bpp); - static unsigned char *Rescale(int Width, int Height, int NewWidth, int NewHeight, int Format, const unsigned char *pData); - void KickCommandBuffer(); int IssueInit(); From 0be51ca98aec2f44cd01a5bf7c3a78fdfd78ea3d Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 7 Oct 2012 15:35:33 +0200 Subject: [PATCH 51/84] added a check for ppc building on mac os x. Closes #1006 --- bam.lua | 59 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/bam.lua b/bam.lua index c81574262..11ac7b9e5 100644 --- a/bam.lua +++ b/bam.lua @@ -9,6 +9,7 @@ config = NewConfig() config:Add(OptCCompiler("compiler")) config:Add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-protector -fstack-protector-all")) config:Add(OptTestCompileC("minmacosxsdk", "int main(){return 0;}", "-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk")) +config:Add(OptTestCompileC("macosxppc", "int main(){return 0;}", "-arch ppc")) config:Add(OptLibrary("zlib", "zlib.h", false)) config:Add(SDL.OptFind("sdl", true)) config:Add(FreeType.OptFind("freetype", true)) @@ -363,27 +364,45 @@ if platform == "macosx" then DefaultTarget("game_debug_x86") - if arch == "ia32" then - PseudoTarget("release", ppc_r, x86_r) - PseudoTarget("debug", ppc_d, x86_d) - PseudoTarget("server_release", "server_release_x86", "server_release_ppc") - PseudoTarget("server_debug", "server_debug_x86", "server_debug_ppc") - PseudoTarget("client_release", "client_release_x86", "client_release_ppc") - PseudoTarget("client_debug", "client_debug_x86", "client_debug_ppc") - elseif arch == "amd64" then - PseudoTarget("release", ppc_r, x86_r, x86_64_r) - PseudoTarget("debug", ppc_d, x86_d, x86_64_d) - PseudoTarget("server_release", "server_release_x86", "server_release_x86_64", "server_release_ppc") - PseudoTarget("server_debug", "server_debug_x86", "server_debug_x86_64", "server_debug_ppc") - PseudoTarget("client_release", "client_release_x86", "client_release_x86_64", "client_release_ppc") - PseudoTarget("client_debug", "client_debug_x86", "client_debug_x86_64", "client_debug_ppc") + if config.macosxppc.value == 1 then + if arch == "ia32" then + PseudoTarget("release", ppc_r, x86_r) + PseudoTarget("debug", ppc_d, x86_d) + PseudoTarget("server_release", "server_release_ppc", "server_release_x86") + PseudoTarget("server_debug", "server_debug_ppc", "server_debug_x86") + PseudoTarget("client_release", "client_release_ppc", "client_release_x86") + PseudoTarget("client_debug", "client_debug_ppc", "client_debug_x86") + elseif arch == "amd64" then + PseudoTarget("release", ppc_r, x86_r, x86_64_r) + PseudoTarget("debug", ppc_d, x86_d, x86_64_d) + PseudoTarget("server_release", "server_release_ppc", "server_release_x86", "server_release_x86_64") + PseudoTarget("server_debug", "server_debug_ppc", "server_debug_x86", "server_debug_x86_64") + PseudoTarget("client_release", "client_release_ppc", "client_release_x86", "client_release_x86_64") + PseudoTarget("client_debug", "client_debug_ppc", "client_debug_x86", "client_debug_x86_64") + else + PseudoTarget("release", ppc_r) + PseudoTarget("debug", ppc_d) + PseudoTarget("server_release", "server_release_ppc") + PseudoTarget("server_debug", "server_debug_ppc") + PseudoTarget("client_release", "client_release_ppc") + PseudoTarget("client_debug", "client_debug_ppc") + end else - PseudoTarget("release", ppc_r) - PseudoTarget("debug", ppc_d) - PseudoTarget("server_release", "server_release_ppc") - PseudoTarget("server_debug", "server_debug_ppc") - PseudoTarget("client_release", "client_release_ppc") - PseudoTarget("client_debug", "client_debug_ppc") + if arch == "ia32" then + PseudoTarget("release", x86_r) + PseudoTarget("debug", x86_d) + PseudoTarget("server_release", "server_release_x86") + PseudoTarget("server_debug", "server_debug_x86") + PseudoTarget("client_release", "client_release_x86") + PseudoTarget("client_debug", "client_debug_x86") + elseif arch == "amd64" then + PseudoTarget("release", x86_r, x86_64_r) + PseudoTarget("debug", x86_d, x86_64_d) + PseudoTarget("server_release", "server_release_x86", "server_release_x86_64") + PseudoTarget("server_debug", "server_debug_x86", "server_debug_x86_64") + PseudoTarget("client_release", "client_release_x86", "client_release_x86_64") + PseudoTarget("client_debug", "client_debug_x86", "client_debug_x86_64") + end end else build(debug_settings) From d58afefaae99f239151483025e516e8da5b6dd17 Mon Sep 17 00:00:00 2001 From: BeaR Date: Sun, 14 Oct 2012 14:04:48 +0200 Subject: [PATCH 52/84] 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 | 175 ++++++++++++++---------- src/game/editor/editor.h | 2 +- src/game/editor/layer_tiles.cpp | 6 +- 7 files changed, 124 insertions(+), 88 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index a88fe3cbe..c481102bd 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 7a2687c51..8a3e4f509 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 809a383a0..ff03c6bb3 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 7f272497a..a2fe47413 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 7109adcaf..07f50110f 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; + if(!apEnvelope[j]) + continue; - //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); + //QuadParams + CPoint *pPoints = pQuad[j].m_aPoints; - //Rotation - if(Rot != 0) + for(int i = 0; i < apEnvelope[j]->m_lPoints.size(); i++) { - 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; + //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; - 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 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); } - - //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); - - Graphics()->QuadsEnd(); - - Graphics()->TextureSet(-1); - Graphics()->QuadsBegin(); - DoQuadEnvPoint(pQuad, Index, i); - Graphics()->QuadsEnd(); } + 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 a81474d96..2807d35cd 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 325d527b7..032f391f8 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); } From 8b4026cbbfb2cf04da8ee47f0b6b30d228cfebaf Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 21 Oct 2012 14:49:26 +0200 Subject: [PATCH 53/84] 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(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 07f50110f..ccd1757f0 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 2807d35cd..19a8752ef 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); From 68390fe04afce9767b152eadaefd9a3bc8462854 Mon Sep 17 00:00:00 2001 From: BeaR Date: Tue, 13 Nov 2012 15:39:23 +0100 Subject: [PATCH 54/84] Bug: Losing render-commands if commandbuffer is full(gfx) Problem: If there is a new draw call, it is checked if there is enough free memory for the vertices in the databuffer but not if we have enough free space in the commandbuffer to add the command So we lose some commands during a frame cuz the commandbuffer is full This fixes the 2nd part of issue 1004 --- src/engine/client/graphics_threaded.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 8a3e4f509..50a116b4e 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -81,7 +81,19 @@ void CGraphics_Threaded::FlushVertices() } mem_copy(Cmd.m_pVertices, m_aVertices, sizeof(CCommandBuffer::SVertex)*NumVerts); - m_pCommandBuffer->AddCommand(Cmd); + + // check if we have enough free memory in the commandbuffer + if(!m_pCommandBuffer->AddCommand(Cmd)) + { + // kick command buffer and try again + KickCommandBuffer(); + + if(!m_pCommandBuffer->AddCommand(Cmd)) + { + dbg_msg("graphics", "failed to allocate memory for render command"); + return; + } + } } void CGraphics_Threaded::AddVertices(int Count) From 73386fdf0f23563e1c4a92857810f8103407fd6b Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 13 Nov 2012 21:37:46 +0100 Subject: [PATCH 55/84] fixed last commit --- src/engine/client/graphics_threaded.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 50a116b4e..0357c41a3 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -80,13 +80,18 @@ void CGraphics_Threaded::FlushVertices() } } - mem_copy(Cmd.m_pVertices, m_aVertices, sizeof(CCommandBuffer::SVertex)*NumVerts); - // check if we have enough free memory in the commandbuffer if(!m_pCommandBuffer->AddCommand(Cmd)) { // kick command buffer and try again KickCommandBuffer(); + + Cmd.m_pVertices = (CCommandBuffer::SVertex *)m_pCommandBuffer->AllocData(sizeof(CCommandBuffer::SVertex)*NumVerts); + if(Cmd.m_pVertices == 0x0) + { + dbg_msg("graphics", "failed to allocate data for vertices"); + return; + } if(!m_pCommandBuffer->AddCommand(Cmd)) { @@ -94,6 +99,8 @@ void CGraphics_Threaded::FlushVertices() return; } } + + mem_copy(Cmd.m_pVertices, m_aVertices, sizeof(CCommandBuffer::SVertex)*NumVerts); } void CGraphics_Threaded::AddVertices(int Count) From 07c97822bba0f7b59c911aab2d6e85f84785b6ed Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 20 Feb 2013 15:51:46 +0100 Subject: [PATCH 56/84] increased sleep time when tw is minimized and made it adjustable via cputhrottle otherwise --- src/engine/client/client.cpp | 6 +++--- src/engine/shared/config_variables.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index c481102bd..30f92eb0b 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1945,10 +1945,10 @@ void CClient::Run() break; // beNice - if(g_Config.m_DbgStress) + if(g_Config.m_ClCpuThrottle) + thread_sleep(g_Config.m_ClCpuThrottle); + else if(g_Config.m_DbgStress || !m_pGraphics->WindowActive()) thread_sleep(5); - else if(g_Config.m_ClCpuThrottle || !m_pGraphics->WindowActive()) - thread_sleep(1); if(g_Config.m_DbgHitch) { diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 659d10877..3215ee0e9 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -15,7 +15,7 @@ MACRO_CONFIG_STR(Password, password, 32, "", CFGFLAG_CLIENT|CFGFLAG_SERVER, "Pas MACRO_CONFIG_STR(Logfile, logfile, 128, "", CFGFLAG_SAVE|CFGFLAG_CLIENT|CFGFLAG_SERVER, "Filename to log all output to") MACRO_CONFIG_INT(ConsoleOutputLevel, console_output_level, 0, 0, 2, CFGFLAG_CLIENT|CFGFLAG_SERVER, "Adjusts the amount of information in the console") -MACRO_CONFIG_INT(ClCpuThrottle, cl_cpu_throttle, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "") +MACRO_CONFIG_INT(ClCpuThrottle, cl_cpu_throttle, 0, 0, 100, CFGFLAG_SAVE|CFGFLAG_CLIENT, "") MACRO_CONFIG_INT(ClEditor, cl_editor, 0, 0, 1, CFGFLAG_CLIENT, "") MACRO_CONFIG_INT(ClLoadCountryFlags, cl_load_country_flags, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Load and show country flags") From 118d2ac837537cd625679a57aca03cd47f2e71a1 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 20 Feb 2013 16:49:21 +0100 Subject: [PATCH 57/84] show reason for closing a connection within a debug message. Closes #1061 --- src/engine/shared/network_conn.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/engine/shared/network_conn.cpp b/src/engine/shared/network_conn.cpp index 24c8f066f..cd2df048e 100644 --- a/src/engine/shared/network_conn.cpp +++ b/src/engine/shared/network_conn.cpp @@ -214,27 +214,25 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr) m_State = NET_CONNSTATE_ERROR; m_RemoteClosed = 1; + char Str[128] = {0}; + if(pPacket->m_DataSize > 1) + { + // make sure to sanitize the error string form the other party + if(pPacket->m_DataSize < 128) + str_copy(Str, (char *)&pPacket->m_aChunkData[1], pPacket->m_DataSize); + else + str_copy(Str, (char *)&pPacket->m_aChunkData[1], sizeof(Str)); + str_sanitize_strong(Str); + } + if(!m_BlockCloseMsg) { - if(pPacket->m_DataSize) - { - // make sure to sanitize the error string form the other party - char Str[128]; - if(pPacket->m_DataSize < 128) - str_copy(Str, (char *)pPacket->m_aChunkData, pPacket->m_DataSize); - else - str_copy(Str, (char *)pPacket->m_aChunkData, sizeof(Str)); - str_sanitize_strong(Str); - - // set the error string - SetError(Str); - } - else - SetError("No reason given"); + // set the error string + SetError(Str); } if(g_Config.m_Debug) - dbg_msg("conn", "closed reason='%s'", ErrorString()); + dbg_msg("conn", "closed reason='%s'", Str); } return 0; } From 0e92dd560300a0b255b5c173e715f2714e7c1765 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Feb 2013 18:55:55 +0100 Subject: [PATCH 58/84] 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(-) diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index 314669e21..3168903db 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 fdd83aa7b..670c22b40 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 0357c41a3..e34b72595 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 ccd1757f0..28a4eda96 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 9e45c1fe9..140dadf97 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 da55e7175..9d6e2960c 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, From 313a0949b0c4d077e61051fd773208d889649c37 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Feb 2013 18:57:23 +0100 Subject: [PATCH 59/84] make sure clients are authed for map downloads --- src/engine/server/server.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 4b7f63329..581c7e673 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -841,6 +841,9 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) } else if(Msg == NETMSG_REQUEST_MAP_DATA) { + if(m_aClients[ClientID].m_State < CClient::STATE_CONNECTING) + return; + int Chunk = Unpacker.GetInt(); int ChunkSize = 1024-128; int Offset = Chunk * ChunkSize; From ea2898e94a6d50e326cb68976d9fabbc378a3b9d Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Feb 2013 19:13:45 +0100 Subject: [PATCH 60/84] prevent quick join/quit flood. #1070 --- src/engine/shared/network.h | 1 + src/engine/shared/network_server.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/engine/shared/network.h b/src/engine/shared/network.h index fbe4d3919..259d600f2 100644 --- a/src/engine/shared/network.h +++ b/src/engine/shared/network.h @@ -188,6 +188,7 @@ public: // Needed for GotProblems in NetClient int64 LastRecvTime() const { return m_LastRecvTime; } + int64 ConnectTime() const { return m_LastUpdateTime; } int AckSequence() const { return m_Ack; } }; diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index add51c9bb..bdc10935c 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -69,11 +69,17 @@ int CNetServer::Drop(int ClientID, const char *pReason) int CNetServer::Update() { + int64 Now = time_get(); for(int i = 0; i < MaxClients(); i++) { m_aSlots[i].m_Connection.Update(); if(m_aSlots[i].m_Connection.State() == NET_CONNSTATE_ERROR) - Drop(i, m_aSlots[i].m_Connection.ErrorString()); + { + if(Now - m_aSlots[i].m_Connection.ConnectTime() < time_freq()/2 && NetBan()) + NetBan()->BanAddr(ClientAddr(i), 60, "Stressing network"); + else + Drop(i, m_aSlots[i].m_Connection.ErrorString()); + } } return 0; From 718653ff85e8cfbda407ccc467dcbfc36895b16c Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Feb 2013 19:18:13 +0100 Subject: [PATCH 61/84] set default values for threaded graphics and async renderer to 0 --- src/engine/shared/config_variables.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 3215ee0e9..473272962 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -72,9 +72,9 @@ MACRO_CONFIG_INT(GfxTextureQuality, gfx_texture_quality, 1, 0, 1, CFGFLAG_SAVE|C MACRO_CONFIG_INT(GfxFsaaSamples, gfx_fsaa_samples, 0, 0, 16, CFGFLAG_SAVE|CFGFLAG_CLIENT, "FSAA Samples") MACRO_CONFIG_INT(GfxRefreshRate, gfx_refresh_rate, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Screen refresh rate") MACRO_CONFIG_INT(GfxFinish, gfx_finish, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "") -MACRO_CONFIG_INT(GfxAsyncRender, gfx_asyncrender, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Do rendering async from the the update") +MACRO_CONFIG_INT(GfxAsyncRender, gfx_asyncrender, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Do rendering async from the the update") -MACRO_CONFIG_INT(GfxThreaded, gfx_threaded, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Use the threaded graphics backend") +MACRO_CONFIG_INT(GfxThreaded, gfx_threaded, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Use the threaded graphics backend") MACRO_CONFIG_INT(InpMousesens, inp_mousesens, 100, 5, 100000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Mouse sensitivity") From f010791231c95eed49c63ce3f2e6809b8c932f27 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Feb 2013 19:43:09 +0100 Subject: [PATCH 62/84] 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(-) diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 467ef5001..b2434d910 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 3d909e368..ee41dbe82 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 From ebdd1af7a3fbf609f7123e8355f18ca980b1921e Mon Sep 17 00:00:00 2001 From: PsychoGod Date: Mon, 25 Feb 2013 13:48:31 +0200 Subject: [PATCH 63/84] window center position when windowed on Windows :3 --- src/engine/client/backend_sdl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 6fa6de017..37d1019ae 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -499,7 +499,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height #ifdef CONF_FAMILY_WINDOWS if(!getenv("SDL_VIDEO_WINDOW_POS") && !getenv("SDL_VIDEO_CENTERED")) // ignore_convention - putenv("SDL_VIDEO_WINDOW_POS=8,27"); // ignore_convention + putenv("SDL_VIDEO_WINDOW_POS=center"); // ignore_convention #endif } From 2f1389e5cd45722863b877adf7031c585dfcf44b Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 25 Feb 2013 22:31:30 +0100 Subject: [PATCH 64/84] fixed version string of the versionserver --- src/game/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/version.h b/src/game/version.h index ee41dbe82..76d95dd07 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 From 5e090fbfed8af54a98a6ab71d895fad04d1bf398 Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 26 Feb 2013 00:00:38 +0100 Subject: [PATCH 65/84] made the demoplayer support 0.6.1 based demos --- src/engine/demo.h | 4 ++++ src/engine/shared/demo.cpp | 30 ++++++++++++++++++------------ src/engine/shared/demo.h | 1 + 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/engine/demo.h b/src/engine/demo.h index 7b7365c7e..bd4a307af 100644 --- a/src/engine/demo.h +++ b/src/engine/demo.h @@ -21,6 +21,10 @@ struct CDemoHeader char m_aType[8]; char m_aLength[4]; char m_aTimestamp[20]; +}; + +struct CTimelineMarkers +{ char m_aNumTimelineMarkers[4]; char m_aTimelineMarkers[MAX_TIMELINE_MARKERS][4]; }; diff --git a/src/engine/shared/demo.cpp b/src/engine/shared/demo.cpp index 37c82cce3..953d8b56a 100644 --- a/src/engine/shared/demo.cpp +++ b/src/engine/shared/demo.cpp @@ -14,6 +14,7 @@ static const unsigned char gs_aHeaderMarker[7] = {'T', 'W', 'D', 'E', 'M', 'O', 0}; static const unsigned char gs_ActVersion = 4; +static const unsigned char gs_OldVersion = 3; static const int gs_LengthOffset = 152; static const int gs_NumMarkersOffset = 176; @@ -29,6 +30,7 @@ CDemoRecorder::CDemoRecorder(class CSnapshotDelta *pSnapshotDelta) int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, const char *pNetVersion, const char *pMap, unsigned Crc, const char *pType) { CDemoHeader Header; + CTimelineMarkers TimelineMarkers; if(m_File) return -1; @@ -90,9 +92,8 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con str_copy(Header.m_aType, pType, sizeof(Header.m_aType)); // Header.m_Length - add this on stop str_timestamp(Header.m_aTimestamp, sizeof(Header.m_aTimestamp)); - // Header.m_aNumTimelineMarkers - add this on stop - // Header.m_aTimelineMarkers - add this on stop io_write(DemoFile, &Header, sizeof(Header)); + io_write(DemoFile, &TimelineMarkers, sizeof(TimelineMarkers)); // fill this on stop // write map data while(1) @@ -615,7 +616,7 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const return -1; } - if(m_Info.m_Header.m_Version < gs_ActVersion) + if(m_Info.m_Header.m_Version < gs_OldVersion) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "demo version %d is not supported", m_Info.m_Header.m_Version); @@ -624,6 +625,8 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const m_File = 0; return -1; } + else if(m_Info.m_Header.m_Version > gs_OldVersion) + io_read(m_File, &m_Info.m_TimelineMarkers, sizeof(m_Info.m_TimelineMarkers)); // get demo type if(!str_comp(m_Info.m_Header.m_aType, "client")) @@ -663,15 +666,18 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const mem_free(pMapData); } - // get timeline markers - int Num = ((m_Info.m_Header.m_aNumTimelineMarkers[0]<<24)&0xFF000000) | ((m_Info.m_Header.m_aNumTimelineMarkers[1]<<16)&0xFF0000) | - ((m_Info.m_Header.m_aNumTimelineMarkers[2]<<8)&0xFF00) | (m_Info.m_Header.m_aNumTimelineMarkers[3]&0xFF); - m_Info.m_Info.m_NumTimelineMarkers = Num; - for(int i = 0; i < Num && i < MAX_TIMELINE_MARKERS; i++) + if(m_Info.m_Header.m_Version > gs_OldVersion) { - char *pTimelineMarker = m_Info.m_Header.m_aTimelineMarkers[i]; - m_Info.m_Info.m_aTimelineMarkers[i] = ((pTimelineMarker[0]<<24)&0xFF000000) | ((pTimelineMarker[1]<<16)&0xFF0000) | - ((pTimelineMarker[2]<<8)&0xFF00) | (pTimelineMarker[3]&0xFF); + // get timeline markers + int Num = ((m_Info.m_TimelineMarkers.m_aNumTimelineMarkers[0]<<24)&0xFF000000) | ((m_Info.m_TimelineMarkers.m_aNumTimelineMarkers[1]<<16)&0xFF0000) | + ((m_Info.m_TimelineMarkers.m_aNumTimelineMarkers[2]<<8)&0xFF00) | (m_Info.m_TimelineMarkers.m_aNumTimelineMarkers[3]&0xFF); + m_Info.m_Info.m_NumTimelineMarkers = Num; + for(int i = 0; i < Num && i < MAX_TIMELINE_MARKERS; i++) + { + char *pTimelineMarker = m_Info.m_TimelineMarkers.m_aTimelineMarkers[i]; + m_Info.m_Info.m_aTimelineMarkers[i] = ((pTimelineMarker[0]<<24)&0xFF000000) | ((pTimelineMarker[1]<<16)&0xFF0000) | + ((pTimelineMarker[2]<<8)&0xFF00) | (pTimelineMarker[3]&0xFF); + } } // scan the file for interessting points @@ -843,7 +849,7 @@ bool CDemoPlayer::GetDemoInfo(class IStorage *pStorage, const char *pFilename, i return false; io_read(File, pDemoHeader, sizeof(CDemoHeader)); - if(mem_comp(pDemoHeader->m_aMarker, gs_aHeaderMarker, sizeof(gs_aHeaderMarker)) || pDemoHeader->m_Version < gs_ActVersion) + if(mem_comp(pDemoHeader->m_aMarker, gs_aHeaderMarker, sizeof(gs_aHeaderMarker)) || pDemoHeader->m_Version < gs_OldVersion) { io_close(File); return false; diff --git a/src/engine/shared/demo.h b/src/engine/shared/demo.h index 760e7256a..d27f4ab69 100644 --- a/src/engine/shared/demo.h +++ b/src/engine/shared/demo.h @@ -51,6 +51,7 @@ public: struct CPlaybackInfo { CDemoHeader m_Header; + CTimelineMarkers m_TimelineMarkers; IDemoPlayer::CInfo m_Info; From 5de3192c27118c53dd5252f55cfd5206c2e57146 Mon Sep 17 00:00:00 2001 From: chingis Date: Thu, 28 Feb 2013 17:27:12 +0600 Subject: [PATCH 66/84] Update index.txt add kyrgyz --- data/languages/index.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data/languages/index.txt b/data/languages/index.txt index b7a6179b3..751c6bfa5 100644 --- a/data/languages/index.txt +++ b/data/languages/index.txt @@ -1,4 +1,3 @@ - ##### language indices ##### belarusian @@ -49,6 +48,10 @@ italian == Italiano == 380 +kyrgyz +== Кыргызча +== 417 + norwegian == Norsk == 578 From e25a002fa4547e04b39fe0bec3a6d2b31783447b Mon Sep 17 00:00:00 2001 From: chingis Date: Thu, 28 Feb 2013 17:28:45 +0600 Subject: [PATCH 67/84] kyrgyz.txt kyrgyz translation --- data/languages/kyrgyz.txt | 687 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 687 insertions(+) create mode 100644 data/languages/kyrgyz.txt diff --git a/data/languages/kyrgyz.txt b/data/languages/kyrgyz.txt new file mode 100644 index 000000000..48c745eb2 --- /dev/null +++ b/data/languages/kyrgyz.txt @@ -0,0 +1,687 @@ + +##### translated strings ##### + +%d Bytes +== %d байт + +%d of %d servers, %d players +== %d/%d сервер, %d оюнчу + +%d%% loaded +== %d%% жүктөлдү + +%ds left +== %d сек. калды + +%i minute left +== %i минута калды! + +%i minutes left +== %i минута калды! + +%i second left +== %i секунда калды! + +%i seconds left +== %i секунда калды! + +%s wins! +== %s утту! + +-Page %d- +== -Барак %d- + +Abort +== Жокко чыгаруу + +Add +== Кошуу + +Add Friend +== Досту кошуу + +Address +== Дареги + +All +== Баары + +Alpha +== Тунук. + +Always show name plates +== Оюнчулардын аттарын дайыма көрсөтүү + +Are you sure that you want to delete the demo? +== Сиз анык эле демонун өчүрүлүшүн каалайсызбы? + +Are you sure that you want to quit? +== Сиз анык эле оюндан чыгууну каалайсызбы? + +Are you sure that you want to remove the player from your friends list? +== Сиз анык эле бул оюнчуну достор тизмесинен өчүрүүнү каалайсызбы? + +As this is the first time you launch the game, please enter your nick name below. It's recommended that you check the settings to adjust them to your liking before joining a server. +== Бул оюндун биринчи жүргүзүлүшү болгону үчүн, төмөн жакка такма атыңызды киргизип, жана ырастоолорду текшерип коюңуз. + +Automatically record demos +== Демону автоматтуу түрдө жазуу + +Automatically take game over screenshot +== Оюн натыйжаларын сүрөткө тартуу + +Blue team +== Көктөр + +Blue team wins! +== Көктөр утту! + +Body +== Дене + +Call vote +== Добуш берүү + +Change settings +== Ырастоолорду өзгөртүү + +Chat +== Чат + +Clan +== Кланы + +Client +== Клиент + +Close +== Чыгуу + +Compatible version +== Батышуучу версия + +Connect +== Туташуу + +Connecting to +== Туташтыруу + +Connection Problems... +== Байланыш көйгөйлөрү... + +Console +== Консоль + +Controls +== Башкаруу + +Count players only +== Оюнчуларды гана саноо + +Country +== Өлкө + +Crc: +== Crc: + +Created: +== Жаратылганы: + +Current +== Кезектеги + +Current version: %s +== Кезектеги версиясы: %s + +Custom colors +== Өз түстөр + +Delete +== Өчүрүү + +Delete demo +== Демону өчүрүү + +Demo details +== Демо деталдары + +Demofile: %s +== Демо: %s + +Demos +== Демо + +Disconnect +== Өчүрүү + +Disconnected +== Өчүрүлдү + +Display Modes +== Экран чечими + +Downloading map +== Картаны жүктөө + +Draw! +== Тең! + +Dynamic Camera +== Динамикалык камера + +Emoticon +== Эмоциялар + +Enter +== Кирүү + +Error +== Ката + +Error loading demo +== Демону жүктөө учурундагы ката + +FSAA samples +== FSAA сэмплдери + +Favorite +== Тандалма + +Favorites +== Тандалмалар + +Feet +== Бут + +Filter +== Фильтр + +Fire +== Атуу + +Folder +== Папка + +Force vote +== Тездетүү + +Free-View +== Эркин сереп + +Friends +== Достор + +Fullscreen +== Толук экран режими + +Game +== Оюн + +Game info +== Оюн жөнүндө + +Game over +== Оюн бүттү + +Game type +== Оюн түрү + +Game types: +== Оюн түрү: + +General +== Негизги + +Graphics +== Графика + +Grenade +== Гранатомёт + +Hammer +== Барскан + +Has people playing +== Бош эмес сервер + +High Detail +== Жогорку детализация + +Hook +== Илмек + +Host address +== Сервер дареги + +Hue +== Түсү + +Info +== Маалымат + +Internet +== Интернет + +Invalid Demo +== Жарабаган демо + +Join blue +== Көктөргө + +Join game +== Оюноо + +Join red +== Кызылдарга + +Jump +== Секирүү + +Kick player +== Оюнчуну бан кылуу + +LAN +== LAN + +Language +== Тил + +Length: +== Узун.: + +Lht. +== Ач. түс. + +Loading +== Жүктөө + +MOTD +== Күндүн билдирүүсү + +Map +== Картасы + +Map: +== Картасы: + +Max Screenshots +== Максималдуу сүрөт саны + +Max demos +== Максималдуу демо саны + +Maximum ping: +== Макс. пинги: + +Miscellaneous +== Кошумча + +Mouse sens. +== Чычкан сезгич. + +Move left +== Солго басуу + +Move player to spectators +== Оюнчуну байкоочу кылуу + +Move right +== Оңго басуу + +Movement +== Аракет + +Mute when not active +== Активдүү эмес кезде колдонбоо + +Name +== Аты + +Name plates size +== Өлчөм + +Netversion: +== Версиясы: + +New name: +== Жаңы ат: + +News +== Жаңылыктар + +Next weapon +== Кийин. курал + +Nickname +== Такма ат + +No +== Жок + +No password +== Сырсөзсүз + +No servers found +== Серверлер табылган жок + +No servers match your filter criteria +== Сиздин фильтриңизге жарай турган серверлер жок + +Ok +== ОК + +Open +== Ачуу + +Parent Folder +== Ата-энелик каталог + +Password +== Сырсөзү + +Password incorrect +== Сырсөз + +Ping +== Пинги + +Pistol +== Тапанча + +Play +== Көрүү + +Play background music +== Фон музыкасын ойнотуу + +Player +== Оюнчу + +Player country: +== Өлкөсү: + +Player options +== Оюнчу опциялары + +Players +== Оюнчулары + +Please balance teams! +== Команадаларды баланстаңыз! + +Prev. weapon +== Мурун. курал + +Quality Textures +== Сапаттуу текстуралар + +Quick search: +== Тез издөө: + +Quit +== Чыгуу + +Quit anyway? +== Чыгуу? + +REC %3d:%02d +== ЖАЗУУ %3d:%02d + +Reason: +== Себеп: + +Record demo +== Демо жазуу + +Red team +== Кызылдар + +Red team wins! +== Кызылдар утту! + +Refresh +== Жаңылоо + +Refreshing master servers +== Мастер-серверлер тизмесин жаңылоо + +Remote console +== Сервер консолу + +Remove +== Өчүрүү + +Remove friend +== Досту өчүрүү + +Rename +== Атын өзгөрт. + +Rename demo +== Демо атын өзгөртүү + +Reset filter +== Фильтрлерди түшүрүү + +Reset to defaults +== Ырастоолорду түшүрүү + +Rifle +== Бластер + +Round +== Раунду + +Sample rate +== Жыштыгы + +Sat. +== Канык. + +Score +== Упайы + +Score board +== Табло + +Score limit +== Упай лимити + +Scoreboard +== Табло + +Screenshot +== Сүрөт + +Server address: +== Сервер дареги: + +Server details +== Сервер деталдары + +Server filter +== Сервер фильтри + +Server info +== Маалымат + +Server not full +== Сервер толук эмес + +Settings +== Ырастоолор + +Shotgun +== Мылтык + +Show chat +== Чатты көрсөтүү + +Show friends only +== Достор менен гана + +Show ingame HUD +== Оюн ичиндеги HUD'ни көрсөтүү + +Show name plates +== Оюнчулардын аттарын көрсөтүү + +Show only supported +== Колдолгон чечимдерди гана көрсөтүү + +Size: +== Өлчөмү: + +Skins +== Скиндер + +Sound +== Үн + +Sound error +== Үн катасы + +Sound volume +== Үн катуулугу + +Spectate +== Байкоо + +Spectate next +== Кийин. байкоо + +Spectate previous +== Мурун. байкоо + +Spectator mode +== Байкоочу + +Spectators +== Байкоочулар + +Standard gametype +== Стандарттуу оюн түрү + +Standard map +== Стандарттуу карта + +Stop record +== Токтотуу + +Strict gametype filter +== Оюн түрүнүн так фильтри + +Sudden Death +== Тез өлүм + +Switch weapon on pickup +== Көтөрүлгөн куралга которуу + +Team +== Команда + +Team chat +== Команда чаты + +Teeworlds %s is out! Download it at www.teeworlds.com! +== Teeworlds %s чыкты! www.teeworlds.com сайтынан жүктөп алыңыз! + +Texture Compression +== Текстура кысылышы + +The audio device couldn't be initialised. +== Аудио түзмөгүн инициализациялап алууга мүмкүн эмес. + +The server is running a non-standard tuning on a pure game type. +== Бул сервер стандартту эмес ырастоолор менен таза оюн түрүндө иштеп жатат. + +There's an unsaved map in the editor, you might want to save it before you quit the game. +== Редактордо сакталбаган карта бар, аны оюндан чыгаар алдында сактасаңыз болот. + +Time limit +== Убакыт лимити + +Time limit: %d min +== Убакыт лимити: %d мин. + +Try again +== ОК + +Type +== Түрү + +Type: +== Түрү: + +UI Color +== Интерфейс түсү + +Unable to delete the demo +== Демону өчүрүү мүмкүн эмес + +Unable to rename the demo +== Демо атын өзгөртүү мүмкүн эмес + +Use sounds +== Үндөрдү колдонуу + +Use team colors for name plates +== Аттар үчүн команданын түсүн колдонуу + +V-Sync +== Вертикалдык синхронизация + +Version +== Версиясы + +Version: +== Версиясы: + +Vote command: +== Добуш коммандасы: + +Vote description: +== Добуш баяндамасы: + +Vote no +== Каршы + +Vote yes +== Макул + +Voting +== Добуш берүү + +Warmup +== Даярдануу + +Weapon +== Курал + +Welcome to Teeworlds +== Teeworlds'ко кош келиңиз! + +Yes +== Ооба + +You must restart the game for all settings to take effect. +== Өзгөртүүлөрдү колдонуу үчүн оюнду кайта жүргүзүңүз. + +Your skin +== Скиниңиз + +no limit +== лимитсиз + +Game paused +== Оюн бир азга токтотулду + +Respawn +== Респаун + +Show only chat messages from friends +== Достордун гана чат билдирүүлөрүн көрсөтүү + +##### needs translation ##### + +##### old translations ##### From 471d479300cf7ec34daaca5576040ef25045ea94 Mon Sep 17 00:00:00 2001 From: PsychoGod Date: Sun, 3 Mar 2013 13:42:25 +0200 Subject: [PATCH 68/84] one more centering window in graphics --- src/engine/client/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index 3168903db..2e8a855dc 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -900,7 +900,7 @@ int CGraphics_SDL::Init() #ifdef CONF_FAMILY_WINDOWS if(!getenv("SDL_VIDEO_WINDOW_POS") && !getenv("SDL_VIDEO_CENTERED")) // ignore_convention - putenv("SDL_VIDEO_WINDOW_POS=8,27"); // ignore_convention + putenv("SDL_VIDEO_WINDOW_POS=center"); // ignore_convention #endif if(InitWindow() != 0) From 878af82d8f59446a590050d2e8cae0cc607093f1 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 16 Mar 2013 15:30:40 +0100 Subject: [PATCH 69/84] fixed frozen GUI caused by popups --- src/game/client/components/menus.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 8d0bdb16f..d625d4c0d 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1311,6 +1311,9 @@ int CMenus::Render() if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || m_EscapePressed || m_EnterPressed) m_Popup = POPUP_NONE; } + + if(m_Popup == POPUP_NONE) + UI()->SetActiveItem(0); } return 0; From b2a9e98bf4e62b1ac568c282dfdebc13c8a3156c Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 16 Mar 2013 16:03:38 +0100 Subject: [PATCH 70/84] fixed client crash on removing friends. Closes #1077 --- src/game/client/components/menus_browser.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index b560b8cd2..42805e0bb 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -806,6 +806,8 @@ void CMenus::RenderServerbrowserFriends(CUIRect View) // friends list(remove friend) static float s_ScrollValue = 0; + if(m_FriendlistSelectedIndex >= m_lFriends.size()) + m_FriendlistSelectedIndex = m_lFriends.size()-1; UiDoListboxStart(&m_lFriends, &List, 30.0f, "", "", m_lFriends.size(), 1, m_FriendlistSelectedIndex, s_ScrollValue); m_lFriends.sort_range(); From 7e8374447a31f96877450574af42d25887122964 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 10 Jun 2012 13:30:25 +0200 Subject: [PATCH 71/84] switched filenames of highlight and client chat message to prevent some misunderstanding there. #966 --- data/audio/sfx_msg-client.wv | Bin 4154 -> 1648 bytes data/audio/sfx_msg-highlight.wv | Bin 1648 -> 4154 bytes src/game/client/components/chat.cpp | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/audio/sfx_msg-client.wv b/data/audio/sfx_msg-client.wv index 516db88e9014f0df98eec9953afb550d8bf8f389..6b68b312e13e9df4536c1eb91200f7cc70d89161 100644 GIT binary patch literal 1648 zcmV-$29No7c5rKG1^@sD1ONaA1^@s6000061^@sB7(4|vZbw5Q7E(z@MlcKj09Qd) zMP_YuAP@im009620D!vy004IZ00ICI0AyiwVGIla073&-S4UPz07CT zztR{{Z^lL|YOmJgpe0@l;|#A2uGq^ippe{qHC4C}`e7?C-w1IE~G)lc$m0 zGP}t(2vzLvZx4&48y({eV$pD6I<84E)8|89;~moCtJF#rK7hz(G1G?6IFCR-9EpLR zZ7soHtx3lbDqLA+l7mnd1{JY+n;dlDnbO_(fl5=evAMmGXTi0*=D0@Jtp@bDel8Q6 za$`>Wv-BD+W1tqFT}hf`C-#+$1WIJ|E?3g?^a?p;=OE}roJUc867|7B9#Ek$3mWUx zQnGehtg_a@Z;^Zy9qra%mN_F3(b{v+M)8%?7jen z9wt(h<#j`-ujC@Tq?h|`n2>m@o_a*YHjCN8+5lHU8!oA z(nu;2HfatNX`~MHQFaRlQ z+JKyF2=$`(N*3sl_>?g&ZJ7Vr#aD%R#Y|DaTEKJ{qYCUZO?)lH z4gy_Snlf+Cq1=jmqyr5=Y{3x%UdrPXHiuDujom3l8%v$wU(}S27m- zFfA!cQ+%ivkc_l2sRgDZ;FSUh3kh#QVNBU(C}?KlCeDrJnjjBlMDAnQ51{U;ZJ}5y z$O(a}vY6;5Q{6&epUpuG6d)cn9s%InNQd=|iL%{#4EPPI=lpOQFwbHC(z3+G4bjIBtbmfPF&t#kto z(j+W`pozo=l?~?>JQekZ5io?1E>JlrMphFES}`){!o@NSo0=TBW}t&(BgEnJ>HsMc z5;7aH*cujT06{im40sjB44e$W~ literal 4154 zcmZuzc{r49`+kOztr%HDOm?zU;}w|_g|ddSjV)QShqBFJ63V`0NxYGp;B?1r2KxW7?$I$pAnt$>pn*pohahDFI!hp#x&p3%BoG4< zK?=D49;0O^jQQi4U1W~k5mLaE**rEQCsII=Hb8+`b6+4dp$39S-mQn=fwuuPOTqOB zq+pY$Kr9#}LIWv8r6Xuo2P?$1e05CvdH_CiFU1 z+5^h%h#(f5_!}f*g~vcF(QF?iKa&T+@b^%OSpO3wQm7y(Hx0G=_dp_McNZjC(y{M= zSnsMsFr;w^i#t?W07)WCVA<%3I*8S!fC^d%{&h2(TI8dH^@VcO88B=KTkt4w|M3)v zT)t1Wv(nfk(+gamoYPQG3d~>UX+sUun1eys zbUt?bDE2(@rr6XjWG`C{+NKQ|~6b9 zN(p<=s)aFg-FPW{X*(4kGrp{&JylR3c(gcq=9kc3HHk)^BeR-kZ6VClYtNo+Uy>A; zt6?$p7yBCHXHWwpN{sHO%IVCF1b+z2wClMz5-28b5ck+tDckMB?A4&O-oT-(aVG=Q zwU1A@9pcveejz62Wk~+gVk>3^uWehUUR`zZFV`??#kQ^)-bU@KY|@G{T$H9HiT;?J zXq1*0KA9tS!}(C;!e6Y&T*-jNEcIB1>}BnYfq~GW#!J&I%GYXW2#+$GlbP@yGyE^T zcd%%ElafHm$(*l=6NlnsRSfoa(;gdV;x9DCNVF#DNDF>l|3R|4$@N(@N{W$chvZ&! zHq-t+damrH+ht9`Wj+%Ta~SU{K`^RagEi?s$#aUYnE!C$#u1Nn#Lsb(#g!t<|=!PuBwv^Rjw1qJ$)i-`Ab)mOS;x z_Up6AJ`qJu*_G9T7^FtYb$8>j2B9yy2)Mf`~@Uftl$3@K*c-=3%Y+ zz^9%D+omf&M+?4jx2{@Sy>83Xvm0k#`@mIrO?Y63#x<@#~z6l;;Eu9cGw4{Aa<VeF*L_pXo*{e)5Mr_;TNmRSis(k3)u#X zp83Ol9k-t>-z26FJ(!LZzF}1#=!^E7q0f^*4EPg^Kvaj%jI@uk(S>uTS7959rvKk zUh!=e>>pj7(+Qu1>Wj?P#l%A*KeXrMUHCJZl^u&#RF{Z~MjO=r5~_)J6dkc-(0%(D zk6zL>A?@Dlk~j>iWOyXkz%2izwXHMqGyVrYFkMoWLeLjsvD*zDrU@?Y&J7}C2ZY{O zHX7eJGpe7Mojxrivpz8l8|UqOl~jIXy?2kZ^ONwS=Et)yobej=g;Bc=#;Z*Xh0$i{ z9Yax$8CAGY_zu^RillJr1*AoL?&|_Y9+?kZ#?pmM?lM>8`Xg-czxxFUDjvApkLWA8 zU7Io2#>tI^YU~MzFP|Y0Y8osTI|wMoHcsAmHO!ips~vvYaLP^ITO8*b>6H}RP%b8_ zp7(@s{amr?pOh30ucrHHs9?z&{f{*;AJterUc97_Xy(X{yYZGQabknC6u?s=Gl=qo zJ;H)lKXI)*$*Xqy^0ScvtbLQ<9Grt>x-#>oySy>fqW*~{f0#iE6OB)9dKv7pw{Sh< zX#V%)-!3wb)xY8c+6Il+r%~3h6Rg7SPn!uCtor27D(#!?2y~`%?b-s9QbRc+gZep6 z;tNikRlW8{X9vTqM*C!oYWY}n89})uji&Ksyu|&)sfCSgV~c-?MrXPlL8--;*4ruk zC1?Q=R3x_vjIQ!i5t}xtZs3HCvxAQT$zc{Yy8Fg|8J{3=S+wzSL-z@?x9e+!zP&lN|{jLrvOsz@9Q+!#kkXN(3;Na0`%Kt7CF zimwF?nJ2;r7eS8@!_5P9j0iq78VA6g^YiKGVO;j}0039^LC{69F+pk^3^;aL$dv&g zKLQQV!C}lyB7CC>c0@m0JO9|$ML8BcU*t+ z?|=Sn&IcKSHrD`v*7YdC2hh}6Id^~fuVZ)Krb4z}1{peb3PRuoJ*bG;-h-ef4uV86 zDrEELA*TjWme3jy25kYvBnn6dcUPg5XuSiqLm*#2A_*QZ81Wkre1SgBFaLn@qI}5h ze}W(xa~A|DozS8{UWG=S-2=(Q&MA;MK>~?nBz7K}Z#524BQ`)1DgneQFheUr);37; z7KSu^#n28>mO=v$GWNk^$%HEihJBxfw2D1c@cJGWPy6+oeU&#G9Fn>IHzx_Z4`LUz zXcH*jZsO<>nTuB)d@=XAF;TMtBt{(=R8@HpUmv!7kK6d!6@qP6dAohIJyJ!V_$D;q zdq`B!4EDin#d9Nk<#5Kn+Kbe+$S+ybPMIsABV%>VK{b^HVg-cBs;nYBFAMkR$nTd# z+a_wb7g45oChR~~#DC?kUR7*xqDOz>5CKT{y8g#*w^-$xa^hAe#w5DZG%W9I2HNOc zq?=BrkSO!3!+7x@mp?vWC*N4$Q%$!v_v<&;kgu)NV&fvvZMh9d>89)I!MbCHx7fu7 zGJlBO+Pm&m)hbh)R`zXY`6n`qmim3oPKf9iTv8A&)R9wQj{l~1`oY%2;NiWODptjn z#SICUuWFRI)@8T7&mt2p4WUl5#Kt+5yk>feA1TW_%Z0^yO98f+wWI*eaD6?C{cHV| zCRAm%OEBZp;0PE0*hF=NdrvO1E@vr{S8-*snD?WqA=k+S;4Wq#B^S1~2N2MY%85e@>CZ^Ogm{X498Y+S(DHc|kAuYnS*g zrvkf?{?s6f=|ZJ^=wHmgiyah*wkz}7MS0CL2~x^d4CkN3v!9LAOu8lX9-Pmw%&fXL z^YLNQbZ_Y|yH@oh_ea)2ZRZ&)XG7yI;JReHVNRqqv8Gc4T;1e{zBQ;(=l1X?C$2R zSuL*>r^6@LXTuue_BC;4)pRT`b?aw}7B6>g!i>*q$Bp#6BJ3WQND&M5jrJV60na>J z(= zpJ`~kFt@}(`?zc%d|JIJTg_gAYKrFA%6@+SKJ$vR-j%*wT91UMKz;&WYmKN1TPo95 zWPV+V^l5Pp0!zG~T-kG<(z~>1oiPQ} zYf}1CTatq~6Mmws6~fnEAR#%vZeh!bw?rf!#nc_}ZMXXcucj!*WeaQYt=iK6iS50> zCj`|uQ6AI$zIV{wJ&tkhm%YlI1!l(GgAxmjGh`;r5P21D0Wl52s#GrPTX^kvt9VP6~@(PNd89ezu(n zj{jR*b-Q%y6NkrhM19BWE!zcxxqh_%*CuJ7*vf`Q$1k1E`$>5JQ4(@qb}!vJy55l3 z&uT)X;=bL;Xmifwk*bzrz~l*?yML!4wA(nYIk|JKdC`x)6eFPB_3M+F2<#kF@k*M9 zmG61+XYaZX}L!( zNIt7}xcr8(B42+lN706!edwDp;B?1r2KxW7?$I$pAnt$>pn*pohahDFI!hp#x&p3%BoG4< zK?=D49;0O^jQQi4U1W~k5mLaE**rEQCsII=Hb8+`b6+4dp$39S-mQn=fwuuPOTqOB zq+pY$Kr9#}LIWv8r6Xuo2P?$1e05CvdH_CiFU1 z+5^h%h#(f5_!}f*g~vcF(QF?iKa&T+@b^%OSpO3wQm7y(Hx0G=_dp_McNZjC(y{M= zSnsMsFr;w^i#t?W07)WCVA<%3I*8S!fC^d%{&h2(TI8dH^@VcO88B=KTkt4w|M3)v zT)t1Wv(nfk(+gamoYPQG3d~>UX+sUun1eys zbUt?bDE2(@rr6XjWG`C{+NKQ|~6b9 zN(p<=s)aFg-FPW{X*(4kGrp{&JylR3c(gcq=9kc3HHk)^BeR-kZ6VClYtNo+Uy>A; zt6?$p7yBCHXHWwpN{sHO%IVCF1b+z2wClMz5-28b5ck+tDckMB?A4&O-oT-(aVG=Q zwU1A@9pcveejz62Wk~+gVk>3^uWehUUR`zZFV`??#kQ^)-bU@KY|@G{T$H9HiT;?J zXq1*0KA9tS!}(C;!e6Y&T*-jNEcIB1>}BnYfq~GW#!J&I%GYXW2#+$GlbP@yGyE^T zcd%%ElafHm$(*l=6NlnsRSfoa(;gdV;x9DCNVF#DNDF>l|3R|4$@N(@N{W$chvZ&! zHq-t+damrH+ht9`Wj+%Ta~SU{K`^RagEi?s$#aUYnE!C$#u1Nn#Lsb(#g!t<|=!PuBwv^Rjw1qJ$)i-`Ab)mOS;x z_Up6AJ`qJu*_G9T7^FtYb$8>j2B9yy2)Mf`~@Uftl$3@K*c-=3%Y+ zz^9%D+omf&M+?4jx2{@Sy>83Xvm0k#`@mIrO?Y63#x<@#~z6l;;Eu9cGw4{Aa<VeF*L_pXo*{e)5Mr_;TNmRSis(k3)u#X zp83Ol9k-t>-z26FJ(!LZzF}1#=!^E7q0f^*4EPg^Kvaj%jI@uk(S>uTS7959rvKk zUh!=e>>pj7(+Qu1>Wj?P#l%A*KeXrMUHCJZl^u&#RF{Z~MjO=r5~_)J6dkc-(0%(D zk6zL>A?@Dlk~j>iWOyXkz%2izwXHMqGyVrYFkMoWLeLjsvD*zDrU@?Y&J7}C2ZY{O zHX7eJGpe7Mojxrivpz8l8|UqOl~jIXy?2kZ^ONwS=Et)yobej=g;Bc=#;Z*Xh0$i{ z9Yax$8CAGY_zu^RillJr1*AoL?&|_Y9+?kZ#?pmM?lM>8`Xg-czxxFUDjvApkLWA8 zU7Io2#>tI^YU~MzFP|Y0Y8osTI|wMoHcsAmHO!ips~vvYaLP^ITO8*b>6H}RP%b8_ zp7(@s{amr?pOh30ucrHHs9?z&{f{*;AJterUc97_Xy(X{yYZGQabknC6u?s=Gl=qo zJ;H)lKXI)*$*Xqy^0ScvtbLQ<9Grt>x-#>oySy>fqW*~{f0#iE6OB)9dKv7pw{Sh< zX#V%)-!3wb)xY8c+6Il+r%~3h6Rg7SPn!uCtor27D(#!?2y~`%?b-s9QbRc+gZep6 z;tNikRlW8{X9vTqM*C!oYWY}n89})uji&Ksyu|&)sfCSgV~c-?MrXPlL8--;*4ruk zC1?Q=R3x_vjIQ!i5t}xtZs3HCvxAQT$zc{Yy8Fg|8J{3=S+wzSL-z@?x9e+!zP&lN|{jLrvOsz@9Q+!#kkXN(3;Na0`%Kt7CF zimwF?nJ2;r7eS8@!_5P9j0iq78VA6g^YiKGVO;j}0039^LC{69F+pk^3^;aL$dv&g zKLQQV!C}lyB7CC>c0@m0JO9|$ML8BcU*t+ z?|=Sn&IcKSHrD`v*7YdC2hh}6Id^~fuVZ)Krb4z}1{peb3PRuoJ*bG;-h-ef4uV86 zDrEELA*TjWme3jy25kYvBnn6dcUPg5XuSiqLm*#2A_*QZ81Wkre1SgBFaLn@qI}5h ze}W(xa~A|DozS8{UWG=S-2=(Q&MA;MK>~?nBz7K}Z#524BQ`)1DgneQFheUr);37; z7KSu^#n28>mO=v$GWNk^$%HEihJBxfw2D1c@cJGWPy6+oeU&#G9Fn>IHzx_Z4`LUz zXcH*jZsO<>nTuB)d@=XAF;TMtBt{(=R8@HpUmv!7kK6d!6@qP6dAohIJyJ!V_$D;q zdq`B!4EDin#d9Nk<#5Kn+Kbe+$S+ybPMIsABV%>VK{b^HVg-cBs;nYBFAMkR$nTd# z+a_wb7g45oChR~~#DC?kUR7*xqDOz>5CKT{y8g#*w^-$xa^hAe#w5DZG%W9I2HNOc zq?=BrkSO!3!+7x@mp?vWC*N4$Q%$!v_v<&;kgu)NV&fvvZMh9d>89)I!MbCHx7fu7 zGJlBO+Pm&m)hbh)R`zXY`6n`qmim3oPKf9iTv8A&)R9wQj{l~1`oY%2;NiWODptjn z#SICUuWFRI)@8T7&mt2p4WUl5#Kt+5yk>feA1TW_%Z0^yO98f+wWI*eaD6?C{cHV| zCRAm%OEBZp;0PE0*hF=NdrvO1E@vr{S8-*snD?WqA=k+S;4Wq#B^S1~2N2MY%85e@>CZ^Ogm{X498Y+S(DHc|kAuYnS*g zrvkf?{?s6f=|ZJ^=wHmgiyah*wkz}7MS0CL2~x^d4CkN3v!9LAOu8lX9-Pmw%&fXL z^YLNQbZ_Y|yH@oh_ea)2ZRZ&)XG7yI;JReHVNRqqv8Gc4T;1e{zBQ;(=l1X?C$2R zSuL*>r^6@LXTuue_BC;4)pRT`b?aw}7B6>g!i>*q$Bp#6BJ3WQND&M5jrJV60na>J z(= zpJ`~kFt@}(`?zc%d|JIJTg_gAYKrFA%6@+SKJ$vR-j%*wT91UMKz;&WYmKN1TPo95 zWPV+V^l5Pp0!zG~T-kG<(z~>1oiPQ} zYf}1CTatq~6Mmws6~fnEAR#%vZeh!bw?rf!#nc_}ZMXXcucj!*WeaQYt=iK6iS50> zCj`|uQ6AI$zIV{wJ&tkhm%YlI1!l(GgAxmjGh`;r5P21D0Wl52s#GrPTX^kvt9VP6~@(PNd89ezu(n zj{jR*b-Q%y6NkrhM19BWE!zcxxqh_%*CuJ7*vf`Q$1k1E`$>5JQ4(@qb}!vJy55l3 z&uT)X;=bL;Xmifwk*bzrz~l*?yML!4wA(nYIk|JKdC`x)6eFPB_3M+F2<#kF@k*M9 zmG61+XYaZX}L!( zNIt7}xcr8(B42+lN706!edwDT zztR{{Z^lL|YOmJgpe0@l;|#A2uGq^ippe{qHC4C}`e7?C-w1IE~G)lc$m0 zGP}t(2vzLvZx4&48y({eV$pD6I<84E)8|89;~moCtJF#rK7hz(G1G?6IFCR-9EpLR zZ7soHtx3lbDqLA+l7mnd1{JY+n;dlDnbO_(fl5=evAMmGXTi0*=D0@Jtp@bDel8Q6 za$`>Wv-BD+W1tqFT}hf`C-#+$1WIJ|E?3g?^a?p;=OE}roJUc867|7B9#Ek$3mWUx zQnGehtg_a@Z;^Zy9qra%mN_F3(b{v+M)8%?7jen z9wt(h<#j`-ujC@Tq?h|`n2>m@o_a*YHjCN8+5lHU8!oA z(nu;2HfatNX`~MHQFaRlQ z+JKyF2=$`(N*3sl_>?g&ZJ7Vr#aD%R#Y|DaTEKJ{qYCUZO?)lH z4gy_Snlf+Cq1=jmqyr5=Y{3x%UdrPXHiuDujom3l8%v$wU(}S27m- zFfA!cQ+%ivkc_l2sRgDZ;FSUh3kh#QVNBU(C}?KlCeDrJnjjBlMDAnQ51{U;ZJ}5y z$O(a}vY6;5Q{6&epUpuG6d)cn9s%InNQd=|iL%{#4EPPI=lpOQFwbHC(z3+G4bjIBtbmfPF&t#kto z(j+W`pozo=l?~?>JQekZ5io?1E>JlrMphFES}`){!o@NSo0=TBW}t&(BgEnJ>HsMc z5;7aH*cujT06{im40sjB44e$W~ diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index f3370f94e..5b2831df4 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -357,7 +357,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) { if(Now-m_aLastSoundPlayed[CHAT_HIGHLIGHT] >= time_freq()*3/10) { - m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_CLIENT, 0); + m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0); m_aLastSoundPlayed[CHAT_HIGHLIGHT] = Now; } } @@ -365,7 +365,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) { if(Now-m_aLastSoundPlayed[CHAT_CLIENT] >= time_freq()*3/10) { - m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0); + m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_CLIENT, 0); m_aLastSoundPlayed[CHAT_CLIENT] = Now; } } From 678863fa7e10b2694c6a97a224ef1c58cf153841 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 20 Mar 2013 22:47:48 +0100 Subject: [PATCH 72/84] increased minimum required connect time for clients to 1 second. #1070 --- src/engine/shared/network_server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index bdc10935c..e8e5635cf 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -75,7 +75,7 @@ int CNetServer::Update() m_aSlots[i].m_Connection.Update(); if(m_aSlots[i].m_Connection.State() == NET_CONNSTATE_ERROR) { - if(Now - m_aSlots[i].m_Connection.ConnectTime() < time_freq()/2 && NetBan()) + if(Now - m_aSlots[i].m_Connection.ConnectTime() < time_freq() && NetBan()) NetBan()->BanAddr(ClientAddr(i), 60, "Stressing network"); else Drop(i, m_aSlots[i].m_Connection.ErrorString()); From 75cdc0a7697bb03c3b06631affcbcbd0b7baaf0e Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 23 Mar 2013 15:59:27 +0100 Subject: [PATCH 73/84] drop game messages when client isn't ingame. Closes #1081 --- src/game/server/gamecontext.cpp | 716 ++++++++++++++++---------------- 1 file changed, 361 insertions(+), 355 deletions(-) diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index bab48308f..a2500dda6 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -608,395 +608,401 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) return; } - if(MsgID == NETMSGTYPE_CL_SAY) + if(Server()->ClientIngame(ClientID)) { - CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg; - int Team = pMsg->m_Team; - if(Team) - Team = pPlayer->GetTeam(); - else - Team = CGameContext::CHAT_ALL; - - if(g_Config.m_SvSpamprotection && pPlayer->m_LastChat && pPlayer->m_LastChat+Server()->TickSpeed() > Server()->Tick()) - return; - - pPlayer->m_LastChat = Server()->Tick(); - - // check for invalid chars - unsigned char *pMessage = (unsigned char *)pMsg->m_pMessage; - while (*pMessage) + if(MsgID == NETMSGTYPE_CL_SAY) { - if(*pMessage < 32) - *pMessage = ' '; - pMessage++; - } + CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg; + int Team = pMsg->m_Team; + if(Team) + Team = pPlayer->GetTeam(); + else + Team = CGameContext::CHAT_ALL; - SendChat(ClientID, Team, pMsg->m_pMessage); - } - else if(MsgID == NETMSGTYPE_CL_CALLVOTE) - { - if(g_Config.m_SvSpamprotection && pPlayer->m_LastVoteTry && pPlayer->m_LastVoteTry+Server()->TickSpeed()*3 > Server()->Tick()) - return; + if(g_Config.m_SvSpamprotection && pPlayer->m_LastChat && pPlayer->m_LastChat+Server()->TickSpeed() > Server()->Tick()) + return; - int64 Now = Server()->Tick(); - pPlayer->m_LastVoteTry = Now; - if(pPlayer->GetTeam() == TEAM_SPECTATORS) - { - SendChatTarget(ClientID, "Spectators aren't allowed to start a vote."); - return; - } + pPlayer->m_LastChat = Server()->Tick(); - if(m_VoteCloseTime) - { - SendChatTarget(ClientID, "Wait for current vote to end before calling a new one."); - return; - } - - int Timeleft = pPlayer->m_LastVoteCall + Server()->TickSpeed()*60 - Now; - if(pPlayer->m_LastVoteCall && Timeleft > 0) - { - char aChatmsg[512] = {0}; - str_format(aChatmsg, sizeof(aChatmsg), "You must wait %d seconds before making another vote", (Timeleft/Server()->TickSpeed())+1); - SendChatTarget(ClientID, aChatmsg); - return; - } - - char aChatmsg[512] = {0}; - char aDesc[VOTE_DESC_LENGTH] = {0}; - char aCmd[VOTE_CMD_LENGTH] = {0}; - CNetMsg_Cl_CallVote *pMsg = (CNetMsg_Cl_CallVote *)pRawMsg; - const char *pReason = pMsg->m_Reason[0] ? pMsg->m_Reason : "No reason given"; - - if(str_comp_nocase(pMsg->m_Type, "option") == 0) - { - CVoteOptionServer *pOption = m_pVoteOptionFirst; - while(pOption) + // check for invalid chars + unsigned char *pMessage = (unsigned char *)pMsg->m_pMessage; + while (*pMessage) { - if(str_comp_nocase(pMsg->m_Value, pOption->m_aDescription) == 0) - { - str_format(aChatmsg, sizeof(aChatmsg), "'%s' called vote to change server option '%s' (%s)", Server()->ClientName(ClientID), - pOption->m_aDescription, pReason); - str_format(aDesc, sizeof(aDesc), "%s", pOption->m_aDescription); - str_format(aCmd, sizeof(aCmd), "%s", pOption->m_aCommand); - break; - } - - pOption = pOption->m_pNext; + if(*pMessage < 32) + *pMessage = ' '; + pMessage++; } - if(!pOption) + SendChat(ClientID, Team, pMsg->m_pMessage); + } + else if(MsgID == NETMSGTYPE_CL_CALLVOTE) + { + if(g_Config.m_SvSpamprotection && pPlayer->m_LastVoteTry && pPlayer->m_LastVoteTry+Server()->TickSpeed()*3 > Server()->Tick()) + return; + + int64 Now = Server()->Tick(); + pPlayer->m_LastVoteTry = Now; + if(pPlayer->GetTeam() == TEAM_SPECTATORS) { - str_format(aChatmsg, sizeof(aChatmsg), "'%s' isn't an option on this server", pMsg->m_Value); + SendChatTarget(ClientID, "Spectators aren't allowed to start a vote."); + return; + } + + if(m_VoteCloseTime) + { + SendChatTarget(ClientID, "Wait for current vote to end before calling a new one."); + return; + } + + int Timeleft = pPlayer->m_LastVoteCall + Server()->TickSpeed()*60 - Now; + if(pPlayer->m_LastVoteCall && Timeleft > 0) + { + char aChatmsg[512] = {0}; + str_format(aChatmsg, sizeof(aChatmsg), "You must wait %d seconds before making another vote", (Timeleft/Server()->TickSpeed())+1); SendChatTarget(ClientID, aChatmsg); return; } - } - else if(str_comp_nocase(pMsg->m_Type, "kick") == 0) - { - if(!g_Config.m_SvVoteKick) - { - SendChatTarget(ClientID, "Server does not allow voting to kick players"); - return; - } - if(g_Config.m_SvVoteKickMin) - { - int PlayerNum = 0; - for(int i = 0; i < MAX_CLIENTS; ++i) - if(m_apPlayers[i] && m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS) - ++PlayerNum; + char aChatmsg[512] = {0}; + char aDesc[VOTE_DESC_LENGTH] = {0}; + char aCmd[VOTE_CMD_LENGTH] = {0}; + CNetMsg_Cl_CallVote *pMsg = (CNetMsg_Cl_CallVote *)pRawMsg; + const char *pReason = pMsg->m_Reason[0] ? pMsg->m_Reason : "No reason given"; - if(PlayerNum < g_Config.m_SvVoteKickMin) + if(str_comp_nocase(pMsg->m_Type, "option") == 0) + { + CVoteOptionServer *pOption = m_pVoteOptionFirst; + while(pOption) { - str_format(aChatmsg, sizeof(aChatmsg), "Kick voting requires %d players on the server", g_Config.m_SvVoteKickMin); + if(str_comp_nocase(pMsg->m_Value, pOption->m_aDescription) == 0) + { + str_format(aChatmsg, sizeof(aChatmsg), "'%s' called vote to change server option '%s' (%s)", Server()->ClientName(ClientID), + pOption->m_aDescription, pReason); + str_format(aDesc, sizeof(aDesc), "%s", pOption->m_aDescription); + str_format(aCmd, sizeof(aCmd), "%s", pOption->m_aCommand); + break; + } + + pOption = pOption->m_pNext; + } + + if(!pOption) + { + str_format(aChatmsg, sizeof(aChatmsg), "'%s' isn't an option on this server", pMsg->m_Value); SendChatTarget(ClientID, aChatmsg); return; } } - - int KickID = str_toint(pMsg->m_Value); - if(KickID < 0 || KickID >= MAX_CLIENTS || !m_apPlayers[KickID]) + else if(str_comp_nocase(pMsg->m_Type, "kick") == 0) { - SendChatTarget(ClientID, "Invalid client id to kick"); - return; - } - if(KickID == ClientID) - { - SendChatTarget(ClientID, "You can't kick yourself"); - return; - } - if(Server()->IsAuthed(KickID)) - { - SendChatTarget(ClientID, "You can't kick admins"); - char aBufKick[128]; - str_format(aBufKick, sizeof(aBufKick), "'%s' called for vote to kick you", Server()->ClientName(ClientID)); - SendChatTarget(KickID, aBufKick); - return; - } - - str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientID), Server()->ClientName(KickID), pReason); - str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickID)); - if (!g_Config.m_SvVoteKickBantime) - str_format(aCmd, sizeof(aCmd), "kick %d Kicked by vote", KickID); - else - { - char aAddrStr[NETADDR_MAXSTRSIZE] = {0}; - Server()->GetClientAddr(KickID, aAddrStr, sizeof(aAddrStr)); - str_format(aCmd, sizeof(aCmd), "ban %s %d Banned by vote", aAddrStr, g_Config.m_SvVoteKickBantime); - } - } - else if(str_comp_nocase(pMsg->m_Type, "spectate") == 0) - { - if(!g_Config.m_SvVoteSpectate) - { - SendChatTarget(ClientID, "Server does not allow voting to move players to spectators"); - return; - } - - int SpectateID = str_toint(pMsg->m_Value); - if(SpectateID < 0 || SpectateID >= MAX_CLIENTS || !m_apPlayers[SpectateID] || m_apPlayers[SpectateID]->GetTeam() == TEAM_SPECTATORS) - { - SendChatTarget(ClientID, "Invalid client id to move"); - return; - } - if(SpectateID == ClientID) - { - SendChatTarget(ClientID, "You can't move yourself"); - return; - } - - str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to move '%s' to spectators (%s)", Server()->ClientName(ClientID), Server()->ClientName(SpectateID), pReason); - str_format(aDesc, sizeof(aDesc), "move '%s' to spectators", Server()->ClientName(SpectateID)); - str_format(aCmd, sizeof(aCmd), "set_team %d -1 %d", SpectateID, g_Config.m_SvVoteSpectateRejoindelay); - } - - if(aCmd[0]) - { - SendChat(-1, CGameContext::CHAT_ALL, aChatmsg); - StartVote(aDesc, aCmd, pReason); - pPlayer->m_Vote = 1; - pPlayer->m_VotePos = m_VotePos = 1; - m_VoteCreator = ClientID; - pPlayer->m_LastVoteCall = Now; - } - } - else if(MsgID == NETMSGTYPE_CL_VOTE) - { - if(!m_VoteCloseTime) - return; - - if(pPlayer->m_Vote == 0) - { - CNetMsg_Cl_Vote *pMsg = (CNetMsg_Cl_Vote *)pRawMsg; - if(!pMsg->m_Vote) - return; - - pPlayer->m_Vote = pMsg->m_Vote; - pPlayer->m_VotePos = ++m_VotePos; - m_VoteUpdate = true; - } - } - else if (MsgID == NETMSGTYPE_CL_SETTEAM && !m_World.m_Paused) - { - CNetMsg_Cl_SetTeam *pMsg = (CNetMsg_Cl_SetTeam *)pRawMsg; - - if(pPlayer->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && pPlayer->m_LastSetTeam && pPlayer->m_LastSetTeam+Server()->TickSpeed()*3 > Server()->Tick())) - return; - - if(pMsg->m_Team != TEAM_SPECTATORS && m_LockTeams) - { - pPlayer->m_LastSetTeam = Server()->Tick(); - SendBroadcast("Teams are locked", ClientID); - return; - } - - if(pPlayer->m_TeamChangeTick > Server()->Tick()) - { - pPlayer->m_LastSetTeam = Server()->Tick(); - int TimeLeft = (pPlayer->m_TeamChangeTick - Server()->Tick())/Server()->TickSpeed(); - char aBuf[128]; - str_format(aBuf, sizeof(aBuf), "Time to wait before changing team: %02d:%02d", TimeLeft/60, TimeLeft%60); - SendBroadcast(aBuf, ClientID); - return; - } - - // Switch team on given client and kill/respawn him - if(m_pController->CanJoinTeam(pMsg->m_Team, ClientID)) - { - if(m_pController->CanChangeTeam(pPlayer, pMsg->m_Team)) - { - pPlayer->m_LastSetTeam = Server()->Tick(); - if(pPlayer->GetTeam() == TEAM_SPECTATORS || pMsg->m_Team == TEAM_SPECTATORS) - m_VoteUpdate = true; - pPlayer->SetTeam(pMsg->m_Team); - (void)m_pController->CheckTeamBalance(); - pPlayer->m_TeamChangeTick = Server()->Tick(); - } - else - SendBroadcast("Teams must be balanced, please join other team", ClientID); - } - else - { - char aBuf[128]; - str_format(aBuf, sizeof(aBuf), "Only %d active players are allowed", Server()->MaxClients()-g_Config.m_SvSpectatorSlots); - SendBroadcast(aBuf, ClientID); - } - } - else if (MsgID == NETMSGTYPE_CL_SETSPECTATORMODE && !m_World.m_Paused) - { - CNetMsg_Cl_SetSpectatorMode *pMsg = (CNetMsg_Cl_SetSpectatorMode *)pRawMsg; - - if(pPlayer->GetTeam() != TEAM_SPECTATORS || pPlayer->m_SpectatorID == pMsg->m_SpectatorID || ClientID == pMsg->m_SpectatorID || - (g_Config.m_SvSpamprotection && pPlayer->m_LastSetSpectatorMode && pPlayer->m_LastSetSpectatorMode+Server()->TickSpeed()*3 > Server()->Tick())) - return; - - pPlayer->m_LastSetSpectatorMode = Server()->Tick(); - if(pMsg->m_SpectatorID != SPEC_FREEVIEW && (!m_apPlayers[pMsg->m_SpectatorID] || m_apPlayers[pMsg->m_SpectatorID]->GetTeam() == TEAM_SPECTATORS)) - SendChatTarget(ClientID, "Invalid spectator id used"); - else - pPlayer->m_SpectatorID = pMsg->m_SpectatorID; - } - else if (MsgID == NETMSGTYPE_CL_STARTINFO) - { - if(pPlayer->m_IsReady) - return; - - CNetMsg_Cl_StartInfo *pMsg = (CNetMsg_Cl_StartInfo *)pRawMsg; - pPlayer->m_LastChangeInfo = Server()->Tick(); - - // set start infos - Server()->SetClientName(ClientID, pMsg->m_pName); - Server()->SetClientClan(ClientID, pMsg->m_pClan); - Server()->SetClientCountry(ClientID, pMsg->m_Country); - str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); - pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; - pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; - pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet; - m_pController->OnPlayerInfoChange(pPlayer); - - // send vote options - CNetMsg_Sv_VoteClearOptions ClearMsg; - Server()->SendPackMsg(&ClearMsg, MSGFLAG_VITAL, ClientID); - - CNetMsg_Sv_VoteOptionListAdd OptionMsg; - int NumOptions = 0; - OptionMsg.m_pDescription0 = ""; - OptionMsg.m_pDescription1 = ""; - OptionMsg.m_pDescription2 = ""; - OptionMsg.m_pDescription3 = ""; - OptionMsg.m_pDescription4 = ""; - OptionMsg.m_pDescription5 = ""; - OptionMsg.m_pDescription6 = ""; - OptionMsg.m_pDescription7 = ""; - OptionMsg.m_pDescription8 = ""; - OptionMsg.m_pDescription9 = ""; - OptionMsg.m_pDescription10 = ""; - OptionMsg.m_pDescription11 = ""; - OptionMsg.m_pDescription12 = ""; - OptionMsg.m_pDescription13 = ""; - OptionMsg.m_pDescription14 = ""; - CVoteOptionServer *pCurrent = m_pVoteOptionFirst; - while(pCurrent) - { - switch(NumOptions++) - { - case 0: OptionMsg.m_pDescription0 = pCurrent->m_aDescription; break; - case 1: OptionMsg.m_pDescription1 = pCurrent->m_aDescription; break; - case 2: OptionMsg.m_pDescription2 = pCurrent->m_aDescription; break; - case 3: OptionMsg.m_pDescription3 = pCurrent->m_aDescription; break; - case 4: OptionMsg.m_pDescription4 = pCurrent->m_aDescription; break; - case 5: OptionMsg.m_pDescription5 = pCurrent->m_aDescription; break; - case 6: OptionMsg.m_pDescription6 = pCurrent->m_aDescription; break; - case 7: OptionMsg.m_pDescription7 = pCurrent->m_aDescription; break; - case 8: OptionMsg.m_pDescription8 = pCurrent->m_aDescription; break; - case 9: OptionMsg.m_pDescription9 = pCurrent->m_aDescription; break; - case 10: OptionMsg.m_pDescription10 = pCurrent->m_aDescription; break; - case 11: OptionMsg.m_pDescription11 = pCurrent->m_aDescription; break; - case 12: OptionMsg.m_pDescription12 = pCurrent->m_aDescription; break; - case 13: OptionMsg.m_pDescription13 = pCurrent->m_aDescription; break; - case 14: + if(!g_Config.m_SvVoteKick) { - OptionMsg.m_pDescription14 = pCurrent->m_aDescription; - OptionMsg.m_NumOptions = NumOptions; - Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID); - OptionMsg = CNetMsg_Sv_VoteOptionListAdd(); - NumOptions = 0; - OptionMsg.m_pDescription1 = ""; - OptionMsg.m_pDescription2 = ""; - OptionMsg.m_pDescription3 = ""; - OptionMsg.m_pDescription4 = ""; - OptionMsg.m_pDescription5 = ""; - OptionMsg.m_pDescription6 = ""; - OptionMsg.m_pDescription7 = ""; - OptionMsg.m_pDescription8 = ""; - OptionMsg.m_pDescription9 = ""; - OptionMsg.m_pDescription10 = ""; - OptionMsg.m_pDescription11 = ""; - OptionMsg.m_pDescription12 = ""; - OptionMsg.m_pDescription13 = ""; - OptionMsg.m_pDescription14 = ""; + SendChatTarget(ClientID, "Server does not allow voting to kick players"); + return; + } + + if(g_Config.m_SvVoteKickMin) + { + int PlayerNum = 0; + for(int i = 0; i < MAX_CLIENTS; ++i) + if(m_apPlayers[i] && m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS) + ++PlayerNum; + + if(PlayerNum < g_Config.m_SvVoteKickMin) + { + str_format(aChatmsg, sizeof(aChatmsg), "Kick voting requires %d players on the server", g_Config.m_SvVoteKickMin); + SendChatTarget(ClientID, aChatmsg); + return; + } + } + + int KickID = str_toint(pMsg->m_Value); + if(KickID < 0 || KickID >= MAX_CLIENTS || !m_apPlayers[KickID]) + { + SendChatTarget(ClientID, "Invalid client id to kick"); + return; + } + if(KickID == ClientID) + { + SendChatTarget(ClientID, "You can't kick yourself"); + return; + } + if(Server()->IsAuthed(KickID)) + { + SendChatTarget(ClientID, "You can't kick admins"); + char aBufKick[128]; + str_format(aBufKick, sizeof(aBufKick), "'%s' called for vote to kick you", Server()->ClientName(ClientID)); + SendChatTarget(KickID, aBufKick); + return; + } + + str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientID), Server()->ClientName(KickID), pReason); + str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickID)); + if (!g_Config.m_SvVoteKickBantime) + str_format(aCmd, sizeof(aCmd), "kick %d Kicked by vote", KickID); + else + { + char aAddrStr[NETADDR_MAXSTRSIZE] = {0}; + Server()->GetClientAddr(KickID, aAddrStr, sizeof(aAddrStr)); + str_format(aCmd, sizeof(aCmd), "ban %s %d Banned by vote", aAddrStr, g_Config.m_SvVoteKickBantime); } } - pCurrent = pCurrent->m_pNext; + else if(str_comp_nocase(pMsg->m_Type, "spectate") == 0) + { + if(!g_Config.m_SvVoteSpectate) + { + SendChatTarget(ClientID, "Server does not allow voting to move players to spectators"); + return; + } + + int SpectateID = str_toint(pMsg->m_Value); + if(SpectateID < 0 || SpectateID >= MAX_CLIENTS || !m_apPlayers[SpectateID] || m_apPlayers[SpectateID]->GetTeam() == TEAM_SPECTATORS) + { + SendChatTarget(ClientID, "Invalid client id to move"); + return; + } + if(SpectateID == ClientID) + { + SendChatTarget(ClientID, "You can't move yourself"); + return; + } + + str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to move '%s' to spectators (%s)", Server()->ClientName(ClientID), Server()->ClientName(SpectateID), pReason); + str_format(aDesc, sizeof(aDesc), "move '%s' to spectators", Server()->ClientName(SpectateID)); + str_format(aCmd, sizeof(aCmd), "set_team %d -1 %d", SpectateID, g_Config.m_SvVoteSpectateRejoindelay); + } + + if(aCmd[0]) + { + SendChat(-1, CGameContext::CHAT_ALL, aChatmsg); + StartVote(aDesc, aCmd, pReason); + pPlayer->m_Vote = 1; + pPlayer->m_VotePos = m_VotePos = 1; + m_VoteCreator = ClientID; + pPlayer->m_LastVoteCall = Now; + } } - if(NumOptions > 0) + else if(MsgID == NETMSGTYPE_CL_VOTE) { - OptionMsg.m_NumOptions = NumOptions; - Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID); + if(!m_VoteCloseTime) + return; + + if(pPlayer->m_Vote == 0) + { + CNetMsg_Cl_Vote *pMsg = (CNetMsg_Cl_Vote *)pRawMsg; + if(!pMsg->m_Vote) + return; + + pPlayer->m_Vote = pMsg->m_Vote; + pPlayer->m_VotePos = ++m_VotePos; + m_VoteUpdate = true; + } } - - // send tuning parameters to client - SendTuningParams(ClientID); - - // client is ready to enter - pPlayer->m_IsReady = true; - CNetMsg_Sv_ReadyToEnter m; - Server()->SendPackMsg(&m, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID); - } - else if (MsgID == NETMSGTYPE_CL_CHANGEINFO) - { - if(g_Config.m_SvSpamprotection && pPlayer->m_LastChangeInfo && pPlayer->m_LastChangeInfo+Server()->TickSpeed()*5 > Server()->Tick()) - return; - - CNetMsg_Cl_ChangeInfo *pMsg = (CNetMsg_Cl_ChangeInfo *)pRawMsg; - pPlayer->m_LastChangeInfo = Server()->Tick(); - - // set infos - char aOldName[MAX_NAME_LENGTH]; - str_copy(aOldName, Server()->ClientName(ClientID), sizeof(aOldName)); - Server()->SetClientName(ClientID, pMsg->m_pName); - if(str_comp(aOldName, Server()->ClientName(ClientID)) != 0) + else if (MsgID == NETMSGTYPE_CL_SETTEAM && !m_World.m_Paused) { - char aChatText[256]; - str_format(aChatText, sizeof(aChatText), "'%s' changed name to '%s'", aOldName, Server()->ClientName(ClientID)); - SendChat(-1, CGameContext::CHAT_ALL, aChatText); + CNetMsg_Cl_SetTeam *pMsg = (CNetMsg_Cl_SetTeam *)pRawMsg; + + if(pPlayer->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && pPlayer->m_LastSetTeam && pPlayer->m_LastSetTeam+Server()->TickSpeed()*3 > Server()->Tick())) + return; + + if(pMsg->m_Team != TEAM_SPECTATORS && m_LockTeams) + { + pPlayer->m_LastSetTeam = Server()->Tick(); + SendBroadcast("Teams are locked", ClientID); + return; + } + + if(pPlayer->m_TeamChangeTick > Server()->Tick()) + { + pPlayer->m_LastSetTeam = Server()->Tick(); + int TimeLeft = (pPlayer->m_TeamChangeTick - Server()->Tick())/Server()->TickSpeed(); + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "Time to wait before changing team: %02d:%02d", TimeLeft/60, TimeLeft%60); + SendBroadcast(aBuf, ClientID); + return; + } + + // Switch team on given client and kill/respawn him + if(m_pController->CanJoinTeam(pMsg->m_Team, ClientID)) + { + if(m_pController->CanChangeTeam(pPlayer, pMsg->m_Team)) + { + pPlayer->m_LastSetTeam = Server()->Tick(); + if(pPlayer->GetTeam() == TEAM_SPECTATORS || pMsg->m_Team == TEAM_SPECTATORS) + m_VoteUpdate = true; + pPlayer->SetTeam(pMsg->m_Team); + (void)m_pController->CheckTeamBalance(); + pPlayer->m_TeamChangeTick = Server()->Tick(); + } + else + SendBroadcast("Teams must be balanced, please join other team", ClientID); + } + else + { + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "Only %d active players are allowed", Server()->MaxClients()-g_Config.m_SvSpectatorSlots); + SendBroadcast(aBuf, ClientID); + } + } + else if (MsgID == NETMSGTYPE_CL_SETSPECTATORMODE && !m_World.m_Paused) + { + CNetMsg_Cl_SetSpectatorMode *pMsg = (CNetMsg_Cl_SetSpectatorMode *)pRawMsg; + + if(pPlayer->GetTeam() != TEAM_SPECTATORS || pPlayer->m_SpectatorID == pMsg->m_SpectatorID || ClientID == pMsg->m_SpectatorID || + (g_Config.m_SvSpamprotection && pPlayer->m_LastSetSpectatorMode && pPlayer->m_LastSetSpectatorMode+Server()->TickSpeed()*3 > Server()->Tick())) + return; + + pPlayer->m_LastSetSpectatorMode = Server()->Tick(); + if(pMsg->m_SpectatorID != SPEC_FREEVIEW && (!m_apPlayers[pMsg->m_SpectatorID] || m_apPlayers[pMsg->m_SpectatorID]->GetTeam() == TEAM_SPECTATORS)) + SendChatTarget(ClientID, "Invalid spectator id used"); + else + pPlayer->m_SpectatorID = pMsg->m_SpectatorID; + } + else if (MsgID == NETMSGTYPE_CL_CHANGEINFO) + { + if(g_Config.m_SvSpamprotection && pPlayer->m_LastChangeInfo && pPlayer->m_LastChangeInfo+Server()->TickSpeed()*5 > Server()->Tick()) + return; + + CNetMsg_Cl_ChangeInfo *pMsg = (CNetMsg_Cl_ChangeInfo *)pRawMsg; + pPlayer->m_LastChangeInfo = Server()->Tick(); + + // set infos + char aOldName[MAX_NAME_LENGTH]; + str_copy(aOldName, Server()->ClientName(ClientID), sizeof(aOldName)); + Server()->SetClientName(ClientID, pMsg->m_pName); + if(str_comp(aOldName, Server()->ClientName(ClientID)) != 0) + { + char aChatText[256]; + str_format(aChatText, sizeof(aChatText), "'%s' changed name to '%s'", aOldName, Server()->ClientName(ClientID)); + SendChat(-1, CGameContext::CHAT_ALL, aChatText); + } + Server()->SetClientClan(ClientID, pMsg->m_pClan); + Server()->SetClientCountry(ClientID, pMsg->m_Country); + str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); + pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; + pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; + pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet; + m_pController->OnPlayerInfoChange(pPlayer); + } + else if (MsgID == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused) + { + CNetMsg_Cl_Emoticon *pMsg = (CNetMsg_Cl_Emoticon *)pRawMsg; + + if(g_Config.m_SvSpamprotection && pPlayer->m_LastEmote && pPlayer->m_LastEmote+Server()->TickSpeed()*3 > Server()->Tick()) + return; + + pPlayer->m_LastEmote = Server()->Tick(); + + SendEmoticon(ClientID, pMsg->m_Emoticon); + } + else if (MsgID == NETMSGTYPE_CL_KILL && !m_World.m_Paused) + { + if(pPlayer->m_LastKill && pPlayer->m_LastKill+Server()->TickSpeed()*3 > Server()->Tick()) + return; + + pPlayer->m_LastKill = Server()->Tick(); + pPlayer->KillCharacter(WEAPON_SELF); } - Server()->SetClientClan(ClientID, pMsg->m_pClan); - Server()->SetClientCountry(ClientID, pMsg->m_Country); - str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); - pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; - pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; - pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet; - m_pController->OnPlayerInfoChange(pPlayer); } - else if (MsgID == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused) + else { - CNetMsg_Cl_Emoticon *pMsg = (CNetMsg_Cl_Emoticon *)pRawMsg; + if(MsgID == NETMSGTYPE_CL_STARTINFO) + { + if(pPlayer->m_IsReady) + return; - if(g_Config.m_SvSpamprotection && pPlayer->m_LastEmote && pPlayer->m_LastEmote+Server()->TickSpeed()*3 > Server()->Tick()) - return; + CNetMsg_Cl_StartInfo *pMsg = (CNetMsg_Cl_StartInfo *)pRawMsg; + pPlayer->m_LastChangeInfo = Server()->Tick(); - pPlayer->m_LastEmote = Server()->Tick(); + // set start infos + Server()->SetClientName(ClientID, pMsg->m_pName); + Server()->SetClientClan(ClientID, pMsg->m_pClan); + Server()->SetClientCountry(ClientID, pMsg->m_Country); + str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); + pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; + pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; + pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet; + m_pController->OnPlayerInfoChange(pPlayer); - SendEmoticon(ClientID, pMsg->m_Emoticon); - } - else if (MsgID == NETMSGTYPE_CL_KILL && !m_World.m_Paused) - { - if(pPlayer->m_LastKill && pPlayer->m_LastKill+Server()->TickSpeed()*3 > Server()->Tick()) - return; + // send vote options + CNetMsg_Sv_VoteClearOptions ClearMsg; + Server()->SendPackMsg(&ClearMsg, MSGFLAG_VITAL, ClientID); - pPlayer->m_LastKill = Server()->Tick(); - pPlayer->KillCharacter(WEAPON_SELF); + CNetMsg_Sv_VoteOptionListAdd OptionMsg; + int NumOptions = 0; + OptionMsg.m_pDescription0 = ""; + OptionMsg.m_pDescription1 = ""; + OptionMsg.m_pDescription2 = ""; + OptionMsg.m_pDescription3 = ""; + OptionMsg.m_pDescription4 = ""; + OptionMsg.m_pDescription5 = ""; + OptionMsg.m_pDescription6 = ""; + OptionMsg.m_pDescription7 = ""; + OptionMsg.m_pDescription8 = ""; + OptionMsg.m_pDescription9 = ""; + OptionMsg.m_pDescription10 = ""; + OptionMsg.m_pDescription11 = ""; + OptionMsg.m_pDescription12 = ""; + OptionMsg.m_pDescription13 = ""; + OptionMsg.m_pDescription14 = ""; + CVoteOptionServer *pCurrent = m_pVoteOptionFirst; + while(pCurrent) + { + switch(NumOptions++) + { + case 0: OptionMsg.m_pDescription0 = pCurrent->m_aDescription; break; + case 1: OptionMsg.m_pDescription1 = pCurrent->m_aDescription; break; + case 2: OptionMsg.m_pDescription2 = pCurrent->m_aDescription; break; + case 3: OptionMsg.m_pDescription3 = pCurrent->m_aDescription; break; + case 4: OptionMsg.m_pDescription4 = pCurrent->m_aDescription; break; + case 5: OptionMsg.m_pDescription5 = pCurrent->m_aDescription; break; + case 6: OptionMsg.m_pDescription6 = pCurrent->m_aDescription; break; + case 7: OptionMsg.m_pDescription7 = pCurrent->m_aDescription; break; + case 8: OptionMsg.m_pDescription8 = pCurrent->m_aDescription; break; + case 9: OptionMsg.m_pDescription9 = pCurrent->m_aDescription; break; + case 10: OptionMsg.m_pDescription10 = pCurrent->m_aDescription; break; + case 11: OptionMsg.m_pDescription11 = pCurrent->m_aDescription; break; + case 12: OptionMsg.m_pDescription12 = pCurrent->m_aDescription; break; + case 13: OptionMsg.m_pDescription13 = pCurrent->m_aDescription; break; + case 14: + { + OptionMsg.m_pDescription14 = pCurrent->m_aDescription; + OptionMsg.m_NumOptions = NumOptions; + Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID); + OptionMsg = CNetMsg_Sv_VoteOptionListAdd(); + NumOptions = 0; + OptionMsg.m_pDescription1 = ""; + OptionMsg.m_pDescription2 = ""; + OptionMsg.m_pDescription3 = ""; + OptionMsg.m_pDescription4 = ""; + OptionMsg.m_pDescription5 = ""; + OptionMsg.m_pDescription6 = ""; + OptionMsg.m_pDescription7 = ""; + OptionMsg.m_pDescription8 = ""; + OptionMsg.m_pDescription9 = ""; + OptionMsg.m_pDescription10 = ""; + OptionMsg.m_pDescription11 = ""; + OptionMsg.m_pDescription12 = ""; + OptionMsg.m_pDescription13 = ""; + OptionMsg.m_pDescription14 = ""; + } + } + pCurrent = pCurrent->m_pNext; + } + if(NumOptions > 0) + { + OptionMsg.m_NumOptions = NumOptions; + Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID); + } + + // send tuning parameters to client + SendTuningParams(ClientID); + + // client is ready to enter + pPlayer->m_IsReady = true; + CNetMsg_Sv_ReadyToEnter m; + Server()->SendPackMsg(&m, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID); + } } } From f0e09f50d97209088ce9f3b79037fe4d582dfea0 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 1 Apr 2013 20:30:58 +0200 Subject: [PATCH 74/84] improved chat msg spam protection --- datasrc/network.py | 4 +-- src/base/system.c | 21 ++++++++++++ src/base/system.h | 1 + src/engine/shared/packer.cpp | 2 +- src/game/client/components/chat.cpp | 28 +++++++++++++++ src/game/client/components/menus.cpp | 3 +- src/game/client/lineinput.cpp | 22 ++++++++++-- src/game/client/lineinput.h | 10 ++++-- src/game/editor/editor.cpp | 3 +- src/game/server/gamecontext.cpp | 51 +++++++++++++++++++--------- 10 files changed, 119 insertions(+), 26 deletions(-) diff --git a/datasrc/network.py b/datasrc/network.py index cd5f5aee9..b2c42b321 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -231,7 +231,7 @@ Messages = [ NetMessage("Sv_Chat", [ NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'), NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'), - NetString("m_pMessage"), + NetStringStrict("m_pMessage"), ]), NetMessage("Sv_KillMsg", [ @@ -294,7 +294,7 @@ Messages = [ ### Client messages NetMessage("Cl_Say", [ NetBool("m_Team"), - NetString("m_pMessage"), + NetStringStrict("m_pMessage"), ]), NetMessage("Cl_SetTeam", [ diff --git a/src/base/system.c b/src/base/system.c index 410cb699a..49150b4e3 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -1829,6 +1829,27 @@ int str_toint(const char *str) { return atoi(str); } float str_tofloat(const char *str) { return atof(str); } +char *str_utf8_skip_whitespaces(char *str) +{ + char *str_old; + int code; + + while(*str) + { + str_old = str; + code = str_utf8_decode(&str); + + // check if unicode is not empty + if(code > 0x20 && code != 0xA0 && code != 0x034F && (code < 0x2000 || code > 0x200F) && (code < 0x2028 || code > 0x202F) && + (code < 0x205F || code > 0x2064) && (code < 0x206A || code > 0x206F) && (code < 0xFE00 || code > 0xFE0F) && + code != 0xFEFF && (code < 0xFFF9 || code > 0xFFFC)) + { + return str_old; + } + } + + return str; +} static int str_utf8_isstart(char c) { diff --git a/src/base/system.h b/src/base/system.h index 7ba0c0a09..871473406 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -1213,6 +1213,7 @@ unsigned str_quickhash(const char *str); */ void gui_messagebox(const char *title, const char *message); +char *str_utf8_skip_whitespaces(char *str); /* Function: str_utf8_rewind diff --git a/src/engine/shared/packer.cpp b/src/engine/shared/packer.cpp index cc218825c..788e564d0 100644 --- a/src/engine/shared/packer.cpp +++ b/src/engine/shared/packer.cpp @@ -136,7 +136,7 @@ const char *CUnpacker::GetString(int SanitizeType) str_sanitize(pPtr); else if(SanitizeType&SANITIZE_CC) str_sanitize_cc(pPtr); - return SanitizeType&SKIP_START_WHITESPACES ? str_skip_whitespaces(pPtr) : pPtr; + return SanitizeType&SKIP_START_WHITESPACES ? str_utf8_skip_whitespaces(pPtr) : pPtr; } const unsigned char *CUnpacker::GetRaw(int Size) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 5b2831df4..5da7e6312 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -282,6 +282,34 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) (m_pClient->m_Snap.m_LocalClientID != ClientID && g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[ClientID].m_Friend)))) return; + // trim right and set maximum length to 128 utf8-characters + int Length = 0; + const char *pStr = pLine; + const char *pEnd = 0; + while(*pStr) + { + const char *pStrOld = pStr; + int Code = str_utf8_decode(&pStr); + + // check if unicode is not empty + if(Code > 0x20 && Code != 0xA0 && Code != 0x034F && (Code < 0x2000 || Code > 0x200F) && (Code < 0x2028 || Code > 0x202F) && + (Code < 0x205F || Code > 0x2064) && (Code < 0x206A || Code > 0x206F) && (Code < 0xFE00 || Code > 0xFE0F) && + Code != 0xFEFF && (Code < 0xFFF9 || Code > 0xFFFC)) + { + pEnd = 0; + } + else if(pEnd == 0) + pEnd = pStrOld; + + if(++Length >= 127) + { + *(const_cast(pStr)) = 0; + break; + } + } + if(pEnd != 0) + *(const_cast(pEnd)) = 0; + bool Highlighted = false; char *p = const_cast(pLine); while(*p) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index d625d4c0d..111cad6a8 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -243,7 +243,8 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS for(int i = 0; i < m_NumInputEvents; i++) { Len = str_length(pStr); - ReturnValue |= CLineInput::Manipulate(m_aInputEvents[i], pStr, StrSize, &Len, &s_AtIndex); + int NumChars = Len; + ReturnValue |= CLineInput::Manipulate(m_aInputEvents[i], pStr, StrSize, StrSize, &Len, &s_AtIndex, &NumChars); } } diff --git a/src/game/client/lineinput.cpp b/src/game/client/lineinput.cpp index 2de85d667..11fae570b 100644 --- a/src/game/client/lineinput.cpp +++ b/src/game/client/lineinput.cpp @@ -13,6 +13,7 @@ void CLineInput::Clear() mem_zero(m_Str, sizeof(m_Str)); m_Len = 0; m_CursorPos = 0; + m_NumChars = 0; } void CLineInput::Set(const char *pString) @@ -20,10 +21,18 @@ void CLineInput::Set(const char *pString) str_copy(m_Str, pString, sizeof(m_Str)); m_Len = str_length(m_Str); m_CursorPos = m_Len; + m_NumChars = 0; + int Offset = 0; + while(pString[Offset]) + { + Offset = str_utf8_forward(pString, Offset); + ++m_NumChars; + } } -bool CLineInput::Manipulate(IInput::CEvent e, char *pStr, int StrMaxSize, int *pStrLenPtr, int *pCursorPosPtr) +bool CLineInput::Manipulate(IInput::CEvent e, char *pStr, int StrMaxSize, int StrMaxChars, int *pStrLenPtr, int *pCursorPosPtr, int *pNumCharsPtr) { + int NumChars = *pNumCharsPtr; int CursorPos = *pCursorPosPtr; int Len = *pStrLenPtr; bool Changes = false; @@ -40,13 +49,15 @@ bool CLineInput::Manipulate(IInput::CEvent e, char *pStr, int StrMaxSize, int *p char Tmp[8]; int CharSize = str_utf8_encode(Tmp, Code); - if (Len < StrMaxSize - CharSize && CursorPos < StrMaxSize - CharSize) + if (Len < StrMaxSize - CharSize && CursorPos < StrMaxSize - CharSize && NumChars < StrMaxChars) { mem_move(pStr + CursorPos + CharSize, pStr + CursorPos, Len-CursorPos+1); // +1 == null term for(int i = 0; i < CharSize; i++) pStr[CursorPos+i] = Tmp[i]; CursorPos += CharSize; Len += CharSize; + if(CharSize > 0) + ++NumChars; Changes = true; } } @@ -60,6 +71,8 @@ bool CLineInput::Manipulate(IInput::CEvent e, char *pStr, int StrMaxSize, int *p mem_move(pStr+NewCursorPos, pStr+CursorPos, Len - NewCursorPos - CharSize + 1); // +1 == null term CursorPos = NewCursorPos; Len -= CharSize; + if(CharSize > 0) + --NumChars; Changes = true; } else if (k == KEY_DELETE && CursorPos < Len) @@ -68,6 +81,8 @@ bool CLineInput::Manipulate(IInput::CEvent e, char *pStr, int StrMaxSize, int *p int CharSize = p-CursorPos; mem_move(pStr + CursorPos, pStr + CursorPos + CharSize, Len - CursorPos - CharSize + 1); // +1 == null term Len -= CharSize; + if(CharSize > 0) + --NumChars; Changes = true; } else if (k == KEY_LEFT && CursorPos > 0) @@ -80,6 +95,7 @@ bool CLineInput::Manipulate(IInput::CEvent e, char *pStr, int StrMaxSize, int *p CursorPos = Len; } + *pNumCharsPtr = NumChars; *pCursorPosPtr = CursorPos; *pStrLenPtr = Len; @@ -88,5 +104,5 @@ bool CLineInput::Manipulate(IInput::CEvent e, char *pStr, int StrMaxSize, int *p void CLineInput::ProcessInput(IInput::CEvent e) { - Manipulate(e, m_Str, sizeof(m_Str), &m_Len, &m_CursorPos); + Manipulate(e, m_Str, MAX_SIZE, MAX_CHARS, &m_Len, &m_CursorPos, &m_NumChars); } diff --git a/src/game/client/lineinput.h b/src/game/client/lineinput.h index 5dfc3e489..f6cb00162 100644 --- a/src/game/client/lineinput.h +++ b/src/game/client/lineinput.h @@ -8,11 +8,17 @@ // line input helter class CLineInput { - char m_Str[256]; + enum + { + MAX_SIZE=512, + MAX_CHARS=MAX_SIZE/4, + }; + char m_Str[MAX_SIZE]; int m_Len; int m_CursorPos; + int m_NumChars; public: - static bool Manipulate(IInput::CEvent e, char *pStr, int StrMaxSize, int *pStrLenPtr, int *pCursorPosPtr); + static bool Manipulate(IInput::CEvent e, char *pStr, int StrMaxSize, int StrMaxChars, int *pStrLenPtr, int *pCursorPosPtr, int *pNumCharsPtr); class CCallback { diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 28a4eda96..e7b917f4d 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -277,7 +277,8 @@ int CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned Str for(int i = 0; i < Input()->NumEvents(); i++) { Len = str_length(pStr); - ReturnValue |= CLineInput::Manipulate(Input()->GetEvent(i), pStr, StrSize, &Len, &s_AtIndex); + int NumChars = Len; + ReturnValue |= CLineInput::Manipulate(Input()->GetEvent(i), pStr, StrSize, StrSize, &Len, &s_AtIndex, &NumChars); } } diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index a2500dda6..f1c533504 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -612,26 +612,45 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) { if(MsgID == NETMSGTYPE_CL_SAY) { - CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg; - int Team = pMsg->m_Team; - if(Team) - Team = pPlayer->GetTeam(); - else - Team = CGameContext::CHAT_ALL; - if(g_Config.m_SvSpamprotection && pPlayer->m_LastChat && pPlayer->m_LastChat+Server()->TickSpeed() > Server()->Tick()) return; - pPlayer->m_LastChat = Server()->Tick(); + CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg; + int Team = pMsg->m_Team ? pPlayer->GetTeam() : CGameContext::CHAT_ALL; + + // trim right and set maximum length to 128 utf8-characters + int Length = 0; + const char *p = pMsg->m_pMessage; + const char *pEnd = 0; + while(*p) + { + const char *pStrOld = p; + int Code = str_utf8_decode(&p); - // check for invalid chars - unsigned char *pMessage = (unsigned char *)pMsg->m_pMessage; - while (*pMessage) - { - if(*pMessage < 32) - *pMessage = ' '; - pMessage++; - } + // check if unicode is not empty + if(Code > 0x20 && Code != 0xA0 && Code != 0x034F && (Code < 0x2000 || Code > 0x200F) && (Code < 0x2028 || Code > 0x202F) && + (Code < 0x205F || Code > 0x2064) && (Code < 0x206A || Code > 0x206F) && (Code < 0xFE00 || Code > 0xFE0F) && + Code != 0xFEFF && (Code < 0xFFF9 || Code > 0xFFFC)) + { + pEnd = 0; + } + else if(pEnd == 0) + pEnd = pStrOld; + + if(++Length >= 127) + { + *(const_cast(p)) = 0; + break; + } + } + if(pEnd != 0) + *(const_cast(pEnd)) = 0; + + // drop empty and autocreated spam messages (more than 16 characters per second) + if(Length == 0 || (g_Config.m_SvSpamprotection && pPlayer->m_LastChat && pPlayer->m_LastChat+Server()->TickSpeed()*((15+Length)/16) > Server()->Tick())) + return; + + pPlayer->m_LastChat = Server()->Tick(); SendChat(ClientID, Team, pMsg->m_pMessage); } From 61671f3bcdfa1dfda115516e8994818ce1e9882c Mon Sep 17 00:00:00 2001 From: Teetime Date: Sun, 7 Apr 2013 14:41:53 +0200 Subject: [PATCH 75/84] Fixed a missing check if killer is alive in tdm --- src/game/server/gamemodes/tdm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/server/gamemodes/tdm.cpp b/src/game/server/gamemodes/tdm.cpp index 50ecd93ec..373bbd094 100644 --- a/src/game/server/gamemodes/tdm.cpp +++ b/src/game/server/gamemodes/tdm.cpp @@ -17,7 +17,7 @@ int CGameControllerTDM::OnCharacterDeath(class CCharacter *pVictim, class CPlaye IGameController::OnCharacterDeath(pVictim, pKiller, Weapon); - if(Weapon != WEAPON_GAME) + if(pKiller && Weapon != WEAPON_GAME) { // do team scoring if(pKiller == pVictim->GetPlayer() || pKiller->GetTeam() == pVictim->GetPlayer()->GetTeam()) From 1a5e22dbcc3124d673a262dafa7c48dc2702acc5 Mon Sep 17 00:00:00 2001 From: chingis Date: Fri, 19 Apr 2013 19:23:01 +0600 Subject: [PATCH 76/84] Update kyrgyz.txt --- data/languages/kyrgyz.txt | 101 +++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/data/languages/kyrgyz.txt b/data/languages/kyrgyz.txt index 48c745eb2..c0b257965 100644 --- a/data/languages/kyrgyz.txt +++ b/data/languages/kyrgyz.txt @@ -1,11 +1,10 @@ - ##### translated strings ##### %d Bytes == %d байт %d of %d servers, %d players -== %d/%d сервер, %d оюнчу +== %d / %d сервер, %d оюнчу %d%% loaded == %d%% жүктөлдү @@ -50,22 +49,22 @@ Alpha == Тунук. Always show name plates -== Оюнчулардын аттарын дайыма көрсөтүү +== Ат көрнөкчөлөрдү дайыма көрсөтүү Are you sure that you want to delete the demo? -== Сиз анык эле демонун өчүрүлүшүн каалайсызбы? +== Сиз чын эле демонун өчүрүлүшүн каалайсызбы? Are you sure that you want to quit? -== Сиз анык эле оюндан чыгууну каалайсызбы? +== Сиз чын эле оюндан чыгууну каалайсызбы? Are you sure that you want to remove the player from your friends list? -== Сиз анык эле бул оюнчуну достор тизмесинен өчүрүүнү каалайсызбы? +== Сиз чын эле бул оюнчуну достор тизмеңизден өчүргүңүз келеби? As this is the first time you launch the game, please enter your nick name below. It's recommended that you check the settings to adjust them to your liking before joining a server. -== Бул оюндун биринчи жүргүзүлүшү болгону үчүн, төмөн жакка такма атыңызды киргизип, жана ырастоолорду текшерип коюңуз. +== Бул оюндун биринчи жүргүзүлүшү болгону үчүн, төмөн жакка такма атыңызды киргизиңиз. Серверге туташуу алдында ырастоолорду текшериңиз. Automatically record demos -== Демону автоматтуу түрдө жазуу +== Демону автоматтуу түрдө жаздыруу Automatically take game over screenshot == Оюн натыйжаларын сүрөткө тартуу @@ -86,7 +85,7 @@ Change settings == Ырастоолорду өзгөртүү Chat -== Чат +== Маек Clan == Кланы @@ -104,7 +103,7 @@ Connect == Туташуу Connecting to -== Туташтыруу +== Туташтырылууда Connection Problems... == Байланыш көйгөйлөрү... @@ -128,13 +127,13 @@ Created: == Жаратылганы: Current -== Кезектеги +== Кезектегиси Current version: %s == Кезектеги версиясы: %s Custom colors -== Өз түстөр +== Өз түстөрүңүз Delete == Өчүрүү @@ -146,10 +145,10 @@ Demo details == Демо деталдары Demofile: %s -== Демо: %s +== Демофайлы: %s Demos -== Демо +== Демолор Disconnect == Өчүрүү @@ -158,10 +157,10 @@ Disconnected == Өчүрүлдү Display Modes -== Экран чечими +== Көрсөтүү режимдери Downloading map -== Картаны жүктөө +== Карта жүктөөлүүдө Draw! == Тең! @@ -212,7 +211,7 @@ Friends == Достор Fullscreen -== Толук экран режими +== Толук экран Game == Оюн @@ -245,7 +244,7 @@ Has people playing == Бош эмес сервер High Detail -== Жогорку детализация +== Жогорку деталдаштыруу Hook == Илмек @@ -269,7 +268,7 @@ Join blue == Көктөргө Join game -== Оюноо +== Ойноо Join red == Кызылдарга @@ -278,7 +277,7 @@ Jump == Секирүү Kick player -== Оюнчуну бан кылуу +== Оюнчуну чыгаруу LAN == LAN @@ -287,13 +286,13 @@ Language == Тил Length: -== Узун.: +== Узундугу: Lht. == Ач. түс. Loading -== Жүктөө +== Жүктөлүүдө MOTD == Күндүн билдирүүсү @@ -305,13 +304,13 @@ Map: == Картасы: Max Screenshots -== Максималдуу сүрөт саны +== Сүрөттөрдүн жогорку чеги Max demos -== Максималдуу демо саны +== Демолордун жогорку чеги Maximum ping: -== Макс. пинги: +== Пингдин ж. чеги: Miscellaneous == Кошумча @@ -323,7 +322,7 @@ Move left == Солго басуу Move player to spectators -== Оюнчуну байкоочу кылуу +== Оюнчуну байкоочуларга ташуу Move right == Оңго басуу @@ -332,19 +331,19 @@ Movement == Аракет Mute when not active -== Активдүү эмес кезде колдонбоо +== Активдүү эмес кезде үндү өчүрүү Name == Аты Name plates size -== Өлчөм +== Ат көрнөкчөлөрдүн өлчөмү Netversion: == Версиясы: New name: -== Жаңы ат: +== Жаңы аты: News == Жаңылыктар @@ -353,7 +352,7 @@ Next weapon == Кийин. курал Nickname -== Такма ат +== Такма атыңыз No == Жок @@ -404,7 +403,7 @@ Player options == Оюнчу опциялары Players -== Оюнчулары +== Оюнчулар Please balance teams! == Команадаларды баланстаңыз! @@ -425,13 +424,13 @@ Quit anyway? == Чыгуу? REC %3d:%02d -== ЖАЗУУ %3d:%02d +== ЖАЗДЫРУУ %3d:%02d Reason: -== Себеп: +== Себеби: Record demo -== Демо жазуу +== Демо жаздыруу Red team == Кызылдар @@ -446,7 +445,7 @@ Refreshing master servers == Мастер-серверлер тизмесин жаңылоо Remote console -== Сервер консолу +== Алыскы консоль Remove == Өчүрүү @@ -455,7 +454,7 @@ Remove friend == Досту өчүрүү Rename -== Атын өзгөрт. +== Атын өзгөртүү Rename demo == Демо атын өзгөртүү @@ -464,7 +463,7 @@ Reset filter == Фильтрлерди түшүрүү Reset to defaults -== Ырастоолорду түшүрүү +== Жарыяланбаска түшүрүү Rifle == Бластер @@ -485,7 +484,7 @@ Score board == Табло Score limit -== Упай лимити +== Упай чеги Scoreboard == Табло @@ -515,7 +514,7 @@ Shotgun == Мылтык Show chat -== Чатты көрсөтүү +== Маекти көрсөтүү Show friends only == Достор менен гана @@ -527,13 +526,13 @@ Show name plates == Оюнчулардын аттарын көрсөтүү Show only supported -== Колдолгон чечимдерди гана көрсөтүү +== Колдолгонду гана көрсөтүү Size: == Өлчөмү: Skins -== Скиндер +== Терилер Sound == Үн @@ -542,7 +541,7 @@ Sound error == Үн катасы Sound volume -== Үн катуулугу +== Үн көлөмү Spectate == Байкоо @@ -569,7 +568,7 @@ Stop record == Токтотуу Strict gametype filter -== Оюн түрүнүн так фильтри +== Так оюн түрүнүн фильтри Sudden Death == Тез өлүм @@ -581,7 +580,7 @@ Team == Команда Team chat -== Команда чаты +== Команда маеги Teeworlds %s is out! Download it at www.teeworlds.com! == Teeworlds %s чыкты! www.teeworlds.com сайтынан жүктөп алыңыз! @@ -599,10 +598,10 @@ There's an unsaved map in the editor, you might want to save it before you quit == Редактордо сакталбаган карта бар, аны оюндан чыгаар алдында сактасаңыз болот. Time limit -== Убакыт лимити +== Убакыт чеги Time limit: %d min -== Убакыт лимити: %d мин. +== Убакыт чеги: %d мин. Try again == ОК @@ -629,7 +628,7 @@ Use team colors for name plates == Аттар үчүн команданын түсүн колдонуу V-Sync -== Вертикалдык синхронизация +== Тик синхрондоштуруусу Version == Версиясы @@ -668,19 +667,19 @@ You must restart the game for all settings to take effect. == Өзгөртүүлөрдү колдонуу үчүн оюнду кайта жүргүзүңүз. Your skin -== Скиниңиз +== Териңиз no limit -== лимитсиз +== чексиз Game paused == Оюн бир азга токтотулду Respawn -== Респаун +== Кайра жаралуу Show only chat messages from friends -== Достордун гана чат билдирүүлөрүн көрсөтүү +== Достордун гана маек билдирүүлөрүн көрсөтүү ##### needs translation ##### From eedd4fed0dcadeac05eae13140ee4fbdd6ba7384 Mon Sep 17 00:00:00 2001 From: chingis Date: Sat, 20 Apr 2013 05:05:41 +0600 Subject: [PATCH 77/84] Update kyrgyz.txt --- data/languages/kyrgyz.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/languages/kyrgyz.txt b/data/languages/kyrgyz.txt index c0b257965..c65e376be 100644 --- a/data/languages/kyrgyz.txt +++ b/data/languages/kyrgyz.txt @@ -568,7 +568,7 @@ Stop record == Токтотуу Strict gametype filter -== Так оюн түрүнүн фильтри +== Оюн түрүнүн так фильтри Sudden Death == Тез өлүм From 234a76f0b3da306ed6a4e5d72d0bddc15c742096 Mon Sep 17 00:00:00 2001 From: BeaR Date: Tue, 2 Apr 2013 16:53:57 +0200 Subject: [PATCH 78/84] Fixing atomics --- src/base/tl/threading.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/base/tl/threading.h b/src/base/tl/threading.h index 5caf8588b..c2bc5abcc 100644 --- a/src/base/tl/threading.h +++ b/src/base/tl/threading.h @@ -7,19 +7,19 @@ atomic_inc - should return the value after increment atomic_dec - should return the value after decrement atomic_compswap - should return the value before the eventual swap - + sync_barrier - creates a full hardware fence */ #if defined(__GNUC__) inline unsigned atomic_inc(volatile unsigned *pValue) { - return __sync_fetch_and_add(pValue, 1); + return __sync_add_and_fetch(pValue, 1); } inline unsigned atomic_dec(volatile unsigned *pValue) { - return __sync_fetch_and_add(pValue, -1); + return __sync_add_and_fetch(pValue, -1); } inline unsigned atomic_compswap(volatile unsigned *pValue, unsigned comperand, unsigned value) @@ -52,7 +52,7 @@ inline void sync_barrier() { - _ReadWriteBarrier(); + _mm_mfence(); } #else #error missing atomic implementation for this compiler From 9b81779ae3a10134bcca6c299aa74d8e88fbd792 Mon Sep 17 00:00:00 2001 From: BeaR Date: Wed, 3 Apr 2013 11:44:06 +0200 Subject: [PATCH 79/84] Using MemoryBarrier() for CPUs not supporting SSE2 --- src/base/tl/threading.h | 5 ++++- src/engine/client/client.cpp | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/base/tl/threading.h b/src/base/tl/threading.h index c2bc5abcc..2cfbc0523 100644 --- a/src/base/tl/threading.h +++ b/src/base/tl/threading.h @@ -35,6 +35,9 @@ #elif defined(_MSC_VER) #include + #define WIN32_LEAN_AND_MEAN + #include + inline unsigned atomic_inc(volatile unsigned *pValue) { return _InterlockedIncrement((volatile long *)pValue); @@ -52,7 +55,7 @@ inline void sync_barrier() { - _mm_mfence(); + MemoryBarrier(); } #else #error missing atomic implementation for this compiler diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 30f92eb0b..3300d6ca5 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include From fd5fe8b6ae92a08f8f1e29138a6c9ec7953b38d4 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 26 Apr 2013 17:10:05 +0200 Subject: [PATCH 80/84] fixed a warning --- src/base/system.c | 4 ++-- src/base/system.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/base/system.c b/src/base/system.c index 49150b4e3..53af5d0fb 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -1829,9 +1829,9 @@ int str_toint(const char *str) { return atoi(str); } float str_tofloat(const char *str) { return atof(str); } -char *str_utf8_skip_whitespaces(char *str) +const char *str_utf8_skip_whitespaces(const char *str) { - char *str_old; + const char *str_old; int code; while(*str) diff --git a/src/base/system.h b/src/base/system.h index 871473406..ae37c1a98 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -1213,7 +1213,7 @@ unsigned str_quickhash(const char *str); */ void gui_messagebox(const char *title, const char *message); -char *str_utf8_skip_whitespaces(char *str); +const char *str_utf8_skip_whitespaces(const char *str); /* Function: str_utf8_rewind From 614020de6ea6967690439fcb861af17af2661516 Mon Sep 17 00:00:00 2001 From: oy Date: Thu, 2 May 2013 00:38:32 +0200 Subject: [PATCH 81/84] fixed make_release script on win64 --- scripts/make_release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/make_release.py b/scripts/make_release.py index 90c8a964e..b8f82fe0b 100644 --- a/scripts/make_release.py +++ b/scripts/make_release.py @@ -31,7 +31,7 @@ if platform == "src": # print(valid_platforms) # sys.exit(-1) -if platform == 'win32': +if platform == 'win32' or platform == 'win64': exe_ext = ".exe" use_zip = 1 use_gz = 0 From ee9a8ce4b7218d84404e49f4778878008b85f483 Mon Sep 17 00:00:00 2001 From: m!nus Date: Sun, 26 May 2013 10:58:03 +0200 Subject: [PATCH 82/84] prevent map editor from crashing if loaded map is invalid --- src/game/editor/editor.cpp | 5 +++++ src/game/editor/io.cpp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index e7b917f4d..5e8c2407d 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -711,6 +711,11 @@ void CEditor::CallbackOpenMap(const char *pFileName, int StorageType, void *pUse pEditor->m_Dialog = DIALOG_NONE; pEditor->m_Map.m_Modified = false; } + else + { + pEditor->Reset(); + pEditor->m_aFileName[0] = 0; + } } void CEditor::CallbackAppendMap(const char *pFileName, int StorageType, void *pUser) { diff --git a/src/game/editor/io.cpp b/src/game/editor/io.cpp index 529638cfb..641ec81ba 100644 --- a/src/game/editor/io.cpp +++ b/src/game/editor/io.cpp @@ -435,6 +435,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag editor->reset(); editor_load_old(df, this); */ + return 0; } else if(pItem->m_Version == 1) { @@ -650,6 +651,8 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag } } } + else + return 0; return 1; } From 7cb173ec53589ad2653f55f7ab27d19184e1300b Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 25 Sep 2013 14:56:47 +0200 Subject: [PATCH 83/84] fixed master server lookup for servers. #1047 --- src/engine/shared/masterserver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/shared/masterserver.cpp b/src/engine/shared/masterserver.cpp index 954826393..59928c5e6 100644 --- a/src/engine/shared/masterserver.cpp +++ b/src/engine/shared/masterserver.cpp @@ -45,7 +45,7 @@ public: virtual int RefreshAddresses(int Nettype) { - if(m_State != STATE_INIT) + if(m_State != STATE_INIT && m_State != STATE_READY) return -1; dbg_msg("engine/mastersrv", "refreshing master server addresses"); From 77478707f2aaabde16c1695de2db6b2159df8471 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 15 Dec 2013 12:30:27 +0100 Subject: [PATCH 84/84] fixed a server crash due to faulty offsets. #1173 --- src/engine/shared/console.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/engine/shared/console.h b/src/engine/shared/console.h index bbe267d42..a45a7fd6e 100644 --- a/src/engine/shared/console.h +++ b/src/engine/shared/console.h @@ -98,12 +98,11 @@ class CConsole : public IConsole if(this != &Other) { IResult::operator=(Other); - int Offset = m_aStringStorage - Other.m_aStringStorage; mem_copy(m_aStringStorage, Other.m_aStringStorage, sizeof(m_aStringStorage)); - m_pArgsStart = Other.m_pArgsStart + Offset; - m_pCommand = Other.m_pCommand + Offset; + m_pArgsStart = m_aStringStorage+(Other.m_pArgsStart-Other.m_aStringStorage); + m_pCommand = m_aStringStorage+(Other.m_pCommand-Other.m_aStringStorage); for(unsigned i = 0; i < Other.m_NumArgs; ++i) - m_apArgs[i] = Other.m_apArgs[i] + Offset; + m_apArgs[i] = m_aStringStorage+(Other.m_apArgs[i]-Other.m_aStringStorage); } return *this; }