diff -Nru ddnet-11.1.3/appveyor.yml ddnet-11.1.8/appveyor.yml --- ddnet-11.1.3/appveyor.yml 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/appveyor.yml 2018-05-13 20:23:11.000000000 +0000 @@ -40,3 +40,4 @@ branches: except: - staging.tmp + - testing.tmp diff -Nru ddnet-11.1.3/circle.yml ddnet-11.1.8/circle.yml --- ddnet-11.1.3/circle.yml 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/circle.yml 2018-05-13 20:23:11.000000000 +0000 @@ -34,6 +34,7 @@ branches: ignore: - staging.tmp + - testing.tmp ## ##deployment: diff -Nru ddnet-11.1.3/CMakeLists.txt ddnet-11.1.8/CMakeLists.txt --- ddnet-11.1.3/CMakeLists.txt 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/CMakeLists.txt 2018-05-13 20:23:11.000000000 +0000 @@ -667,6 +667,9 @@ layers.h localization.cpp localization.h + mapbugs.cpp + mapbugs.h + mapbugs_list.h mapitems.cpp mapitems.h teamscore.cpp @@ -1104,6 +1107,7 @@ fs.cpp git_revision.cpp jobs.cpp + mapbugs.cpp name_ban.cpp str.cpp strip_path_and_extension.cpp diff -Nru ddnet-11.1.3/data/languages/portuguese.txt ddnet-11.1.8/data/languages/portuguese.txt --- ddnet-11.1.3/data/languages/portuguese.txt 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/data/languages/portuguese.txt 2018-05-13 20:23:11.000000000 +0000 @@ -5,6 +5,7 @@ # HeroiAmarelo 2011-07-15 00:35:23 # HeroiAmarelo 2012-08-01 15:47:40 # HeroiAmarelo 2012-10-18 23:56:32 +# Rockus 2018-04-06 ##### /authors ##### ##### translated strings ##### @@ -55,7 +56,7 @@ == Queres mesmo apagar o jogador da tua lista de amigos? 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. -== Olá! Pelos vistos é a primeira vez que inicias o jogo, por isso escolhe um Nick Name para ti! Aproveita e vê as configurações antes de entrar num servidor! +== Olá! Pelos vistos é a primeira vez que inicias o jogo, por isso escolhe um nick name para ti! Aproveita e vê as configurações antes de entrares num servidor! Automatically record demos == Gravar demos automaticamente @@ -271,19 +272,19 @@ == Sens. do rato Move left -== Move-te para a esquerda +== Mover para a esquerda Move player to spectators == Juntar jogador aos spectators Move right -== Move-te para a direita +== Mover para a direita Movement == Movimento Mute when not active -== Fazer mute em estado AFK +== Silenciar quando inativo Name == Nome @@ -427,7 +428,7 @@ == Filtro de servidores Server info -== Informação +== Info de servidor Server not full == Servidor não cheio @@ -688,7 +689,7 @@ == Dummy settings -== Configurações do Dummy +== Configurações do Dummy AntiPing == Antiping @@ -718,7 +719,7 @@ == Mostrar mensagens de morte Show ghost -== Mostrar fantasma +== Mostrar ghost DDNet == DDNet @@ -736,10 +737,10 @@ == Mostrar janela de voto depois de votar HUD -== +== HUD Look out! -== +== Cuidado! Show names in chat in team colors == Mostrar nomes no chat com cores da equipa @@ -796,7 +797,7 @@ == Navegador Follow -== +== Seguir Enable gun sound == Ativar o som da arma @@ -811,7 +812,7 @@ == Automatically create statboard csv -== +== Criar automaticamente csv de statboard Save the best demo of each race == Guardar a melhor demo de cada corrida @@ -826,7 +827,7 @@ == Tipos Ghost -== Fantasma +== Ghost Remove chat == Removar o chat @@ -841,7 +842,7 @@ == Background (regular) -== Plano de fundo (regular) +== Plano de fundo (regular) DDNet %s is out! Download it at DDNet.tw! == DDNet %s saiu! Saca-o em DDNet.tw! @@ -859,7 +860,7 @@ == Automatically take statboard screenshot -== +== Tirar automaticamente screenshot da statboard System message == Mensagem do sistema @@ -916,7 +917,7 @@ == Mostrar os IDs do cliente na tabela de pontuação Max CSVs -== +== CSVs máximos seconds == segundos @@ -955,10 +956,10 @@ == Show clan above name plates -== Mostrar o nome do clã por cima do nome +== Mostrar o nome do clã por cima do nick Save ghost -== Guardar fantasma +== Guardar ghost Exclude == Excluir diff -Nru ddnet-11.1.3/debian/changelog ddnet-11.1.8/debian/changelog --- ddnet-11.1.3/debian/changelog 2018-04-09 02:55:12.000000000 +0000 +++ ddnet-11.1.8/debian/changelog 2018-05-24 06:26:39.000000000 +0000 @@ -1,3 +1,10 @@ +ddnet (11.1.8-1) unstable; urgency=medium + + * New upstream release + * Temporarily bundle icon font since it uses Unicode private area + + -- Yangfl Thu, 24 May 2018 14:26:39 +0800 + ddnet (11.1.3-1) unstable; urgency=medium * New upstream release diff -Nru ddnet-11.1.3/debian/control ddnet-11.1.8/debian/control --- ddnet-11.1.3/debian/control 2018-04-09 02:55:12.000000000 +0000 +++ ddnet-11.1.8/debian/control 2018-05-24 06:26:39.000000000 +0000 @@ -79,10 +79,9 @@ Multi-Arch: foreign Depends: ${misc:Depends}, -Recommends: fonts-dejavu-core, +Recommends: fonts-wqy-microhei, - fonts-materialdesignicons-webfont, Description: Data for DDNet DDraceNetwork (DDNet) is an actively maintained version of DDRace, a Teeworlds modification with a unique cooperative gameplay. Help each other play through diff -Nru ddnet-11.1.3/debian/ddnet-data.links ddnet-11.1.8/debian/ddnet-data.links --- ddnet-11.1.3/debian/ddnet-data.links 2018-04-09 02:55:12.000000000 +0000 +++ ddnet-11.1.8/debian/ddnet-data.links 2018-05-24 06:26:39.000000000 +0000 @@ -1,3 +1,2 @@ /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf /usr/share/games/ddnet/data/fonts/DejaVuSansCJKName.ttf /usr/share/fonts/truetype/wqy/wqy-microhei.ttc /usr/share/games/ddnet/data/fonts/DejavuWenQuanYiMicroHei.ttf -/usr/share/fonts/truetype/materialdesignicons-webfont/materialdesignicons-webfont.ttf /usr/share/games/ddnet/data/fonts/Icons.ttf diff -Nru ddnet-11.1.3/other/manifest/DDNet.manifest ddnet-11.1.8/other/manifest/DDNet.manifest --- ddnet-11.1.3/other/manifest/DDNet.manifest 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/other/manifest/DDNet.manifest 2018-05-13 20:23:11.000000000 +0000 @@ -11,10 +11,10 @@ - - - - + + + + diff -Nru ddnet-11.1.3/src/base/system.c ddnet-11.1.8/src/base/system.c --- ddnet-11.1.3/src/base/system.c 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/base/system.c 2018-05-13 20:23:11.000000000 +0000 @@ -93,7 +93,6 @@ static int num_loggers = 0; static NETSTATS network_stats = {0}; -static MEMSTATS memory_stats = {0}; static NETSOCKET invalid_socket = {NETTYPE_INVALID, -1, -1}; @@ -246,138 +245,6 @@ } /* */ -typedef struct MEMHEADER -{ - const char *filename; - int line; - int size; - struct MEMHEADER *prev; - struct MEMHEADER *next; -} MEMHEADER; - -typedef struct MEMTAIL -{ - int guard; -} MEMTAIL; - -static LOCK mem_lock = (LOCK)0x0; -static char init_mem_lock = 0; -static struct MEMHEADER *first = 0; -static const int MEM_GUARD_VAL = 0xbaadc0de; - -void *mem_alloc_impl(unsigned size, unsigned alignment) -{ - /* TODO: remove alignment parameter */ - return malloc(size); -} - -void *mem_alloc_debug(const char *filename, int line, unsigned size, unsigned alignment) -{ - /* TODO: add debugging */ - MEMTAIL *tail; - MEMHEADER *header = (struct MEMHEADER *)mem_alloc_impl(size+sizeof(MEMHEADER)+sizeof(MEMTAIL), alignment); - - dbg_assert(header != 0, "mem_alloc failure"); - if(!header) - return NULL; - - tail = (struct MEMTAIL *)(((char*)(header + 1)) + size); - header->size = size; - header->filename = filename; - header->line = line; - tail->guard = MEM_GUARD_VAL; - - if(init_mem_lock == 0) - { - init_mem_lock = 1; - mem_lock = lock_create(); - } - - if(mem_lock) - lock_wait(mem_lock); - - memory_stats.allocated += header->size; - memory_stats.total_allocations++; - memory_stats.active_allocations++; - - header->prev = (MEMHEADER *)0; - header->next = first; - if(first) - first->prev = header; - first = header; - - if(mem_lock) - lock_unlock(mem_lock); - - /*dbg_msg("mem", "++ %p", header+1); */ - return header+1; -} - -void mem_free_impl(void *p) -{ - free(p); -} - -void mem_free_debug(void *p) -{ - if(p) - { - MEMHEADER *header = (MEMHEADER *)p - 1; - MEMTAIL *tail = (MEMTAIL *)(((char*)(header+1))+header->size); - - if(mem_lock) - lock_wait(mem_lock); - - if(tail->guard != MEM_GUARD_VAL) - dbg_msg("mem", "!! %p", p); - /* dbg_msg("mem", "-- %p", p); */ - memory_stats.allocated -= header->size; - memory_stats.active_allocations--; - - if(header->prev) - header->prev->next = header->next; - else - first = header->next; - if(header->next) - header->next->prev = header->prev; - - if(mem_lock) - lock_unlock(mem_lock); - - mem_free_impl(header); - } -} - -void mem_debug_dump(IOHANDLE file) -{ - char buf[1024]; - MEMHEADER *header; - - if(mem_lock) - lock_wait(mem_lock); - - header = first; - - if(!file) - file = io_open("memory.txt", IOFLAG_WRITE); - - if(file) - { - while(header) - { - str_format(buf, sizeof(buf), "%s(%d): %d", header->filename, header->line, header->size); - io_write(file, buf, strlen(buf)); - io_write_newline(file); - header = header->next; - } - - io_close(file); - } - - if(mem_lock) - lock_unlock(mem_lock); -} - void mem_copy(void *dest, const void *source, unsigned size) { memcpy(dest, source, size); @@ -393,32 +260,6 @@ memset(block, 0, size); } -int mem_check_imp() -{ - MEMHEADER *header; - - if(mem_lock) - lock_wait(mem_lock); - - header = first; - - while(header) - { - MEMTAIL *tail = (MEMTAIL *)(((char*)(header+1))+header->size); - if(tail->guard != MEM_GUARD_VAL) - { - dbg_msg("mem", "memory check failed at %s(%d): %d", header->filename, header->line, header->size); - return 0; - } - header = header->next; - } - - if(mem_lock) - lock_unlock(mem_lock); - - return 1; -} - IOHANDLE io_open(const char *filename, int flags) { if(flags == IOFLAG_READ) @@ -569,10 +410,10 @@ lock_unlock(aio->lock); if(do_free) { - mem_free(aio->buffer); + free(aio->buffer); sphore_destroy(&aio->sphore); lock_destroy(aio->lock); - mem_free(aio); + free(aio); } } @@ -638,7 +479,7 @@ ASYNCIO *aio_new(IOHANDLE io) { - ASYNCIO *aio = mem_alloc(sizeof(*aio), sizeof(void *)); + ASYNCIO *aio = malloc(sizeof(*aio)); if(!aio) { return 0; @@ -648,12 +489,12 @@ sphore_init(&aio->sphore); aio->thread = 0; - aio->buffer = mem_alloc(ASYNC_BUFSIZE, 1); + aio->buffer = malloc(ASYNC_BUFSIZE); if(!aio->buffer) { sphore_destroy(&aio->sphore); lock_destroy(aio->lock); - mem_free(aio); + free(aio); return 0; } aio->buffer_size = ASYNC_BUFSIZE; @@ -666,10 +507,10 @@ aio->thread = thread_init(aio_thread, aio); if(!aio->thread) { - mem_free(aio->buffer); + free(aio->buffer); sphore_destroy(&aio->sphore); lock_destroy(aio->lock); - mem_free(aio); + free(aio); return 0; } return aio; @@ -732,7 +573,7 @@ unsigned int new_written = buffer_len(aio) + size + 1; unsigned int next_size = next_buffer_size(aio->buffer_size, new_written); unsigned int next_len = 0; - unsigned char *next_buffer = mem_alloc(next_size, 1); + unsigned char *next_buffer = malloc(next_size); struct BUFFERS buffers; buffer_ptrs(aio, &buffers); @@ -749,7 +590,7 @@ mem_copy(next_buffer + next_len, buffer, size); next_len += size; - mem_free(aio->buffer); + free(aio->buffer); aio->buffer = next_buffer; aio->buffer_size = next_size; aio->read_pos = 0; @@ -899,7 +740,7 @@ LOCK lock_create() { - LOCKINTERNAL *lock = (LOCKINTERNAL*)mem_alloc(sizeof(LOCKINTERNAL), 4); + LOCKINTERNAL *lock = (LOCKINTERNAL *)malloc(sizeof(*lock)); #if defined(CONF_FAMILY_UNIX) pthread_mutex_init(lock, 0x0); @@ -920,7 +761,7 @@ #else #error not implemented on this platform #endif - mem_free(lock); + free(lock); } int lock_trylock(LOCK lock) @@ -2485,9 +2326,9 @@ int str_utf8_dist(const char *a, const char *b) { int buf_len = 2 * (str_length(a) + 1 + str_length(b) + 1); - int *buf = (int *)mem_alloc(buf_len * sizeof(*buf), 1); + int *buf = (int *)calloc(buf_len, sizeof(*buf)); int result = str_utf8_dist_buffer(a, b, buf, buf_len); - mem_free(buf); + free(buf); return result; } @@ -2723,11 +2564,6 @@ return memcmp(a,b,size); } -const MEMSTATS *mem_stats() -{ - return &memory_stats; -} - void net_stats(NETSTATS *stats_inout) { *stats_inout = network_stats; diff -Nru ddnet-11.1.3/src/base/system.h ddnet-11.1.8/src/base/system.h --- ddnet-11.1.3/src/base/system.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/base/system.h 2018-05-13 20:23:11.000000000 +0000 @@ -9,7 +9,8 @@ #define BASE_SYSTEM_H #include "detect.h" -#include "stddef.h" +#include +#include #include #ifdef CONF_FAMILY_UNIX @@ -93,82 +94,6 @@ /* Group: Memory */ /* - Function: mem_alloc_impl - Allocates memory. - - Parameters: - size - Size of the needed block. - alignment - Alignment for the block. - - Returns: - Returns a pointer to the newly allocated block. Returns a - null pointer if the memory couldn't be allocated. - - Remarks: - - Passing 0 to size will allocated the smallest amount possible - and return a unique pointer. - - See Also: - -*/ -void *mem_alloc_impl(unsigned size, unsigned alignment); - -/* - Function: mem_alloc - Allocates memory. - - Parameters: - size - Size of the needed block. - alignment - Alignment for the block. - - Returns: - Returns a pointer to the newly allocated block. Returns a - null pointer if the memory couldn't be allocated. - - Remarks: - - Passing 0 to size will allocated the smallest amount possible - and return a unique pointer. - - See Also: - , -*/ -void *mem_alloc_debug(const char *filename, int line, unsigned size, unsigned alignment); -#ifdef CONF_DEBUG -#define mem_alloc(s,a) mem_alloc_debug(__FILE__, __LINE__, (s), (a)) -#else -#define mem_alloc(s,a) mem_alloc_impl(s, a) -#endif - -/* - Function: mem_free - Frees a block allocated through . - - Remarks: - - Is safe on null pointers. - - See Also: - -*/ -void mem_free_impl(void *block); - -/* - Function: mem_free - Frees a block allocated through . - - Remarks: - - Is safe on null pointers. - - See Also: - , -*/ -void mem_free_debug(void *block); -#ifdef CONF_DEBUG -#define mem_free(p) mem_free_debug(p) -#else -#define mem_free(p) mem_free_impl(p) -#endif - -/* Function: mem_copy Copies a a memory block. @@ -230,14 +155,6 @@ */ int mem_comp(const void *a, const void *b, int size); -/* - Function: mem_check - Validates the heap - Will trigger a assert if memory has failed. -*/ -int mem_check_imp(); -#define mem_check() dbg_assert_imp(__FILE__, __LINE__, mem_check_imp(), "Memory check failed") - /* Group: File IO */ enum { IOFLAG_READ = 1, @@ -1586,8 +1503,6 @@ int net_socket_read_wait(NETSOCKET sock, int time); -void mem_debug_dump(IOHANDLE file); - void swap_endian(void *data, unsigned elem_size, unsigned num); @@ -1601,15 +1516,6 @@ typedef struct { - int allocated; - int active_allocations; - int total_allocations; -} MEMSTATS; - -const MEMSTATS *mem_stats(); - -typedef struct -{ int sent_packets; int sent_bytes; int recv_packets; diff -Nru ddnet-11.1.3/src/engine/client/backend_sdl.cpp ddnet-11.1.8/src/engine/client/backend_sdl.cpp --- ddnet-11.1.3/src/engine/client/backend_sdl.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/client/backend_sdl.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -166,7 +166,7 @@ else if(Format == CCommandBuffer::TEXFORMAT_ALPHA) Bpp = 1; - pTmpData = (unsigned char *)mem_alloc(NewWidth*NewHeight*Bpp, 1); + pTmpData = (unsigned char *)malloc(NewWidth * NewHeight * Bpp); int c = 0; for(int y = 0; y < NewHeight; y++) @@ -265,13 +265,13 @@ } void *pTmpData = Rescale(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast(pCommand->m_pData)); - mem_free(pTexData); + free(pTexData); pTexData = pTmpData; } glTexSubImage2D(GL_TEXTURE_2D, 0, X, Y, Width, Height, TexFormatToOpenGLFormat(pCommand->m_Format), GL_UNSIGNED_BYTE, pTexData); - mem_free(pTexData); + free(pTexData); } void CCommandProcessorFragment_OpenGL::Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand) @@ -307,7 +307,7 @@ } while(Width > m_MaxTexSize || Height > m_MaxTexSize); void *pTmpData = Rescale(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast(pCommand->m_pData)); - mem_free(pTexData); + free(pTexData); pTexData = pTmpData; } else if(pCommand->m_Format != CCommandBuffer::TEXFORMAT_ALPHA && (Width > 16 && Height > 16 && (pCommand->m_Flags&CCommandBuffer::TEXFLAG_QUALITY) == 0)) @@ -317,7 +317,7 @@ ++RescaleCount; void *pTmpData = Rescale(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast(pCommand->m_pData)); - mem_free(pTexData); + free(pTexData); pTexData = pTmpData; } } @@ -357,7 +357,7 @@ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); gluBuild2DMipmaps(GL_TEXTURE_2D, StoreOglformat, Width, Height, Oglformat, GL_UNSIGNED_BYTE, pTexData); } - + // calculate memory usage m_aTextures[pCommand->m_Slot].m_MemSize = Width*Height*pCommand->m_PixelSize; while(Width > 2 && Height > 2) @@ -368,7 +368,7 @@ } *m_pTextureMemoryUsage += m_aTextures[pCommand->m_Slot].m_MemSize; - mem_free(pTexData); + free(pTexData); } void CCommandProcessorFragment_OpenGL::Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand) @@ -419,7 +419,7 @@ int h = aViewport[3]; // we allocate one more row to use when we are flipping the texture - unsigned char *pPixelData = (unsigned char *)mem_alloc(w*(h+1)*3, 1); + unsigned char *pPixelData = (unsigned char *)malloc(w*(h+1)*3); unsigned char *pTempRow = pPixelData+w*h*3; // fetch the pixels @@ -498,7 +498,7 @@ else if(Format == CCommandBuffer::TEXFORMAT_ALPHA) Bpp = 1; - pTmpData = (unsigned char *)mem_alloc(NewWidth*NewHeight*Bpp, 1); + pTmpData = (unsigned char *)malloc(NewWidth*NewHeight*Bpp); int c = 0; for(int y = 0; y < NewHeight; y++) @@ -534,7 +534,7 @@ default: dbg_msg("render", "unknown blendmode %d\n", State.m_BlendMode); }; - + m_LastBlendMode = State.m_BlendMode; } @@ -556,7 +556,7 @@ if(State.m_Texture >= 0 && State.m_Texture < CCommandBuffer::MAX_TEXTURES) { int Slot = State.m_Texture % m_MaxTextureUnits; - + if(m_UseMultipleTextureUnits) { if(!IsAndUpdateTextureSlotBound(Slot, State.m_Texture)) @@ -652,7 +652,7 @@ { glActiveTexture(GL_TEXTURE0); } - + m_pTextureMemoryUsage = pCommand->m_pTextureMemoryUsage; m_LastBlendMode = CCommandBuffer::BLEND_ALPHA; m_LastClipEnable = false; @@ -668,20 +668,20 @@ m_pTextProgram = new CGLSLTextProgram; m_pSpriteProgram = new CGLSLSpriteProgram; m_pSpriteProgramMultiple = new CGLSLSpriteMultipleProgram; - + { CGLSL PrimitiveVertexShader; CGLSL PrimitiveFragmentShader; PrimitiveVertexShader.LoadShader(pCommand->m_pStorage, "shader/prim.vert", GL_VERTEX_SHADER); PrimitiveFragmentShader.LoadShader(pCommand->m_pStorage, "shader/prim.frag", GL_FRAGMENT_SHADER); - + m_pPrimitiveProgram->CreateProgram(); m_pPrimitiveProgram->AddShader(&PrimitiveVertexShader); m_pPrimitiveProgram->AddShader(&PrimitiveFragmentShader); m_pPrimitiveProgram->LinkProgram(); - + UseProgram(m_pPrimitiveProgram); - + m_pPrimitiveProgram->m_LocPos = m_pPrimitiveProgram->GetUniformLoc("Pos"); m_pPrimitiveProgram->m_LocIsTextured = m_pPrimitiveProgram->GetUniformLoc("isTextured"); m_pPrimitiveProgram->m_LocTextureSampler = m_pPrimitiveProgram->GetUniformLoc("textureSampler"); @@ -691,14 +691,14 @@ CGLSL FragmentShader; VertexShader.LoadShader(pCommand->m_pStorage, "shader/tile.vert", GL_VERTEX_SHADER); FragmentShader.LoadShader(pCommand->m_pStorage, "shader/tile.frag", GL_FRAGMENT_SHADER); - + m_pTileProgram->CreateProgram(); m_pTileProgram->AddShader(&VertexShader); m_pTileProgram->AddShader(&FragmentShader); m_pTileProgram->LinkProgram(); - + UseProgram(m_pTileProgram); - + m_pTileProgram->m_LocPos = m_pTileProgram->GetUniformLoc("Pos"); m_pTileProgram->m_LocIsTextured = -1; m_pTileProgram->m_LocTextureSampler = -1; @@ -712,14 +712,14 @@ CGLSL FragmentShader; VertexShader.LoadShader(pCommand->m_pStorage, "shader/tiletex.vert", GL_VERTEX_SHADER); FragmentShader.LoadShader(pCommand->m_pStorage, "shader/tiletex.frag", GL_FRAGMENT_SHADER); - + m_pTileProgramTextured->CreateProgram(); m_pTileProgramTextured->AddShader(&VertexShader); m_pTileProgramTextured->AddShader(&FragmentShader); m_pTileProgramTextured->LinkProgram(); - + UseProgram(m_pTileProgramTextured); - + m_pTileProgramTextured->m_LocPos = m_pTileProgramTextured->GetUniformLoc("Pos"); m_pTileProgramTextured->m_LocIsTextured = -1; m_pTileProgramTextured->m_LocTextureSampler = m_pTileProgramTextured->GetUniformLoc("textureSampler"); @@ -733,14 +733,14 @@ CGLSL FragmentShader; VertexShader.LoadShader(pCommand->m_pStorage, "shader/bordertile.vert", GL_VERTEX_SHADER); FragmentShader.LoadShader(pCommand->m_pStorage, "shader/bordertile.frag", GL_FRAGMENT_SHADER); - + m_pBorderTileProgram->CreateProgram(); m_pBorderTileProgram->AddShader(&VertexShader); m_pBorderTileProgram->AddShader(&FragmentShader); m_pBorderTileProgram->LinkProgram(); - + UseProgram(m_pBorderTileProgram); - + m_pBorderTileProgram->m_LocPos = m_pBorderTileProgram->GetUniformLoc("Pos"); m_pBorderTileProgram->m_LocIsTextured = -1; m_pBorderTileProgram->m_LocTextureSampler = -1; @@ -762,9 +762,9 @@ m_pBorderTileProgramTextured->AddShader(&VertexShader); m_pBorderTileProgramTextured->AddShader(&FragmentShader); m_pBorderTileProgramTextured->LinkProgram(); - + UseProgram(m_pBorderTileProgramTextured); - + m_pBorderTileProgramTextured->m_LocPos = m_pBorderTileProgramTextured->GetUniformLoc("Pos"); m_pBorderTileProgramTextured->m_LocIsTextured = -1; m_pBorderTileProgramTextured->m_LocTextureSampler = m_pBorderTileProgramTextured->GetUniformLoc("textureSampler"); @@ -781,14 +781,14 @@ CGLSL FragmentShader; VertexShader.LoadShader(pCommand->m_pStorage, "shader/bordertileline.vert", GL_VERTEX_SHADER); FragmentShader.LoadShader(pCommand->m_pStorage, "shader/bordertileline.frag", GL_FRAGMENT_SHADER); - + m_pBorderTileLineProgram->CreateProgram(); m_pBorderTileLineProgram->AddShader(&VertexShader); m_pBorderTileLineProgram->AddShader(&FragmentShader); m_pBorderTileLineProgram->LinkProgram(); - + UseProgram(m_pBorderTileLineProgram); - + m_pBorderTileLineProgram->m_LocPos = m_pBorderTileLineProgram->GetUniformLoc("Pos"); m_pBorderTileLineProgram->m_LocIsTextured = -1; m_pBorderTileLineProgram->m_LocTextureSampler = -1; @@ -936,7 +936,7 @@ glGenVertexArrays(MAX_STREAM_BUFFER_COUNT, m_PrimitiveDrawVertexID); m_UsePreinitializedVertexBuffer = g_Config.m_GfxUsePreinitBuffer; - + for(int i = 0; i < MAX_STREAM_BUFFER_COUNT; ++i) { glBindBuffer(GL_ARRAY_BUFFER, m_PrimitiveDrawBufferID[i]); @@ -954,7 +954,7 @@ m_LastIndexBufferBound[i] = 0; } - + //query the image max size only once glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_MaxTexSize); @@ -969,7 +969,7 @@ glBindVertexArray(0); glGenBuffers(1, &m_QuadDrawIndexBufferID); glBindBuffer(GL_COPY_WRITE_BUFFER, m_QuadDrawIndexBufferID); - + unsigned int Indices[CCommandBuffer::MAX_VERTICES/4 * 6]; int Primq = 0; for(int i = 0; i < CCommandBuffer::MAX_VERTICES/4 * 6; i+=6) @@ -983,20 +983,20 @@ Primq+=4; } glBufferData(GL_COPY_WRITE_BUFFER, sizeof(unsigned int) * CCommandBuffer::MAX_VERTICES/4 * 6, Indices, GL_STATIC_DRAW); - + m_CurrentIndicesInBuffer = CCommandBuffer::MAX_VERTICES/4 * 6; - + mem_zero(m_aTextures, sizeof(m_aTextures)); - + m_ClearColor.r = m_ClearColor.g = m_ClearColor.b = -1.f; - + // fix the alignment to allow even 1byte changes, e.g. for alpha components glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } void CCommandProcessorFragment_OpenGL3_3::Cmd_Shutdown(const SCommand_Shutdown *pCommand) { - //clean up everything + //clean up everything delete m_pPrimitiveProgram; //delete m_QuadProgram; delete m_pTileProgram; @@ -1010,18 +1010,18 @@ glDeleteBuffers(MAX_STREAM_BUFFER_COUNT, m_PrimitiveDrawBufferID); glDeleteBuffers(1, &m_QuadDrawIndexBufferID); glDeleteVertexArrays(MAX_STREAM_BUFFER_COUNT, m_PrimitiveDrawVertexID); - + for(int i = 0; i < CCommandBuffer::MAX_TEXTURES; ++i) { DestroyTexture(i); } - + for(size_t i = 0; i < m_BufferContainers.size(); ++i) { DestroyBufferContainer(i); } - m_BufferContainers.clear(); + m_BufferContainers.clear(); } void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand) @@ -1054,13 +1054,13 @@ } void *pTmpData = Rescale(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast(pCommand->m_pData)); - mem_free(pTexData); + free(pTexData); pTexData = pTmpData; } glTexSubImage2D(GL_TEXTURE_2D, 0, X, Y, Width, Height, TexFormatToOpenGLFormat(pCommand->m_Format), GL_UNSIGNED_BYTE, pTexData); - mem_free(pTexData); + free(pTexData); } void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand) @@ -1099,7 +1099,7 @@ while(Width > m_MaxTexSize || Height > m_MaxTexSize); void *pTmpData = Rescale(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast(pCommand->m_pData)); - mem_free(pTexData); + free(pTexData); pTexData = pTmpData; } else if(pCommand->m_Format != CCommandBuffer::TEXFORMAT_ALPHA && (Width > 16 && Height > 16 && (pCommand->m_Flags&CCommandBuffer::TEXFLAG_QUALITY) == 0)) @@ -1109,7 +1109,7 @@ ++RescaleCount; void *pTmpData = Rescale(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast(pCommand->m_pData)); - mem_free(pTexData); + free(pTexData); pTexData = pTmpData; } } @@ -1148,7 +1148,7 @@ glGenSamplers(1, &m_aTextures[pCommand->m_Slot].m_Sampler); glBindSampler(Slot, m_aTextures[pCommand->m_Slot].m_Sampler); - + if(Oglformat == GL_RED) { //Bind the texture 2D. @@ -1156,7 +1156,7 @@ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); StoreOglformat = GL_R8; } - + if(pCommand->m_Flags&CCommandBuffer::TEXFLAG_NOMIPMAPS) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -1178,7 +1178,7 @@ glTexImage2D(GL_TEXTURE_2D, 0, StoreOglformat, Width, Height, 0, Oglformat, GL_UNSIGNED_BYTE, pTexData); glGenerateMipmap(GL_TEXTURE_2D); } - + // This is the initial value for the wrap modes m_aTextures[pCommand->m_Slot].m_LastWrapMode = CCommandBuffer::WRAP_REPEAT; @@ -1191,8 +1191,8 @@ m_aTextures[pCommand->m_Slot].m_MemSize += Width*Height*pCommand->m_PixelSize; } *m_pTextureMemoryUsage += m_aTextures[pCommand->m_Slot].m_MemSize; - - mem_free(pTexData); + + free(pTexData); } void CCommandProcessorFragment_OpenGL3_3::Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand) @@ -1239,7 +1239,7 @@ { UseProgram(m_pPrimitiveProgram); SetState(pCommand->m_State, m_pPrimitiveProgram); - + UploadStreamBufferData(pCommand->m_PrimType, pCommand->m_pVertices, pCommand->m_PrimCount); glBindVertexArray(m_PrimitiveDrawVertexID[m_LastStreamBuffer]); @@ -1275,7 +1275,7 @@ int h = aViewport[3]; // we allocate one more row to use when we are flipping the texture - unsigned char *pPixelData = (unsigned char *)mem_alloc(w*(h+1)*3, 1); + unsigned char *pPixelData = (unsigned char *)malloc(w*(h+1)*3); unsigned char *pTempRow = pPixelData+w*h*3; // fetch the pixels @@ -1361,7 +1361,7 @@ glDeleteTextures(1, &m_aTextures[Slot].m_Tex); glDeleteSamplers(1, &m_aTextures[Slot].m_Sampler); *m_pTextureMemoryUsage -= m_aTextures[Slot].m_MemSize; - + m_aTextures[Slot].m_Tex = 0; m_aTextures[Slot].m_Sampler = 0; } @@ -1392,7 +1392,7 @@ } } } - + BufferContainer.m_LastIndexBufferBound = 0; BufferContainer.m_ContainerInfo.m_Attributes.clear(); } @@ -1413,7 +1413,7 @@ Indices[i+5] = Primq + 3; Primq+=4; } - + glBindBuffer(GL_COPY_READ_BUFFER, m_QuadDrawIndexBufferID); GLuint NewIndexBufferID; glGenBuffers(1, &NewIndexBufferID); @@ -1424,8 +1424,8 @@ glBufferSubData(GL_COPY_WRITE_BUFFER, (GLsizeiptr)m_CurrentIndicesInBuffer * size, (GLsizeiptr)AddCount * size, Indices); glBindBuffer(GL_COPY_WRITE_BUFFER, 0); glBindBuffer(GL_COPY_READ_BUFFER, 0); - - glDeleteBuffers(1, &m_QuadDrawIndexBufferID); + + glDeleteBuffers(1, &m_QuadDrawIndexBufferID); m_QuadDrawIndexBufferID = NewIndexBufferID; for(int i = 0; i < MAX_STREAM_BUFFER_COUNT; ++i) @@ -1436,7 +1436,7 @@ } m_CurrentIndicesInBuffer = NewIndicesCount; - delete[] Indices; + delete[] Indices; } void CCommandProcessorFragment_OpenGL3_3::Cmd_CreateBufferObject(const CCommandBuffer::SCommand_CreateBufferObject *pCommand) @@ -1785,7 +1785,7 @@ { return; //nothing to draw } - + UseProgram(m_pTextProgram); int SlotText = 0; @@ -1822,7 +1822,7 @@ glBindSampler(SlotTextOutline, m_aTextures[TextOutlineTextureIndex].m_Sampler); glActiveTexture(GL_TEXTURE0); } - + if(m_pTextProgram->m_LastTextSampler != SlotText) { m_pTextProgram->SetUniform(m_pTextProgram->m_LocTextSampler, (int)SlotText); @@ -1894,8 +1894,8 @@ } UploadStreamBufferData(CCommandBuffer::PRIMTYPE_QUADS, pCommand->m_pVertices, pCommand->m_QuadNum); - - glBindVertexArray(m_PrimitiveDrawVertexID[m_LastStreamBuffer]); + + glBindVertexArray(m_PrimitiveDrawVertexID[m_LastStreamBuffer]); if(m_LastIndexBufferBound[m_LastStreamBuffer] != m_QuadDrawIndexBufferID) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID); @@ -2021,7 +2021,7 @@ m_pSpriteProgramMultiple->m_LastCenter[0] = pCommand->m_Center.x; m_pSpriteProgramMultiple->m_LastCenter[1] = pCommand->m_Center.y; } - + if(m_pSpriteProgramMultiple->m_LastVertciesColor[0] != pCommand->m_VertexColor.r || m_pSpriteProgramMultiple->m_LastVertciesColor[1] != pCommand->m_VertexColor.g || m_pSpriteProgramMultiple->m_LastVertciesColor[2] != pCommand->m_VertexColor.b || m_pSpriteProgramMultiple->m_LastVertciesColor[3] != pCommand->m_VertexColor.a) { m_pSpriteProgramMultiple->SetUniformVec4(m_pSpriteProgramMultiple->m_LocVertciesColor, 1, (float*)&pCommand->m_VertexColor); @@ -2033,7 +2033,7 @@ int DrawCount = pCommand->m_DrawCount; size_t RenderOffset = 0; - + // 4 for the center (always use vec4) and 16 for the matrix(just to be sure), 4 for the sampler and vertex color const int RSPCount = 256 - 4 - 16 - 8; @@ -2165,7 +2165,7 @@ const CCommandBuffer::SCommand *pBaseCommand = pBuffer->GetCommand(&CmdIndex); if(pBaseCommand == 0x0) break; - + if(m_UseOpenGL3_3) { if(m_OpenGL3_3.RunCommand(pBaseCommand)) @@ -2189,7 +2189,7 @@ // ------------ CGraphicsBackend_SDL_OpenGL int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidth, int *pHeight, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight, int *pCurrentWidth, int *pCurrentHeight, IStorage *pStorage) -{ +{ if(!SDL_WasInit(SDL_INIT_VIDEO)) { if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) @@ -2206,61 +2206,64 @@ SDL_ClearError(); const char *pErr = NULL; - + //query default values, since they are platform dependend static bool s_InitDefaultParams = false; static int s_SDLGLContextProfileMask, s_SDLGLContextMajorVersion, s_SDLGLContextMinorVersion; - if(!s_InitDefaultParams) - { - SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &s_SDLGLContextProfileMask); - SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &s_SDLGLContextMajorVersion); - SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &s_SDLGLContextMinorVersion); - s_InitDefaultParams = true; - } - m_UseOpenGL3_3 = false; - if(g_Config.m_GfxOpenGL3 && SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE) == 0) + if(g_Config.m_GfxOpenGL3) { - pErr = SDL_GetError(); - if(pErr[0] != '\0') + if(!s_InitDefaultParams) { - dbg_msg("gfx", "Using old OpenGL context, because an error occurred while trying to use OpenGL context 3.3: %s.", pErr); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, s_SDLGLContextProfileMask); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &s_SDLGLContextProfileMask); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &s_SDLGLContextMajorVersion); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &s_SDLGLContextMinorVersion); + s_InitDefaultParams = true; } - else - { - if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) == 0 && SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3) == 0) - { - pErr = SDL_GetError(); - if(pErr[0] != '\0') - { - dbg_msg("gfx", "Using old OpenGL context, because an error occurred while trying to use OpenGL context 3.3: %s.", pErr); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, s_SDLGLContextMajorVersion); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, s_SDLGLContextMinorVersion); + + if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE) == 0) + { + pErr = SDL_GetError(); + if(pErr[0] != '\0') + { + dbg_msg("gfx", "Using old OpenGL context, because an error occurred while trying to use OpenGL context 3.3: %s.", pErr); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, s_SDLGLContextProfileMask); + } + else + { + if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) == 0 && SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3) == 0) + { + pErr = SDL_GetError(); + if(pErr[0] != '\0') + { + dbg_msg("gfx", "Using old OpenGL context, because an error occurred while trying to use OpenGL context 3.3: %s.", pErr); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, s_SDLGLContextMajorVersion); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, s_SDLGLContextMinorVersion); + } + else + { + m_UseOpenGL3_3 = true; + int vMaj, vMin; + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &vMaj); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &vMin); + dbg_msg("gfx", "Using OpenGL version %d.%d.", vMaj, vMin); + } } - else + else { - m_UseOpenGL3_3 = true; - int vMaj, vMin; - SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &vMaj); - SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &vMin); - dbg_msg("gfx", "Using OpenGL version %d.%d.", vMaj, vMin); + dbg_msg("gfx", "Couldn't create OpenGL 3.3 context."); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, s_SDLGLContextMajorVersion); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, s_SDLGLContextMinorVersion); } } - else - { - dbg_msg("gfx", "Couldn't create OpenGL 3.3 context."); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, s_SDLGLContextMajorVersion); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, s_SDLGLContextMinorVersion); - } } - } - else - { - //set default attributes - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, s_SDLGLContextProfileMask); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, s_SDLGLContextMajorVersion); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, s_SDLGLContextMinorVersion); + else + { + //set default attributes + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, s_SDLGLContextProfileMask); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, s_SDLGLContextMajorVersion); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, s_SDLGLContextMinorVersion); + } } // set screen @@ -2379,10 +2382,13 @@ return -1; } - //support graphic cards that are pretty old(and linux) - glewExperimental = GL_TRUE; - if(GLEW_OK != glewInit()) - return -1; + if(m_UseOpenGL3_3) + { + //support graphic cards that are pretty old(and linux) + glewExperimental = GL_TRUE; + if(GLEW_OK != glewInit()) + return -1; + } SDL_GL_GetDrawableSize(m_pWindow, pWidth, pHeight); SDL_GL_SetSwapInterval(Flags&IGraphicsBackend::INITFLAG_VSYNC ? 1 : 0); @@ -2445,7 +2451,7 @@ //int YOverflow = (*pHeight > *pCurrentHeight ? (*pHeight - *pCurrentHeight) : 0); //TODO: current problem is, that the opengl driver knows about the scaled display, //so the viewport cannot be adjusted for resolutions, that are higher than allowed by the display driver - + CCommandProcessorFragment_SDL::SCommand_Update_Viewport CmdSDL; CmdSDL.m_X = 0; CmdSDL.m_Y = 0; @@ -2454,7 +2460,7 @@ CmdSDL.m_Height = CurrentDisplayMode.h; CmdBuffer.AddCommand(CmdSDL); RunBuffer(&CmdBuffer); - WaitForIdle(); + WaitForIdle(); } } @@ -2467,10 +2473,10 @@ // issue a shutdown command CCommandBuffer CmdBuffer(1024, 512); if(m_UseOpenGL3_3) - { + { CCommandProcessorFragment_OpenGL3_3::SCommand_Shutdown Cmd; CmdBuffer.AddCommand(Cmd); - } + } CCommandProcessorFragment_SDL::SCommand_Shutdown Cmd; CmdBuffer.AddCommand(Cmd); RunBuffer(&CmdBuffer); diff -Nru ddnet-11.1.3/src/engine/client/client.cpp ddnet-11.1.8/src/engine/client/client.cpp --- ddnet-11.1.3/src/engine/client/client.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/client/client.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -942,10 +942,8 @@ total = 42 */ FrameTimeAvg = FrameTimeAvg*0.9f + m_RenderFrameTime*0.1f; - str_format(aBuffer, sizeof(aBuffer), "ticks: %8d %8d mem %dk %d gfxmem: %dk fps: %3d", + str_format(aBuffer, sizeof(aBuffer), "ticks: %8d %8d gfxmem: %dk fps: %3d", m_CurGameTick[g_Config.m_ClDummy], m_PredTick[g_Config.m_ClDummy], - mem_stats()->allocated/1024, - mem_stats()->total_allocations, Graphics()->MemoryUsage()/1024, (int)(1.0f/FrameTimeAvg + 0.5f)); Graphics()->QuadsText(2, 2, 16, aBuffer); @@ -3439,7 +3437,7 @@ static CClient *CreateClient() { - CClient *pClient = static_cast(mem_alloc(sizeof(CClient), 1)); + CClient *pClient = static_cast(malloc(sizeof(*pClient))); mem_zero(pClient, sizeof(CClient)); return new(pClient) CClient; } @@ -3536,7 +3534,7 @@ { delete pKernel; pClient->~CClient(); - mem_free(pClient); + free(pClient); return -1; } } @@ -3612,7 +3610,7 @@ delete pKernel; pClient->~CClient(); - mem_free(pClient); + free(pClient); return 0; } diff -Nru ddnet-11.1.3/src/engine/client/graphics_threaded.cpp ddnet-11.1.8/src/engine/client/graphics_threaded.cpp --- ddnet-11.1.3/src/engine/client/graphics_threaded.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/client/graphics_threaded.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -391,7 +391,7 @@ int MemSize = Width*Height*ImageFormatToPixelSize(Format); // copy texture data - void *pTmpData = mem_alloc(MemSize, sizeof(void*)); + void *pTmpData = malloc(MemSize); mem_copy(pTmpData, pData, MemSize); Cmd.m_pData = pTmpData; @@ -437,7 +437,7 @@ // copy texture data int MemSize = Width*Height*Cmd.m_PixelSize; - void *pTmpData = mem_alloc(MemSize, sizeof(void*)); + void *pTmpData = malloc(MemSize); mem_copy(pTmpData, pData, MemSize); Cmd.m_pData = pTmpData; @@ -467,7 +467,7 @@ StoreFormat = Img.m_Format; ID = LoadTextureRaw(Img.m_Width, Img.m_Height, Img.m_Format, Img.m_pData, StoreFormat, Flags); - mem_free(Img.m_pData); + free(Img.m_pData); if(ID != m_InvalidTexture && g_Config.m_Debug) dbg_msg("graphics/texture", "loaded %s", pFilename); return ID; @@ -510,7 +510,7 @@ return 0; } - pBuffer = (unsigned char *)mem_alloc(Png.width * Png.height * Png.bpp, 1); // ignore_convention + pBuffer = (unsigned char *)malloc(Png.width * Png.height * Png.bpp); // ignore_convention png_get_data(&Png, pBuffer); // ignore_convention png_close_file(&Png); // ignore_convention @@ -566,7 +566,7 @@ png_set_data(&Png, Image.m_Width, Image.m_Height, 8, PNG_TRUECOLOR, (unsigned char *)Image.m_pData); // ignore_convention png_close_file(&Png); // ignore_convention - mem_free(Image.m_pData); + free(Image.m_pData); } } @@ -1209,6 +1209,60 @@ return Index; } +void CGraphics_Threaded::QuadContainerUpload(int ContainerIndex) +{ + if(m_UseOpenGL3_3) + { + SQuadContainer& Container = m_QuadContainers[ContainerIndex]; + if(Container.m_Quads.size() > 0) + { + if(Container.m_QuadBufferObjectIndex == -1) + { + size_t UploadDataSize = Container.m_Quads.size() * sizeof(SQuadContainer::SQuad); + Container.m_QuadBufferObjectIndex = CreateBufferObject(UploadDataSize, &Container.m_Quads[0]); + } + else + { + size_t UploadDataSize = Container.m_Quads.size() * sizeof(SQuadContainer::SQuad); + RecreateBufferObject(Container.m_QuadBufferObjectIndex, UploadDataSize, &Container.m_Quads[0]); + } + + if(Container.m_QuadBufferContainerIndex == -1) + { + SBufferContainerInfo Info; + Info.m_Stride = sizeof(CCommandBuffer::SVertex); + + Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute()); + SBufferContainerInfo::SAttribute* pAttr = &Info.m_Attributes.back(); + pAttr->m_DataTypeCount = 2; + pAttr->m_FuncType = 0; + pAttr->m_Normalized = false; + pAttr->m_pOffset = 0; + pAttr->m_Type = GRAPHICS_TYPE_FLOAT; + pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex; + Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute()); + pAttr = &Info.m_Attributes.back(); + pAttr->m_DataTypeCount = 2; + pAttr->m_FuncType = 0; + pAttr->m_Normalized = false; + pAttr->m_pOffset = (void*)(sizeof(float) * 2); + pAttr->m_Type = GRAPHICS_TYPE_FLOAT; + pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex; + Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute()); + pAttr = &Info.m_Attributes.back(); + pAttr->m_DataTypeCount = 4; + pAttr->m_FuncType = 0; + pAttr->m_Normalized = true; + pAttr->m_pOffset = (void*)(sizeof(float) * 2 + sizeof(float) * 2); + pAttr->m_Type = GRAPHICS_TYPE_UNSIGNED_BYTE; + pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex; + + Container.m_QuadBufferContainerIndex = CreateBufferContainer(&Info); + } + } + } +} + void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num) { SQuadContainer& Container = m_QuadContainers[ContainerIndex]; @@ -1251,52 +1305,7 @@ } } - if(Container.m_Quads.size() > 0) - { - if(Container.m_QuadBufferObjectIndex == -1) - { - size_t UploadDataSize = Container.m_Quads.size() * sizeof(SQuadContainer::SQuad); - Container.m_QuadBufferObjectIndex = CreateBufferObject(UploadDataSize, &Container.m_Quads[0]); - } - else - { - size_t UploadDataSize = Container.m_Quads.size() * sizeof(SQuadContainer::SQuad); - RecreateBufferObject(Container.m_QuadBufferObjectIndex, UploadDataSize, &Container.m_Quads[0]); - } - - if(Container.m_QuadBufferContainerIndex == -1) - { - SBufferContainerInfo Info; - Info.m_Stride = sizeof(CCommandBuffer::SVertex); - - Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute()); - SBufferContainerInfo::SAttribute* pAttr = &Info.m_Attributes.back(); - pAttr->m_DataTypeCount = 2; - pAttr->m_FuncType = 0; - pAttr->m_Normalized = false; - pAttr->m_pOffset = 0; - pAttr->m_Type = GRAPHICS_TYPE_FLOAT; - pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex; - Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute()); - pAttr = &Info.m_Attributes.back(); - pAttr->m_DataTypeCount = 2; - pAttr->m_FuncType = 0; - pAttr->m_Normalized = false; - pAttr->m_pOffset = (void*)(sizeof(float) * 2); - pAttr->m_Type = GRAPHICS_TYPE_FLOAT; - pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex; - Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute()); - pAttr = &Info.m_Attributes.back(); - pAttr->m_DataTypeCount = 4; - pAttr->m_FuncType = 0; - pAttr->m_Normalized = true; - pAttr->m_pOffset = (void*)(sizeof(float) * 2 + sizeof(float) * 2); - pAttr->m_Type = GRAPHICS_TYPE_UNSIGNED_BYTE; - pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex; - - Container.m_QuadBufferContainerIndex = CreateBufferContainer(&Info); - } - } + QuadContainerUpload(ContainerIndex); } void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num) @@ -1332,59 +1341,17 @@ SetColor(&Quad.m_aVertices[3], 2); } - if(Container.m_Quads.size() > 0) - { - if(Container.m_QuadBufferObjectIndex == -1) - { - size_t UploadDataSize = Container.m_Quads.size() * sizeof(SQuadContainer::SQuad); - Container.m_QuadBufferObjectIndex = CreateBufferObject(UploadDataSize, &Container.m_Quads[0]); - } - else - { - size_t UploadDataSize = Container.m_Quads.size() * sizeof(SQuadContainer::SQuad); - RecreateBufferObject(Container.m_QuadBufferObjectIndex, UploadDataSize, &Container.m_Quads[0]); - } - - if(Container.m_QuadBufferContainerIndex == -1) - { - SBufferContainerInfo Info; - Info.m_Stride = sizeof(CCommandBuffer::SVertex); - - Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute()); - SBufferContainerInfo::SAttribute* pAttr = &Info.m_Attributes.back(); - pAttr->m_DataTypeCount = 2; - pAttr->m_FuncType = 0; - pAttr->m_Normalized = false; - pAttr->m_pOffset = 0; - pAttr->m_Type = GRAPHICS_TYPE_FLOAT; - pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex; - Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute()); - pAttr = &Info.m_Attributes.back(); - pAttr->m_DataTypeCount = 2; - pAttr->m_FuncType = 0; - pAttr->m_Normalized = false; - pAttr->m_pOffset = (void*)(sizeof(float) * 2); - pAttr->m_Type = GRAPHICS_TYPE_FLOAT; - pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex; - Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute()); - pAttr = &Info.m_Attributes.back(); - pAttr->m_DataTypeCount = 4; - pAttr->m_FuncType = 0; - pAttr->m_Normalized = true; - pAttr->m_pOffset = (void*)(sizeof(float) * 2 + sizeof(float) * 2); - pAttr->m_Type = GRAPHICS_TYPE_UNSIGNED_BYTE; - pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex; - - Container.m_QuadBufferContainerIndex = CreateBufferContainer(&Info); - } - } + QuadContainerUpload(ContainerIndex); } void CGraphics_Threaded::QuadContainerReset(int ContainerIndex) { SQuadContainer& Container = m_QuadContainers[ContainerIndex]; - if(Container.m_QuadBufferContainerIndex != -1) - DeleteBufferContainer(Container.m_QuadBufferContainerIndex, true); + if(m_UseOpenGL3_3) + { + if(Container.m_QuadBufferContainerIndex != -1) + DeleteBufferContainer(Container.m_QuadBufferContainerIndex, true); + } Container.m_Quads.clear(); Container.m_QuadBufferContainerIndex = Container.m_QuadBufferObjectIndex = -1; } @@ -1412,12 +1379,12 @@ if((int)Container.m_Quads.size() < QuadOffset + QuadDrawNum || QuadDrawNum == 0) return; - - if(Container.m_QuadBufferContainerIndex == -1) - return; - + if(m_UseOpenGL3_3) { + if(Container.m_QuadBufferContainerIndex == -1) + return; + CCommandBuffer::SCommand_RenderQuadContainer Cmd; Cmd.m_State = m_State; Cmd.m_DrawNum = (unsigned int)QuadDrawNum * 6; @@ -1471,11 +1438,11 @@ if((int)Container.m_Quads.size() < QuadOffset + 1) return; - if(Container.m_QuadBufferContainerIndex == -1) - return; - if(m_UseOpenGL3_3) { + if(Container.m_QuadBufferContainerIndex == -1) + return; + SQuadContainer::SQuad& Quad = Container.m_Quads[QuadOffset]; CCommandBuffer::SCommand_RenderQuadContainerAsSprite Cmd; @@ -1597,11 +1564,11 @@ if(DrawCount == 0) return; - if(Container.m_QuadBufferContainerIndex == -1) - return; - if(m_UseOpenGL3_3) { + if(Container.m_QuadBufferContainerIndex == -1) + return; + SQuadContainer::SQuad& Quad = Container.m_Quads[0]; CCommandBuffer::SCommand_RenderQuadContainerAsSpriteMultiple Cmd; diff -Nru ddnet-11.1.3/src/engine/client/graphics_threaded.h ddnet-11.1.8/src/engine/client/graphics_threaded.h --- ddnet-11.1.3/src/engine/client/graphics_threaded.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/client/graphics_threaded.h 2018-05-13 20:23:11.000000000 +0000 @@ -756,6 +756,7 @@ virtual void QuadsText(float x, float y, float Size, const char *pText); virtual int CreateQuadContainer(); + virtual void QuadContainerUpload(int ContainerIndex); virtual void QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num); virtual void QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num); virtual void QuadContainerReset(int ContainerIndex); diff -Nru ddnet-11.1.3/src/engine/client/serverbrowser.cpp ddnet-11.1.8/src/engine/client/serverbrowser.cpp --- ddnet-11.1.3/src/engine/client/serverbrowser.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/client/serverbrowser.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -166,9 +166,9 @@ if(m_NumSortedServersCapacity < m_NumServers) { if(m_pSortedServerlist) - mem_free(m_pSortedServerlist); + free(m_pSortedServerlist); m_NumSortedServersCapacity = m_NumServers; - m_pSortedServerlist = (int *)mem_alloc(m_NumSortedServersCapacity*sizeof(int), 1); + m_pSortedServerlist = (int *)calloc(m_NumSortedServersCapacity, sizeof(int)); } // filter the servers @@ -467,9 +467,9 @@ { CServerEntry **ppNewlist; m_NumServerCapacity += 100; - ppNewlist = (CServerEntry **)mem_alloc(m_NumServerCapacity*sizeof(CServerEntry*), 1); + ppNewlist = (CServerEntry **)calloc(m_NumServerCapacity, sizeof(CServerEntry *)); mem_copy(ppNewlist, m_ppServerlist, m_NumServers*sizeof(CServerEntry*)); - mem_free(m_ppServerlist); + free(m_ppServerlist); m_ppServerlist = ppNewlist; } @@ -1093,7 +1093,7 @@ return; } - char *pBuf = (char *)mem_alloc(Length, 1); + char *pBuf = (char *)malloc(Length); pBuf[0] = '\0'; io_read(File, pBuf, Length); @@ -1104,7 +1104,7 @@ m_pDDNetInfo = json_parse(pBuf, Length); - mem_free(pBuf); + free(pBuf); if(m_pDDNetInfo && m_pDDNetInfo->type != json_object) { diff -Nru ddnet-11.1.3/src/engine/client/sound.cpp ddnet-11.1.8/src/engine/client/sound.cpp --- ddnet-11.1.3/src/engine/client/sound.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/client/sound.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -322,7 +322,7 @@ dbg_msg("client/sound", "sound init successful"); m_MaxFrames = FormatOut.samples*2; - m_pMixBuffer = (int *)mem_alloc(m_MaxFrames*2*sizeof(int), 1); + m_pMixBuffer = (int *)calloc(m_MaxFrames * 2, sizeof(int)); SDL_PauseAudioDevice(m_Device, 0); @@ -359,7 +359,7 @@ SDL_CloseAudioDevice(m_Device); SDL_QuitSubSystem(SDL_INIT_AUDIO); lock_destroy(m_SoundLock); - mem_free(m_pMixBuffer); + free(m_pMixBuffer); m_pMixBuffer = 0; return 0; } @@ -388,7 +388,7 @@ // allocate new data NumFrames = (int)((pSample->m_NumFrames/(float)pSample->m_Rate)*m_MixingRate); - pNewData = (short *)mem_alloc(NumFrames*pSample->m_Channels*sizeof(short), 1); + pNewData = (short *)calloc(NumFrames * pSample->m_Channels, sizeof(short)); for(int i = 0; i < NumFrames; i++) { @@ -409,7 +409,7 @@ } // free old data and apply new - mem_free(pSample->m_pData); + free(pSample->m_pData); pSample->m_pData = pNewData; pSample->m_NumFrames = NumFrames; pSample->m_Rate = m_MixingRate; @@ -436,7 +436,7 @@ return -1; } - pSample->m_pData = (short *)mem_alloc(NumSamples * sizeof(short) * NumChannels, 1); + pSample->m_pData = (short *)calloc(NumSamples * NumChannels, sizeof(short)); int Read; int Pos = 0; @@ -550,17 +550,17 @@ return -1; } - int *pBuffer = (int *)mem_alloc(4*NumSamples*NumChannels, 1); + int *pBuffer = (int *)calloc(NumSamples * NumChannels, sizeof(int)); WavpackUnpackSamples(pContext, pBuffer, NumSamples); // TODO: check return value pSrc = pBuffer; - pSample->m_pData = (short *)mem_alloc(2*NumSamples*NumChannels, 1); + pSample->m_pData = (short *)calloc(NumSamples * NumChannels, sizeof(short)); pDst = pSample->m_pData; for (i = 0; i < NumSamples*NumChannels; i++) *pDst++ = (short)*pSrc++; - mem_free(pBuffer); + free(pBuffer); pSample->m_NumFrames = NumSamples; pSample->m_LoopStart = -1; @@ -731,7 +731,7 @@ return; Stop(SampleID); - mem_free(m_aSamples[SampleID].m_pData); + free(m_aSamples[SampleID].m_pData); m_aSamples[SampleID].m_pData = 0x0; } diff -Nru ddnet-11.1.3/src/engine/client/text.cpp ddnet-11.1.8/src/engine/client/text.cpp --- ddnet-11.1.3/src/engine/client/text.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/client/text.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -103,7 +103,7 @@ int m_aTextures[2]; // keep the full texture, because opengl doesn't provide texture copying - unsigned char* m_TextureData[2]; + unsigned char *m_TextureData[2]; // width and height are the same int m_CurTextureDimensions[2]; @@ -282,21 +282,22 @@ } } - int InitTexture(int Width, int Height, void* pUploadData = NULL) + int InitTexture(int Width, int Height, void *pUploadData = NULL) { void *pMem = NULL; if(pUploadData) + { pMem = pUploadData; + } else { - pMem = mem_alloc(Width*Height, 1); - mem_zero(pMem, Width*Height); + pMem = calloc(Width * Height, 1); } int TextureID = Graphics()->LoadTextureRaw(Width, Height, CImageInfo::FORMAT_ALPHA, pMem, CImageInfo::FORMAT_ALPHA, IGraphics::TEXLOAD_NOMIPMAPS); if(!pUploadData) - mem_free(pMem); + free(pMem); return TextureID; } @@ -310,7 +311,7 @@ { int NewDimensions = pFont->m_CurTextureDimensions[TextureIndex] * 2; - unsigned char* pTmpTexBuffer = new unsigned char[NewDimensions*NewDimensions]; + unsigned char *pTmpTexBuffer = new unsigned char[NewDimensions*NewDimensions]; mem_zero(pTmpTexBuffer, NewDimensions * NewDimensions * sizeof(unsigned char)); for(int y = 0; y < pFont->m_CurTextureDimensions[TextureIndex]; ++y) @@ -1554,22 +1555,19 @@ { STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[i]; - if(pTextOutlineColor->m_A != 0) - Graphics()->SetColor(TextCharQuad.m_Vertices[0].m_Color.m_R / 255.f * pTextOutlineColor->m_R, TextCharQuad.m_Vertices[0].m_Color.m_G / 255.f * pTextOutlineColor->m_G, TextCharQuad.m_Vertices[0].m_Color.m_B / 255.f * pTextOutlineColor->m_B, TextCharQuad.m_Vertices[0].m_Color.m_A / 255.f * pTextOutlineColor->m_A); - else - Graphics()->SetColor(TextCharQuad.m_Vertices[0].m_Color.m_R / 255.f, TextCharQuad.m_Vertices[0].m_Color.m_G / 255.f, TextCharQuad.m_Vertices[0].m_Color.m_B / 255.f, TextCharQuad.m_Vertices[0].m_Color.m_A / 255.f); - - + Graphics()->SetColor(TextCharQuad.m_Vertices[0].m_Color.m_R / 255.f * pTextOutlineColor->m_R, TextCharQuad.m_Vertices[0].m_Color.m_G / 255.f * pTextOutlineColor->m_G, TextCharQuad.m_Vertices[0].m_Color.m_B / 255.f * pTextOutlineColor->m_B, TextCharQuad.m_Vertices[0].m_Color.m_A / 255.f * pTextOutlineColor->m_A); + Graphics()->QuadsSetSubset(TextCharQuad.m_Vertices[0].m_U * UVScale, TextCharQuad.m_Vertices[0].m_V * UVScale, TextCharQuad.m_Vertices[2].m_U * UVScale, TextCharQuad.m_Vertices[2].m_V * UVScale); IGraphics::CQuadItem QuadItem(TextCharQuad.m_Vertices[0].m_X, TextCharQuad.m_Vertices[0].m_Y, TextCharQuad.m_Vertices[1].m_X - TextCharQuad.m_Vertices[0].m_X, TextCharQuad.m_Vertices[2].m_Y - TextCharQuad.m_Vertices[0].m_Y); Graphics()->QuadsDrawTL(&QuadItem, 1); } - - Graphics()->QuadsEndKeepVertices(); - - Graphics()->TextureSet(pFont->m_aTextures[0]); + if(pTextColor->m_A != 0) { + Graphics()->QuadsEndKeepVertices(); + + Graphics()->TextureSet(pFont->m_aTextures[0]); + for(size_t i = 0; i < TextContainer.m_StringInfo.m_QuadNum; ++i) { STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[i]; @@ -1579,22 +1577,16 @@ unsigned char CA = (unsigned char)((float)(TextCharQuad.m_Vertices[0].m_Color.m_A) * pTextColor->m_A); Graphics()->ChangeColorOfQuadVertices((int)i, CR, CG, CB, CA); } + + // render non outlined + Graphics()->QuadsDrawCurrentVertices(false); } else - { - for(size_t i = 0; i < TextContainer.m_StringInfo.m_QuadNum; ++i) - { - STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[i]; - unsigned char CR = TextCharQuad.m_Vertices[0].m_Color.m_R; - unsigned char CG = TextCharQuad.m_Vertices[0].m_Color.m_G; - unsigned char CB = TextCharQuad.m_Vertices[0].m_Color.m_B; - unsigned char CA = TextCharQuad.m_Vertices[0].m_Color.m_A; - Graphics()->ChangeColorOfQuadVertices((int)i, CR, CG, CB, CA); - } - } + Graphics()->QuadsEnd(); + - // render non outlined - Graphics()->QuadsDrawCurrentVertices(false); + // reset + Graphics()->SetColor(1.f, 1.f, 1.f, 1.f); } } @@ -1744,9 +1736,14 @@ { // reset the skylines for(int j = 0; j < 2; ++j) + { for(size_t k = 0; k < m_Fonts[i]->m_TextureSkyline[j].m_CurHeightOfPixelColumn.size(); ++k) m_Fonts[i]->m_TextureSkyline[j].m_CurHeightOfPixelColumn[k] = 0; + mem_zero(m_Fonts[i]->m_TextureData[j], m_Fonts[i]->m_CurTextureDimensions[j] * m_Fonts[i]->m_CurTextureDimensions[j] * sizeof(unsigned char)); + Graphics()->LoadTextureRawSub(m_Fonts[i]->m_aTextures[j], 0, 0, m_Fonts[i]->m_CurTextureDimensions[j], m_Fonts[i]->m_CurTextureDimensions[j], CImageInfo::FORMAT_ALPHA, m_Fonts[i]->m_TextureData[j]); + } + m_Fonts[i]->InitFontSizes(); } } diff -Nru ddnet-11.1.3/src/engine/graphics.h ddnet-11.1.8/src/engine/graphics.h --- ddnet-11.1.3/src/engine/graphics.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/graphics.h 2018-05-13 20:23:11.000000000 +0000 @@ -209,6 +209,7 @@ }; virtual int CreateQuadContainer() = 0; + virtual void QuadContainerUpload(int ContainerIndex) = 0; virtual void QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num) = 0; virtual void QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num) = 0; virtual void QuadContainerReset(int ContainerIndex) = 0; diff -Nru ddnet-11.1.3/src/engine/server/server.cpp ddnet-11.1.8/src/engine/server/server.cpp --- ddnet-11.1.3/src/engine/server/server.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/server/server.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -769,24 +769,21 @@ return 0; } -int CServer::NewClientNoAuthCallback(int ClientID, bool Reset, void *pUser) +int CServer::NewClientNoAuthCallback(int ClientID, void *pUser) { CServer *pThis = (CServer *)pUser; pThis->m_aClients[ClientID].m_DnsblState = CClient::DNSBL_STATE_NONE; - if (Reset) - { - pThis->m_aClients[ClientID].m_State = CClient::STATE_CONNECTING; - pThis->m_aClients[ClientID].m_aName[0] = 0; - pThis->m_aClients[ClientID].m_aClan[0] = 0; - pThis->m_aClients[ClientID].m_Country = -1; - pThis->m_aClients[ClientID].m_Authed = AUTHED_NO; - pThis->m_aClients[ClientID].m_AuthKey = -1; - pThis->m_aClients[ClientID].m_AuthTries = 0; - pThis->m_aClients[ClientID].m_pRconCmdToSend = 0; - pThis->m_aClients[ClientID].Reset(); - } + pThis->m_aClients[ClientID].m_State = CClient::STATE_CONNECTING; + pThis->m_aClients[ClientID].m_aName[0] = 0; + pThis->m_aClients[ClientID].m_aClan[0] = 0; + pThis->m_aClients[ClientID].m_Country = -1; + pThis->m_aClients[ClientID].m_Authed = AUTHED_NO; + pThis->m_aClients[ClientID].m_AuthKey = -1; + pThis->m_aClients[ClientID].m_AuthTries = 0; + pThis->m_aClients[ClientID].m_pRconCmdToSend = 0; + pThis->m_aClients[ClientID].Reset(); pThis->SendMap(ClientID); #if defined(CONF_FAMILY_UNIX) @@ -1705,9 +1702,8 @@ { IOHANDLE File = Storage()->OpenFile(aBuf, IOFLAG_READ, IStorage::TYPE_ALL); m_CurrentMapSize = (unsigned int)io_length(File); - if(m_pCurrentMapData) - mem_free(m_pCurrentMapData); - m_pCurrentMapData = (unsigned char *)mem_alloc(m_CurrentMapSize, 1); + free(m_pCurrentMapData); + m_pCurrentMapData = (unsigned char *)malloc(m_CurrentMapSize); io_read(File, m_pCurrentMapData, m_CurrentMapSize); io_close(File); } @@ -1799,12 +1795,6 @@ m_Lastheartbeat = 0; m_GameStartTime = time_get(); - if(g_Config.m_Debug) - { - str_format(aBuf, sizeof(aBuf), "baseline memory usage %dk", mem_stats()->allocated/1024); - Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf); - } - while(m_RunServer) { if(NonActive) @@ -2004,8 +1994,7 @@ GameServer()->OnShutdown(true); m_pMap->Unload(); - if(m_pCurrentMapData) - mem_free(m_pCurrentMapData); + free(m_pCurrentMapData); #if defined (CONF_SQL) for (int i = 0; i < MAX_SQLSERVERS; i++) @@ -2512,7 +2501,7 @@ return; } - bool SetUpDb = pResult->NumArguments() == 8 ? pResult->GetInteger(7) : false; + bool SetUpDb = pResult->NumArguments() == 8 ? pResult->GetInteger(7) : true; CSqlServer** apSqlServers = ReadOnly ? pSelf->m_apSqlReadServers : pSelf->m_apSqlWriteServers; diff -Nru ddnet-11.1.3/src/engine/server/server.h ddnet-11.1.8/src/engine/server/server.h --- ddnet-11.1.3/src/engine/server/server.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/server/server.h 2018-05-13 20:23:11.000000000 +0000 @@ -261,7 +261,7 @@ void DoSnapshot(); static int NewClientCallback(int ClientID, void *pUser); - static int NewClientNoAuthCallback(int ClientID, bool Reset, void *pUser); + static int NewClientNoAuthCallback(int ClientID, void *pUser); static int DelClientCallback(int ClientID, const char *pReason, void *pUser); static int ClientRejoinCallback(int ClientID, void *pUser); diff -Nru ddnet-11.1.3/src/engine/shared/config.cpp ddnet-11.1.8/src/engine/shared/config.cpp --- ddnet-11.1.3/src/engine/shared/config.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/shared/config.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -11,6 +11,7 @@ { IStorage *m_pStorage; IOHANDLE m_ConfigFile; + bool m_Failed; struct CCallback { @@ -37,6 +38,7 @@ { m_ConfigFile = 0; m_NumCallbacks = 0; + m_Failed = false; } virtual void Init() @@ -60,11 +62,14 @@ { if(!m_pStorage || !g_Config.m_ClSaveSettings) return; - m_ConfigFile = m_pStorage->OpenFile(CONFIG_FILE, IOFLAG_WRITE, IStorage::TYPE_SAVE); + + m_ConfigFile = m_pStorage->OpenFile(CONFIG_FILE_TMP, IOFLAG_WRITE, IStorage::TYPE_SAVE); if(!m_ConfigFile) return; + m_Failed = false; + char aLineBuf[1024*2]; char aEscapeBuf[1024*2]; @@ -79,8 +84,19 @@ for(int i = 0; i < m_NumCallbacks; i++) m_aCallbacks[i].m_pfnFunc(this, m_aCallbacks[i].m_pUserData); - io_close(m_ConfigFile); + if(io_close(m_ConfigFile) != 0) + m_Failed = true; + m_ConfigFile = 0; + + if(m_Failed) + { + dbg_msg("config", "ERROR: writing to " CONFIG_FILE_TMP " failed"); + return; + } + + if(!m_pStorage->RenameFile(CONFIG_FILE_TMP, CONFIG_FILE, IStorage::TYPE_SAVE)) + dbg_msg("config", "ERROR: renaming " CONFIG_FILE_TMP " to " CONFIG_FILE " failed"); } virtual void RegisterCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData) @@ -93,10 +109,14 @@ virtual void WriteLine(const char *pLine) { - if(!m_ConfigFile) - return; - io_write(m_ConfigFile, pLine, str_length(pLine)); - io_write_newline(m_ConfigFile); + if(!m_ConfigFile || + io_write(m_ConfigFile, pLine, str_length(pLine)) != static_cast(str_length(pLine)) || +#if defined(CONF_FAMILY_WINDOWS) + io_write_newline(m_ConfigFile) != 2) +#else + io_write_newline(m_ConfigFile) != 1) +#endif + m_Failed = true; } }; diff -Nru ddnet-11.1.3/src/engine/shared/config.h ddnet-11.1.8/src/engine/shared/config.h --- ddnet-11.1.3/src/engine/shared/config.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/shared/config.h 2018-05-13 20:23:11.000000000 +0000 @@ -4,6 +4,7 @@ #define ENGINE_SHARED_CONFIG_H #define CONFIG_FILE "settings_ddnet.cfg" +#define CONFIG_FILE_TMP CONFIG_FILE ".tmp" #define AUTOEXEC_FILE "autoexec.cfg" #define AUTOEXEC_CLIENT_FILE "autoexec_client.cfg" #define AUTOEXEC_SERVER_FILE "autoexec_server.cfg" diff -Nru ddnet-11.1.3/src/engine/shared/config_variables.h ddnet-11.1.8/src/engine/shared/config_variables.h --- ddnet-11.1.3/src/engine/shared/config_variables.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/shared/config_variables.h 2018-05-13 20:23:11.000000000 +0000 @@ -128,7 +128,7 @@ MACRO_CONFIG_INT(GfxQuadAsTriangle, gfx_quad_as_triangle, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Render quads as triangles (fixes quad coloring on some GPUs)") #endif -MACRO_CONFIG_INT(InpMousesens, inp_mousesens, 200, 5, 100000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Mouse sensitivity") +MACRO_CONFIG_INT(InpMousesens, inp_mousesens, 200, 1, 100000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Mouse sensitivity") MACRO_CONFIG_INT(InpMouseOld, inp_mouseold, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Use old mouse mode (warp mouse instead of raw input)") MACRO_CONFIG_INT(InpIgnoredModifiers, inp_ignored_modifiers, 0, 0, 65536, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Ignored keyboard modifier mask") @@ -230,6 +230,7 @@ #if defined(CONF_SQL) MACRO_CONFIG_INT(SvUseSQL, sv_use_sql, 0, 0, 1, CFGFLAG_SERVER, "Enables SQL DB instead of record file") MACRO_CONFIG_STR(SvSqlServerName, sv_sql_servername, 5, "UNK", CFGFLAG_SERVER, "SQL Server name that is inserted into record table") +MACRO_CONFIG_STR(SvSqlValidServerNames, sv_sql_valid_servernames, 64, "UNK", CFGFLAG_SERVER, "Comma seperated list of valid server names for saving a game to ([A-Z][A-Z][A-Z].?") MACRO_CONFIG_INT(SvSaveGames, sv_savegames, 1, 0, 1, CFGFLAG_SERVER, "Enables savegames (/save and /load)") MACRO_CONFIG_INT(SvSaveGamesDelay, sv_savegames_delay, 60, 0, 10000, CFGFLAG_SERVER, "Delay in seconds for loading a savegame") @@ -376,6 +377,7 @@ MACRO_CONFIG_INT(ClShowNinja, cl_show_ninja, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show ninja skin") MACRO_CONFIG_INT(ClShowHookCollOther, cl_show_hook_coll_other, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show other players' hook collision line") MACRO_CONFIG_INT(ClShowHookCollOwn, cl_show_hook_coll_own, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show own players' hook collision line") +MACRO_CONFIG_INT(ClShowHookCollAlways, cl_show_hook_coll_always, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show every players' hook collision line even if they're not using it") MACRO_CONFIG_INT(ClChatTeamColors, cl_chat_teamcolors, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show names in chat in team colors") MACRO_CONFIG_INT(ClChatReset, cl_chat_reset, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Reset chat when pressing escape") MACRO_CONFIG_INT(ClShowDirection, cl_show_direction, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Show tee direction") diff -Nru ddnet-11.1.3/src/engine/shared/console.cpp ddnet-11.1.8/src/engine/shared/console.cpp --- ddnet-11.1.3/src/engine/shared/console.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/shared/console.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -863,7 +863,7 @@ { CCommand *pNext = pCommand->m_pNext; if(pCommand->m_pfnCallback == Con_Chain) - mem_free(static_cast(pCommand->m_pUserData)); + delete static_cast(pCommand->m_pUserData); delete pCommand; pCommand = pNext; } @@ -1048,7 +1048,7 @@ return; } - CChain *pChainInfo = (CChain *)mem_alloc(sizeof(CChain), sizeof(void*)); + CChain *pChainInfo = new CChain(); // store info pChainInfo->m_pfnChainCallback = pfnChainFunc; diff -Nru ddnet-11.1.3/src/engine/shared/datafile.cpp ddnet-11.1.8/src/engine/shared/datafile.cpp --- ddnet-11.1.3/src/engine/shared/datafile.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/shared/datafile.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -137,10 +137,10 @@ AllocSize += sizeof(CDatafile); // add space for info structure AllocSize += Header.m_NumRawData*sizeof(void*); // add space for data pointers - CDatafile *pTmpDataFile = (CDatafile*)mem_alloc(AllocSize, 1); + CDatafile *pTmpDataFile = (CDatafile *)malloc(AllocSize); pTmpDataFile->m_Header = Header; pTmpDataFile->m_DataStartOffset = sizeof(CDatafileHeader) + Size; - pTmpDataFile->m_ppDataPtrs = (char**)(pTmpDataFile+1); + pTmpDataFile->m_ppDataPtrs = (char **)(pTmpDataFile+1); pTmpDataFile->m_pData = (char *)(pTmpDataFile+1)+Header.m_NumRawData*sizeof(char *); pTmpDataFile->m_File = File; pTmpDataFile->m_Crc = Crc; @@ -153,7 +153,7 @@ if(ReadSize != Size) { io_close(pTmpDataFile->m_File); - mem_free(pTmpDataFile); + free(pTmpDataFile); pTmpDataFile = 0; dbg_msg("datafile", "couldn't load the whole thing, wanted=%d got=%d", Size, ReadSize); return false; @@ -295,12 +295,12 @@ if(m_pDataFile->m_Header.m_Version == 4) { // v4 has compressed data - void *pTemp = (char *)mem_alloc(DataSize, 1); + void *pTemp = malloc(DataSize); unsigned long UncompressedSize = m_pDataFile->m_Info.m_pDataSizes[Index]; unsigned long s; dbg_msg("datafile", "loading data index=%d size=%d uncompressed=%lu", Index, DataSize, UncompressedSize); - m_pDataFile->m_ppDataPtrs[Index] = (char *)mem_alloc(UncompressedSize, 1); + m_pDataFile->m_ppDataPtrs[Index] = (char *)malloc(UncompressedSize); // read the compressed data io_seek(m_pDataFile->m_File, m_pDataFile->m_DataStartOffset+m_pDataFile->m_Info.m_pDataOffsets[Index], IOSEEK_START); @@ -314,13 +314,13 @@ #endif // clean up the temporary buffers - mem_free(pTemp); + free(pTemp); } else { // load the data dbg_msg("datafile", "loading data index=%d size=%d", Index, DataSize); - m_pDataFile->m_ppDataPtrs[Index] = (char *)mem_alloc(DataSize, 1); + m_pDataFile->m_ppDataPtrs[Index] = (char *)malloc(DataSize); io_seek(m_pDataFile->m_File, m_pDataFile->m_DataStartOffset+m_pDataFile->m_Info.m_pDataOffsets[Index], IOSEEK_START); io_read(m_pDataFile->m_File, m_pDataFile->m_ppDataPtrs[Index], DataSize); } @@ -350,7 +350,7 @@ return; // - mem_free(m_pDataFile->m_ppDataPtrs[Index]); + free(m_pDataFile->m_ppDataPtrs[Index]); m_pDataFile->m_ppDataPtrs[Index] = 0x0; } @@ -424,10 +424,10 @@ // free the data that is loaded int i; for(i = 0; i < m_pDataFile->m_Header.m_NumRawData; i++) - mem_free(m_pDataFile->m_ppDataPtrs[i]); + free(m_pDataFile->m_ppDataPtrs[i]); io_close(m_pDataFile->m_File); - mem_free(m_pDataFile); + free(m_pDataFile); m_pDataFile = 0; return true; } @@ -454,18 +454,18 @@ CDataFileWriter::CDataFileWriter() { m_File = 0; - m_pItemTypes = static_cast(mem_alloc(sizeof(CItemTypeInfo) * MAX_ITEM_TYPES, 1)); - m_pItems = static_cast(mem_alloc(sizeof(CItemInfo) * MAX_ITEMS, 1)); - m_pDatas = static_cast(mem_alloc(sizeof(CDataInfo) * MAX_DATAS, 1)); + m_pItemTypes = static_cast(calloc(MAX_ITEM_TYPES, sizeof(CItemTypeInfo))); + m_pItems = static_cast(calloc(MAX_ITEMS, sizeof(CItemInfo))); + m_pDatas = static_cast(calloc(MAX_DATAS, sizeof(CDataInfo))); } CDataFileWriter::~CDataFileWriter() { - mem_free(m_pItemTypes); + free(m_pItemTypes); m_pItemTypes = 0; - mem_free(m_pItems); + free(m_pItems); m_pItems = 0; - mem_free(m_pDatas); + free(m_pDatas); m_pDatas = 0; } @@ -508,7 +508,7 @@ m_pItems[m_NumItems].m_Size = Size; // copy data - m_pItems[m_NumItems].m_pData = mem_alloc(Size, 1); + m_pItems[m_NumItems].m_pData = malloc(Size); mem_copy(m_pItems[m_NumItems].m_pData, pData, Size); if(!m_pItemTypes[Type].m_Num) // count item types @@ -537,7 +537,7 @@ CDataInfo *pInfo = &m_pDatas[m_NumDatas]; unsigned long s = compressBound(Size); - void *pCompData = mem_alloc(s, 1); // temporary buffer that we use during compression + void *pCompData = malloc(s); // temporary buffer that we use during compression int Result = compress((Bytef*)pCompData, &s, (Bytef*)pData, Size); // ignore_convention if(Result != Z_OK) @@ -548,9 +548,9 @@ pInfo->m_UncompressedSize = Size; pInfo->m_CompressedSize = (int)s; - pInfo->m_pCompressedData = mem_alloc(pInfo->m_CompressedSize, 1); + pInfo->m_pCompressedData = malloc(pInfo->m_CompressedSize); mem_copy(pInfo->m_pCompressedData, pCompData, pInfo->m_CompressedSize); - mem_free(pCompData); + free(pCompData); m_NumDatas++; return m_NumDatas-1; @@ -561,11 +561,11 @@ dbg_assert(Size%sizeof(int) == 0, "incorrect boundary"); #if defined(CONF_ARCH_ENDIAN_BIG) - void *pSwapped = mem_alloc(Size, 1); // temporary buffer that we use during compression + void *pSwapped = malloc(Size); // temporary buffer that we use during compression mem_copy(pSwapped, pData, Size); swap_endian(pSwapped, sizeof(int), Size/sizeof(int)); int Index = AddData(Size, pSwapped); - mem_free(pSwapped); + free(pSwapped); return Index; #else return AddData(Size, pData); @@ -741,9 +741,9 @@ // free data for(int i = 0; i < m_NumItems; i++) - mem_free(m_pItems[i].m_pData); + free(m_pItems[i].m_pData); for(int i = 0; i < m_NumDatas; ++i) - mem_free(m_pDatas[i].m_pCompressedData); + free(m_pDatas[i].m_pCompressedData); io_close(m_File); m_File = 0; diff -Nru ddnet-11.1.3/src/engine/shared/demo.cpp ddnet-11.1.8/src/engine/shared/demo.cpp --- ddnet-11.1.3/src/engine/shared/demo.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/shared/demo.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -497,7 +497,7 @@ } // copy all the frames to an array instead for fast access - m_pKeyFrames = (CKeyFrame*)mem_alloc(m_Info.m_SeekablePoints*sizeof(CKeyFrame), 1); + m_pKeyFrames = (CKeyFrame *)calloc(m_Info.m_SeekablePoints, sizeof(CKeyFrame)); for(pCurrentKey = pFirstKey, i = 0; pCurrentKey; pCurrentKey = pCurrentKey->m_pNext, i++) m_pKeyFrames[i] = pCurrentKey->m_Frame; @@ -715,7 +715,7 @@ else if(MapSize > 0) { // get map data - unsigned char *pMapData = (unsigned char *)mem_alloc(MapSize, 1); + unsigned char *pMapData = (unsigned char *)malloc(MapSize); io_read(m_File, pMapData, MapSize); // save map @@ -724,7 +724,7 @@ io_close(MapFile); // free data - mem_free(pMapData); + free(pMapData); } // store map inforation @@ -891,7 +891,7 @@ m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_player", "Stopped playback"); io_close(m_File); m_File = 0; - mem_free(m_pKeyFrames); + free(m_pKeyFrames); m_pKeyFrames = 0; str_copy(m_aFilename, "", sizeof(m_aFilename)); return 0; diff -Nru ddnet-11.1.3/src/engine/shared/engine.cpp ddnet-11.1.8/src/engine/shared/engine.cpp --- ddnet-11.1.3/src/engine/shared/engine.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/shared/engine.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -32,16 +32,6 @@ IStorage *m_pStorage; bool m_Logging; - static void Con_DbgDumpmem(IConsole::IResult *pResult, void *pUserData) - { - CEngine *pEngine = static_cast(pUserData); - char aBuf[32]; - str_timestamp(aBuf, sizeof(aBuf)); - char aFilename[128]; - str_format(aFilename, sizeof(aFilename), "dumps/memory_%s.txt", aBuf); - mem_debug_dump(pEngine->m_pStorage->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE)); - } - static void Con_DbgLognetwork(IConsole::IResult *pResult, void *pUserData) { CEngine *pEngine = static_cast(pUserData); @@ -97,9 +87,6 @@ if(!m_pConsole || !m_pStorage) return; -#ifdef CONF_DEBUG - m_pConsole->Register("dbg_dumpmem", "", CFGFLAG_SERVER|CFGFLAG_CLIENT, Con_DbgDumpmem, this, "Dump the memory"); -#endif m_pConsole->Register("dbg_lognetwork", "", CFGFLAG_SERVER|CFGFLAG_CLIENT, Con_DbgLognetwork, this, "Log the network"); } diff -Nru ddnet-11.1.3/src/engine/shared/memheap.cpp ddnet-11.1.8/src/engine/shared/memheap.cpp --- ddnet-11.1.3/src/engine/shared/memheap.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/shared/memheap.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -10,7 +10,7 @@ char *pMem; // allocate memory - pMem = (char*)mem_alloc(sizeof(CChunk)+CHUNK_SIZE, 1); + pMem = (char *)malloc(sizeof(CChunk) + CHUNK_SIZE); if(!pMem) return; @@ -68,7 +68,7 @@ while(pChunk) { pNext = pChunk->m_pNext; - mem_free(pChunk); + free(pChunk); pChunk = pNext; } diff -Nru ddnet-11.1.3/src/engine/shared/network.h ddnet-11.1.8/src/engine/shared/network.h --- ddnet-11.1.3/src/engine/shared/network.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/shared/network.h 2018-05-13 20:23:11.000000000 +0000 @@ -101,7 +101,7 @@ typedef int (*NETFUNC_DELCLIENT)(int ClientID, const char *pReason, void *pUser); typedef int (*NETFUNC_NEWCLIENT)(int ClientID, void *pUser); -typedef int (*NETFUNC_NEWCLIENT_NOAUTH)(int ClientID, bool Reset, void *pUser); +typedef int (*NETFUNC_NEWCLIENT_NOAUTH)(int ClientID, void *pUser); typedef int (*NETFUNC_CLIENTREJOIN)(int ClientID, void *pUser); struct CNetChunk diff -Nru ddnet-11.1.3/src/engine/shared/network_server.cpp ddnet-11.1.8/src/engine/shared/network_server.cpp --- ddnet-11.1.3/src/engine/shared/network_server.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/shared/network_server.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -280,7 +280,7 @@ if (VanillaAuth) - m_pfnNewClientNoAuth(Slot, true, m_UserPtr); + m_pfnNewClientNoAuth(Slot, m_UserPtr); else m_pfnNewClient(Slot, m_UserPtr); diff -Nru ddnet-11.1.3/src/engine/shared/snapshot.cpp ddnet-11.1.8/src/engine/shared/snapshot.cpp --- ddnet-11.1.3/src/engine/shared/snapshot.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/engine/shared/snapshot.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -419,7 +419,7 @@ while(pHolder) { pNext = pHolder->m_pNext; - mem_free(pHolder); + free(pHolder); pHolder = pNext; } @@ -438,7 +438,7 @@ pNext = pHolder->m_pNext; if(pHolder->m_Tick >= Tick) return; // no more to remove - mem_free(pHolder); + free(pHolder); // did we come to the end of the list? if (!pNext) @@ -463,7 +463,7 @@ if(CreateAlt) TotalSize += DataSize; - CHolder *pHolder = (CHolder *)mem_alloc(TotalSize, 1); + CHolder *pHolder = (CHolder *)malloc(TotalSize); // set data pHolder->m_Tick = Tick; diff -Nru ddnet-11.1.3/src/game/client/components/binds.cpp ddnet-11.1.8/src/game/client/components/binds.cpp --- ddnet-11.1.3/src/game/client/components/binds.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/binds.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -30,7 +30,7 @@ { for(int i = 0; i < KEY_LAST; i++) if(m_apKeyBindings[i]) - mem_free(m_apKeyBindings[i]); + free(m_apKeyBindings[i]); } void CBinds::Bind(int KeyID, const char *pStr, bool FreeOnly) @@ -43,7 +43,7 @@ if(m_apKeyBindings[KeyID]) { - mem_free(m_apKeyBindings[KeyID]); + free(m_apKeyBindings[KeyID]); m_apKeyBindings[KeyID] = 0; } @@ -54,17 +54,10 @@ } else { - int size = str_length(pStr) + 1; - m_apKeyBindings[KeyID] = (char *)mem_alloc(size, 1); - if(!m_apKeyBindings[KeyID]) - { - str_format(aBuf, sizeof(aBuf), "couldn't bind %s (%d) (bind might be too long)", Input()->KeyName(KeyID), KeyID); - } - else - { - str_copy(m_apKeyBindings[KeyID], pStr, size); - str_format(aBuf, sizeof(aBuf), "bound %s (%d) = %s", Input()->KeyName(KeyID), KeyID, m_apKeyBindings[KeyID]); - } + int Size = str_length(pStr) + 1; + m_apKeyBindings[KeyID] = (char *)malloc(Size); + str_copy(m_apKeyBindings[KeyID], pStr, Size); + str_format(aBuf, sizeof(aBuf), "bound %s (%d) = %s", Input()->KeyName(KeyID), KeyID, m_apKeyBindings[KeyID]); } Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); } @@ -87,7 +80,7 @@ for(int i = 0; i < KEY_LAST; i++) { if(m_apKeyBindings[i]) - mem_free(m_apKeyBindings[i]); + free(m_apKeyBindings[i]); m_apKeyBindings[i] = 0; } } diff -Nru ddnet-11.1.3/src/game/client/components/console.cpp ddnet-11.1.8/src/game/client/components/console.cpp --- ddnet-11.1.3/src/game/client/components/console.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/console.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -343,8 +343,8 @@ float tw = pInfo->m_pSelf->TextRender()->TextWidth(pInfo->m_Cursor.m_pFont, pInfo->m_Cursor.m_FontSize, pStr, -1); pInfo->m_pSelf->Graphics()->TextureSet(-1); pInfo->m_pSelf->Graphics()->QuadsBegin(); - pInfo->m_pSelf->Graphics()->SetColor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f); - pInfo->m_pSelf->RenderTools()->DrawRoundRect(pInfo->m_Cursor.m_X-3, pInfo->m_Cursor.m_Y, tw+5, pInfo->m_Cursor.m_FontSize+4, pInfo->m_Cursor.m_FontSize/3); + pInfo->m_pSelf->Graphics()->SetColor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f); + pInfo->m_pSelf->RenderTools()->DrawRoundRect(pInfo->m_Cursor.m_X - 2.5f, pInfo->m_Cursor.m_Y - 4.f / 2.f, tw + 5.f, pInfo->m_Cursor.m_FontSize + 4.f, pInfo->m_Cursor.m_FontSize / 3.f); pInfo->m_pSelf->Graphics()->QuadsEnd(); // scroll when out of sight diff -Nru ddnet-11.1.3/src/game/client/components/countryflags.cpp ddnet-11.1.8/src/game/client/components/countryflags.cpp --- ddnet-11.1.3/src/game/client/components/countryflags.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/countryflags.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -78,7 +78,7 @@ if(g_Config.m_ClLoadCountryFlags) { CountryFlag.m_Texture = Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0); - mem_free(Info.m_pData); + free(Info.m_pData); } else CountryFlag.m_Texture = -1; diff -Nru ddnet-11.1.3/src/game/client/components/flow.cpp ddnet-11.1.8/src/game/client/components/flow.cpp --- ddnet-11.1.3/src/game/client/components/flow.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/flow.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -42,18 +42,15 @@ void CFlow::Init() { - if(m_pCells) - { - mem_free(m_pCells); - m_pCells = 0; - } + free(m_pCells); + m_pCells = 0; CMapItemLayerTilemap *pTilemap = Layers()->GameLayer(); m_Width = pTilemap->m_Width*32/m_Spacing; m_Height = pTilemap->m_Height*32/m_Spacing; // allocate and clear - m_pCells = (CCell *)mem_alloc(sizeof(CCell)*m_Width*m_Height, 1); + m_pCells = (CCell *)calloc(m_Width * m_Height, sizeof(CCell)); for(int y = 0; y < m_Height; y++) for(int x = 0; x < m_Width; x++) m_pCells[y*m_Width+x].m_Vel = vec2(0.0f, 0.0f); diff -Nru ddnet-11.1.3/src/game/client/components/ghost.cpp ddnet-11.1.8/src/game/client/components/ghost.cpp --- ddnet-11.1.3/src/game/client/components/ghost.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/ghost.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -79,7 +79,7 @@ void CGhost::CGhostPath::Reset(int ChunkSize) { for(unsigned i = 0; i < m_lChunks.size(); i++) - mem_free(m_lChunks[i]); + free(m_lChunks[i]); m_lChunks.clear(); m_ChunkSize = ChunkSize; m_NumItems = 0; @@ -94,7 +94,7 @@ { m_lChunks.resize(NeededChunks); for(int i = Chunks; i < NeededChunks; i++) - m_lChunks[i] = (CGhostCharacter*)mem_alloc(sizeof(CGhostCharacter) * m_ChunkSize, 1); + m_lChunks[i] = (CGhostCharacter *)calloc(m_ChunkSize, sizeof(CGhostCharacter)); } m_NumItems = Items; diff -Nru ddnet-11.1.3/src/game/client/components/hud.cpp ddnet-11.1.8/src/game/client/components/hud.cpp --- ddnet-11.1.3/src/game/client/components/hud.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/hud.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -262,6 +262,7 @@ // draw flag Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id); int QuadOffset = NUM_WEAPONS * 10 + 40 + NUM_WEAPONS + t; + Graphics()->SetColor(1.f, 1.f, 1.f, 1.f); Graphics()->RenderQuadContainerAsSprite(m_HudQuadContainerIndex, QuadOffset, Whole - ScoreWidthMax - ImageSize, StartY + 1.0f + t * 20); } else if(FlagCarrier[t] >= 0) diff -Nru ddnet-11.1.3/src/game/client/components/killmessages.cpp ddnet-11.1.8/src/game/client/components/killmessages.cpp --- ddnet-11.1.3/src/game/client/components/killmessages.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/killmessages.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -166,7 +166,7 @@ } if(m_aKillmsgs[r].m_VictimTextContainerIndex != -1) - TextRender()->RenderTextContainer(m_aKillmsgs[r].m_VictimTextContainerIndex, &TColor, &TOutlineColor, x, y); + TextRender()->RenderTextContainer(m_aKillmsgs[r].m_VictimTextContainerIndex, &TColor, &TOutlineColor, x, y + (46.f - 36.f) / 2.f); // render victim tee x -= 24.0f; @@ -205,7 +205,7 @@ Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id); int QuadOffset = 2; - if(m_aKillmsgs[r].m_VictimTeam == TEAM_RED) + if(m_aKillmsgs[r].m_KillerTeam == TEAM_RED) ++QuadOffset; Graphics()->RenderQuadContainerAsSprite(m_SpriteQuadContainerIndex, QuadOffset, x - 56, y - 16); @@ -221,7 +221,7 @@ x -= m_aKillmsgs[r].m_KillerTextWidth; if(m_aKillmsgs[r].m_KillerTextContainerIndex != -1) - TextRender()->RenderTextContainer(m_aKillmsgs[r].m_KillerTextContainerIndex, &TColor, &TOutlineColor, x, y); + TextRender()->RenderTextContainer(m_aKillmsgs[r].m_KillerTextContainerIndex, &TColor, &TOutlineColor, x, y + (46.f - 36.f) / 2.f); } y += 46.0f; diff -Nru ddnet-11.1.3/src/game/client/components/mapimages.cpp ddnet-11.1.8/src/game/client/components/mapimages.cpp --- ddnet-11.1.3/src/game/client/components/mapimages.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/mapimages.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -24,10 +24,9 @@ //TODO: improve this a bit -- with better fron sizes etc. if(m_OverlayBottomTexture == -1) { - void *pMem = mem_alloc(1024*1024, 1); - mem_zero(pMem, 1024*1024); + void *pMem = calloc(1024 * 1024, 1); m_OverlayBottomTexture = Graphics()->LoadTextureRaw(1024, 1024, CImageInfo::FORMAT_ALPHA, pMem, CImageInfo::FORMAT_ALPHA, IGraphics::TEXLOAD_NOMIPMAPS); - mem_free(pMem); + free(pMem); for(int i = 0; i < 256; ++i) { @@ -41,10 +40,9 @@ } if(m_OverlayTopTexture == -1) { - void *pMem = mem_alloc(1024*1024, 1); - mem_zero(pMem, 1024*1024); + void *pMem = calloc(1024 * 1024, 1); m_OverlayTopTexture = Graphics()->LoadTextureRaw(1024, 1024, CImageInfo::FORMAT_ALPHA, pMem, CImageInfo::FORMAT_ALPHA, IGraphics::TEXLOAD_NOMIPMAPS); - mem_free(pMem); + free(pMem); for(int i = 0; i < 256; ++i) { @@ -58,10 +56,9 @@ } if(m_OverlayCenterTexture == -1) { - void *pMem = mem_alloc(1024*1024, 1); - mem_zero(pMem, 1024*1024); + void *pMem = calloc(1024 * 1024, 1); m_OverlayCenterTexture = Graphics()->LoadTextureRaw(1024, 1024, CImageInfo::FORMAT_ALPHA, pMem, CImageInfo::FORMAT_ALPHA, IGraphics::TEXLOAD_NOMIPMAPS); - mem_free(pMem); + free(pMem); for(int i = 0; i < 256; ++i) { diff -Nru ddnet-11.1.3/src/game/client/components/menus_settings.cpp ddnet-11.1.8/src/game/client/components/menus_settings.cpp --- ddnet-11.1.3/src/game/client/components/menus_settings.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/menus_settings.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -798,7 +798,7 @@ str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Mouse sens."), g_Config.m_InpMousesens); UI()->DoLabel(&Label, aBuf, 14.0f*UI()->Scale(), -1); Button.HMargin(2.0f, &Button); - int NewValue = (int)(DoScrollbarH(&g_Config.m_InpMousesens, &Button, (min(g_Config.m_InpMousesens, 500)-5)/500.0f)*500.0f)+5; + int NewValue = (int)(DoScrollbarH(&g_Config.m_InpMousesens, &Button, (min(g_Config.m_InpMousesens, 500)-1)/500.0f)*500.0f)+1; if(g_Config.m_InpMousesens < 500 || NewValue < 500) g_Config.m_InpMousesens = min(NewValue, 500); MovementSettings.HSplitTop(20.0f, 0, &MovementSettings); @@ -811,7 +811,7 @@ str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("UI mouse s."), g_Config.m_UiMousesens); UI()->DoLabel(&Label, aBuf, 14.0f*UI()->Scale(), -1); Button.HMargin(2.0f, &Button); - int NewValue = (int)(DoScrollbarH(&g_Config.m_UiMousesens, &Button, (min(g_Config.m_UiMousesens, 500)-5)/500.0f)*500.0f)+5; + int NewValue = (int)(DoScrollbarH(&g_Config.m_UiMousesens, &Button, (min(g_Config.m_UiMousesens, 500)-1)/500.0f)*500.0f)+1; if(g_Config.m_UiMousesens < 500 || NewValue < 500) g_Config.m_UiMousesens = min(NewValue, 500); MovementSettings.HSplitTop(20.0f, 0, &MovementSettings); diff -Nru ddnet-11.1.3/src/game/client/components/players.cpp ddnet-11.1.8/src/game/client/components/players.cpp --- ddnet-11.1.3/src/game/client/components/players.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/players.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -546,7 +547,9 @@ // draw gun { - if(ClientID >= 0 && Player.m_PlayerFlags&PLAYERFLAG_AIM && ((!Local && g_Config.m_ClShowHookCollOther) || (Local && g_Config.m_ClShowHookCollOwn))) + CServerInfo Info; + Client()->GetServerInfo(&Info); + if(ClientID >= 0 && (((IsDDRace(&Info) || IsDDNet(&Info)) && g_Config.m_ClShowHookCollAlways) || (Player.m_PlayerFlags&PLAYERFLAG_AIM && ((!Local && g_Config.m_ClShowHookCollOther) || (Local && g_Config.m_ClShowHookCollOwn))))) { float Alpha = 1.0f; if(OtherTeam) diff -Nru ddnet-11.1.3/src/game/client/components/scoreboard.cpp ddnet-11.1.8/src/game/client/components/scoreboard.cpp --- ddnet-11.1.3/src/game/client/components/scoreboard.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/scoreboard.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -112,7 +112,7 @@ // Headline y += 10.0f; - TextRender()->Text(0, x+10.0f, y, 28.0f, Localize("Spectators"), w-20.0f); + TextRender()->Text(0, x+10.0f, y + (30.f - 28.f) / 2.f, 28.0f, Localize("Spectators"), w-20.0f); // spectator names y += 30.0f; @@ -195,7 +195,7 @@ else pTitle = Localize("Score board"); } - TextRender()->Text(0, x+20.0f, y, TitleFontsize, pTitle, -1); + TextRender()->Text(0, x+20.0f, y + (50.f - TitleFontsize) / 2.f, TitleFontsize, pTitle, -1); char aBuf[128] = {0}; @@ -237,7 +237,7 @@ if (!lower16 && !lower32 && !lower24) { tw = TextRender()->TextWidth(0, TitleFontsize, aBuf, -1); - TextRender()->Text(0, x+w-tw-20.0f, y, TitleFontsize, aBuf, -1); + TextRender()->Text(0, x+w-tw-20.0f, y + (50.f - TitleFontsize) / 2.f, TitleFontsize, aBuf, -1); } // calculate measurements @@ -287,15 +287,15 @@ float HeadlineFontsize = 22.0f; float ScoreWidth = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Score"), -1); tw = ScoreLength > ScoreWidth ? ScoreLength : ScoreWidth; - TextRender()->Text(0, ScoreOffset+ScoreLength-tw, y, HeadlineFontsize, Localize("Score"), -1); + TextRender()->Text(0, ScoreOffset+ScoreLength-tw, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Score"), -1); - TextRender()->Text(0, NameOffset, y, HeadlineFontsize, Localize("Name"), -1); + TextRender()->Text(0, NameOffset, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Name"), -1); tw = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Clan"), -1); - TextRender()->Text(0, ClanOffset+ClanLength/2-tw/2, y, HeadlineFontsize, Localize("Clan"), -1); + TextRender()->Text(0, ClanOffset+ClanLength/2-tw/2, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Clan"), -1); tw = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Ping"), -1); - TextRender()->Text(0, PingOffset+PingLength-tw, y, HeadlineFontsize, Localize("Ping"), -1); + TextRender()->Text(0, PingOffset+PingLength-tw, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Ping"), -1); // render player entries y += HeadlineFontsize*2.0f; diff -Nru ddnet-11.1.3/src/game/client/components/skins.cpp ddnet-11.1.8/src/game/client/components/skins.cpp --- ddnet-11.1.3/src/game/client/components/skins.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/skins.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -132,7 +132,7 @@ } Skin.m_ColorTexture = pSelf->Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0); - mem_free(Info.m_pData); + free(Info.m_pData); // set skin data str_copy(Skin.m_aName, pName, min((int)sizeof(Skin.m_aName),l-3)); diff -Nru ddnet-11.1.3/src/game/client/components/statboard.cpp ddnet-11.1.8/src/game/client/components/statboard.cpp --- ddnet-11.1.3/src/game/client/components/statboard.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/components/statboard.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -419,20 +419,12 @@ FormatStats(); - unsigned int len = str_length(m_pCSVstr); - char* buf = (char*)mem_alloc(len, 0); - mem_copy(buf, m_pCSVstr, len); - - mem_free(m_pCSVstr); - if(File) { - io_write(File, buf, sizeof(char)*len); + io_write(File, m_pCSVstr, str_length(m_pCSVstr)); io_close(File); } - mem_free(buf); - Client()->AutoCSV_Start(); } } @@ -560,8 +552,7 @@ char aStats[1024*(VANILLA_MAX_CLIENTS+1)]; str_format(aStats, sizeof(aStats), "%s\n\n%s", aServerStats, aPlayerStats); - unsigned int len = str_length(aStats); - m_pCSVstr = (char*)mem_alloc(len, 0); - mem_zero(m_pCSVstr, len); - str_copy(m_pCSVstr, aStats, len); + unsigned int Len = str_length(aStats); + m_pCSVstr = (char *)malloc(Len); + str_copy(m_pCSVstr, aStats, Len); } diff -Nru ddnet-11.1.3/src/game/client/render_map.cpp ddnet-11.1.8/src/game/client/render_map.cpp --- ddnet-11.1.3/src/game/client/render_map.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/client/render_map.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -439,7 +439,7 @@ char aBuf[16]; str_format(aBuf, sizeof(aBuf), "%d", Index); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha); - UI()->TextRender()->Text(0, mx*Scale-2, my*Scale-4, Scale-5, aBuf, -1); + UI()->TextRender()->Text(0, mx*Scale - 3.f, my*Scale, Scale - 5.f, aBuf, -1); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); } } @@ -498,13 +498,13 @@ char aBuf[16]; str_format(aBuf, sizeof(aBuf), "%d", Force); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha); - UI()->TextRender()->Text(0, mx*Scale, my*Scale+16, Scale-20, aBuf, -1); + UI()->TextRender()->Text(0, mx*Scale, (my*Scale) + 16.f + ((16.f - (Scale - 20.f)) / 2.f), Scale - 20.f, aBuf, -1); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); if(MaxSpeed) { str_format(aBuf, sizeof(aBuf), "%d", MaxSpeed); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha); - UI()->TextRender()->Text(0, mx*Scale, my*Scale-2, Scale-20, aBuf, -1); + UI()->TextRender()->Text(0, mx*Scale, (my*Scale) + ((16.f - (Scale - 20.f)) / 2.f), Scale - 20.f, aBuf, -1); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); } } @@ -553,7 +553,7 @@ char aBuf[16]; str_format(aBuf, sizeof(aBuf), "%d", Index); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha); - UI()->TextRender()->Text(0, mx*Scale, my*Scale+16, Scale-20, aBuf, -1); + UI()->TextRender()->Text(0, mx*Scale, my*Scale + 16.f + ((16.f - (Scale - 20.f)) / 2.f), Scale - 20.f, aBuf, -1); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); } @@ -563,7 +563,7 @@ char aBuf[16]; str_format(aBuf, sizeof(aBuf), "%d", Delay); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha); - UI()->TextRender()->Text(0, mx*Scale, my*Scale-2, Scale-20, aBuf, -1); + UI()->TextRender()->Text(0, mx*Scale, my*Scale + ((16.f - (Scale - 20.f)) / 2.f), Scale - 20.f, aBuf, -1); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); } } diff -Nru ddnet-11.1.3/src/game/ddracecommands.h ddnet-11.1.8/src/game/ddracecommands.h --- ddnet-11.1.3/src/game/ddracecommands.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/ddracecommands.h 2018-05-13 20:23:11.000000000 +0000 @@ -42,6 +42,7 @@ CONSOLE_COMMAND("list", "?s[filter]", CFGFLAG_CHAT, ConList, this, "List connected players with optional case-insensitive substring matching filter") CONSOLE_COMMAND("set_team_ddr", "v[id] ?i[team]", CFGFLAG_SERVER, ConSetDDRTeam, this, "Set ddrace team of a player") +CONSOLE_COMMAND("vote_mute", "v[id] i[seconds]", CFGFLAG_SERVER, ConVoteMute, this, "Remove v's right to vote for i seconds") CONSOLE_COMMAND("mute", "", CFGFLAG_SERVER, ConMute, this, "") CONSOLE_COMMAND("muteid", "v[id] i[seconds]", CFGFLAG_SERVER, ConMuteID, this, "") CONSOLE_COMMAND("muteip", "s[ip] i[seconds]", CFGFLAG_SERVER, ConMuteIP, this, "") diff -Nru ddnet-11.1.3/src/game/editor/editor.cpp ddnet-11.1.8/src/game/editor/editor.cpp --- ddnet-11.1.3/src/game/editor/editor.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/editor/editor.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -63,7 +63,7 @@ m_pEditor->Graphics()->UnloadTexture(m_TexID); if(m_pData) { - mem_free(m_pData); + free(m_pData); m_pData = 0; } } @@ -73,7 +73,7 @@ m_pEditor->Sound()->UnloadSample(m_SoundID); if(m_pData) { - mem_free(m_pData); + free(m_pData); m_pData = 0x0; } } @@ -3069,7 +3069,7 @@ pEditor->Graphics()->UnloadTexture(pImg->m_TexID); if(pImg->m_pData) { - mem_free(pImg->m_pData); + free(pImg->m_pData); pImg->m_pData = 0; } *pImg = ImgInfo; @@ -3155,7 +3155,7 @@ return; } - void *pData = mem_alloc((unsigned) DataSize, 1); + void *pData = malloc((unsigned) DataSize); io_read(SoundFile, pData, (unsigned) DataSize); io_close(SoundFile); @@ -3208,7 +3208,7 @@ return; } - void *pData = mem_alloc((unsigned) DataSize, 1); + void *pData = malloc((unsigned) DataSize); io_read(SoundFile, pData, (unsigned) DataSize); io_close(SoundFile); @@ -3219,7 +3219,7 @@ pEditor->Sound()->UnloadSample(pSound->m_SoundID); if(pSound->m_pData) { - mem_free(pSound->m_pData); + free(pSound->m_pData); pSound->m_pData = 0x0; } @@ -3893,7 +3893,7 @@ if(Graphics()->LoadPNG(&m_FilePreviewImageInfo, aBuffer, IStorage::TYPE_ALL)) { m_FilePreviewImage = Graphics()->LoadTextureRaw(m_FilePreviewImageInfo.m_Width, m_FilePreviewImageInfo.m_Height, m_FilePreviewImageInfo.m_Format, m_FilePreviewImageInfo.m_pData, m_FilePreviewImageInfo.m_Format, IGraphics::TEXLOAD_NORESAMPLE); - mem_free(m_FilePreviewImageInfo.m_pData); + free(m_FilePreviewImageInfo.m_pData); } } } diff -Nru ddnet-11.1.3/src/game/editor/editor.h ddnet-11.1.8/src/game/editor/editor.h --- ddnet-11.1.3/src/game/editor/editor.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/editor/editor.h 2018-05-13 20:23:11.000000000 +0000 @@ -383,7 +383,7 @@ struct CSetting { - char m_aCommand[64]; + char m_aCommand[256]; }; array m_lSettings; @@ -905,7 +905,7 @@ static void EnvelopeEval(float TimeOffset, int Env, float *pChannels, void *pUser); float m_CommandBox; - char m_aSettingsCommand[64]; + char m_aSettingsCommand[256]; void DoMapBorder(); int DoButton_Editor_Common(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip); diff -Nru ddnet-11.1.3/src/game/editor/io.cpp ddnet-11.1.8/src/game/editor/io.cpp --- ddnet-11.1.3/src/game/editor/io.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/editor/io.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -267,7 +267,7 @@ Size += str_length(m_lSettings[i].m_aCommand) + 1; } - char *pSettings = (char *)mem_alloc(Size, 1); + char *pSettings = (char *)malloc(Size); char *pNext = pSettings; for(int i = 0; i < m_lSettings.size(); i++) { @@ -276,7 +276,7 @@ pNext += Length; } Item.m_Settings = df.AddData(Size, pSettings); - mem_free(pSettings); + free(pSettings); } df.AddItem(MAPITEMTYPE_INFO, 0, sizeof(Item), &Item); @@ -305,7 +305,7 @@ if(pImg->m_Format == CImageInfo::FORMAT_RGB) { // Convert to RGBA - unsigned char *pDataRGBA = (unsigned char *)mem_alloc(Item.m_Width*Item.m_Height*4, 1); + unsigned char *pDataRGBA = (unsigned char *)malloc(Item.m_Width * Item.m_Height * 4); unsigned char *pDataRGB = (unsigned char *)pImg->m_pData; for(int i = 0; i < Item.m_Width*Item.m_Height; i++) { @@ -316,7 +316,7 @@ pDataRGBA[i*4+3] = 255; } Item.m_ImageData = df.AddData(Item.m_Width*Item.m_Height*4, pDataRGBA); - mem_free(pDataRGBA); + free(pDataRGBA); } else { @@ -418,10 +418,10 @@ if (Item.m_Flags && !(pLayer->m_Game)) { - CTile *pEmptyTiles = (CTile*)mem_alloc(sizeof(CTile)*pLayer->m_Width*pLayer->m_Height, 1); + CTile *pEmptyTiles = (CTile *)calloc(pLayer->m_Width*pLayer->m_Height, sizeof(CTile)); mem_zero(pEmptyTiles, pLayer->m_Width*pLayer->m_Height*sizeof(CTile)); Item.m_Data = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTile), pEmptyTiles); - mem_free(pEmptyTiles); + free(pEmptyTiles); if(pLayer->m_Tele) Item.m_Tele = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTeleTile), ((CLayerTele *)pLayer)->m_pTeleTile); @@ -520,7 +520,7 @@ // save points int TotalSize = sizeof(CEnvPoint) * PointCount; - CEnvPoint *pPoints = (CEnvPoint *)mem_alloc(TotalSize, 1); + CEnvPoint *pPoints = (CEnvPoint *)calloc(PointCount, sizeof(*pPoints)); PointCount = 0; for(int e = 0; e < m_lEnvelopes.size(); e++) @@ -531,7 +531,7 @@ } df.AddItem(MAPITEMTYPE_ENVPOINTS, 0, TotalSize, pPoints); - mem_free(pPoints); + free(pPoints); // finish the data file df.Finish(); @@ -683,7 +683,7 @@ // copy image data void *pData = DataFile.GetData(pItem->m_ImageData); - pImg->m_pData = mem_alloc(pImg->m_Width*pImg->m_Height*4, 1); + pImg->m_pData = malloc(pImg->m_Width*pImg->m_Height*4); mem_copy(pImg->m_pData, pData, pImg->m_Width*pImg->m_Height*4); pImg->m_TexID = m_pEditor->Graphics()->LoadTextureRaw(pImg->m_Width, pImg->m_Height, pImg->m_Format, pImg->m_pData, CImageInfo::FORMAT_AUTO, 0); } @@ -730,7 +730,7 @@ if(pSound->m_DataSize > 0) { - pSound->m_pData = mem_alloc(pSound->m_DataSize, 1); + pSound->m_pData = malloc(pSound->m_DataSize); io_read(SoundFile, pSound->m_pData, pSound->m_DataSize); } io_close(SoundFile); @@ -746,7 +746,7 @@ // copy sample data void *pData = DataFile.GetData(pItem->m_SoundData); - pSound->m_pData = mem_alloc(pSound->m_DataSize, 1); + pSound->m_pData = malloc(pSound->m_DataSize); mem_copy(pSound->m_pData, pData, pSound->m_DataSize); pSound->m_SoundID = m_pEditor->Sound()->LoadOpusFromMem(pSound->m_pData, pSound->m_DataSize, true); } diff -Nru ddnet-11.1.3/src/game/mapbugs.cpp ddnet-11.1.8/src/game/mapbugs.cpp --- ddnet-11.1.3/src/game/mapbugs.cpp 1970-01-01 00:00:00.000000000 +0000 +++ ddnet-11.1.8/src/game/mapbugs.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -0,0 +1,119 @@ +#include "mapbugs.h" + +#include + +struct CMapDescription +{ + const char *m_pName; + int m_Size; + int m_Crc; + + bool operator==(const CMapDescription &Other) const + { + return str_comp(m_pName, Other.m_pName) == 0 && + m_Size == Other.m_Size && + m_Crc == Other.m_Crc; + } +}; + +struct CMapBugsInternal +{ + CMapDescription m_Map; + unsigned int m_BugFlags; +}; + +static unsigned int BugToFlag(int Bug) +{ + unsigned int Result; + dbg_assert((unsigned)Bug < 8 * sizeof(Result), "invalid shift"); + return Result = (1 << Bug); +} + +static unsigned int IsBugFlagSet(int Bug, unsigned int BugFlags) +{ + return (BugFlags & BugToFlag(Bug)) != 0; +} + +static CMapBugsInternal MAP_BUGS[] = +{ + {{"Binary", 2022597, 0x0ae3a3d5}, BugToFlag(BUG_GRENADE_DOUBLEEXPLOSION)} +}; + +CMapBugs GetMapBugs(const char *pName, int Size, int Crc) +{ + CMapDescription Map = {pName, Size, Crc}; + CMapBugs Result; + Result.m_Extra = 0; + for(unsigned int i = 0; i < sizeof(MAP_BUGS) / sizeof(MAP_BUGS[0]); i++) + { + if(Map == MAP_BUGS[i].m_Map) + { + Result.m_pData = &MAP_BUGS[i]; + return Result; + } + } + Result.m_pData = 0; + return Result; +} + +bool CMapBugs::Contains(int Bug) const +{ + CMapBugsInternal *pInternal = (CMapBugsInternal *)m_pData; + if(!pInternal) + { + return IsBugFlagSet(Bug, m_Extra); + } + return IsBugFlagSet(Bug, pInternal->m_BugFlags); +} + +int CMapBugs::Update(const char *pBug) +{ + CMapBugsInternal *pInternal = (CMapBugsInternal *)m_pData; + int Bug = -1; + if(false) {} +#define MAPBUG(constname, string) else if(str_comp(pBug, string) == 0) { Bug = constname; } +#include "mapbugs_list.h" +#undef MAPBUG + if(Bug == -1) + { + return MAPBUGUPDATE_NOTFOUND; + } + if(pInternal) + { + return MAPBUGUPDATE_OVERRIDDEN; + } + m_Extra |= BugToFlag(Bug); + return MAPBUGUPDATE_OK; +} + +void CMapBugs::Dump() const +{ + CMapBugsInternal *pInternal = (CMapBugsInternal *)m_pData; + unsigned int Flags; + if(pInternal) + { + Flags = pInternal->m_BugFlags; + } + else if(m_Extra) + { + Flags = m_Extra; + } + else + { + return; + } + char aBugs[NUM_BUGS + 1] = {0}; + for(int i = 0; i < NUM_BUGS; i++) + { + aBugs[i] = IsBugFlagSet(i, Flags) ? 'X' : 'O'; + } + + dbg_msg("mapbugs", "enabling map compatibility mode %s", aBugs); + if(pInternal) + { + dbg_msg("mapbugs", "map='%s' map_size=%d map_crc=%08x", + pInternal->m_Map.m_pName, + pInternal->m_Map.m_Size, + pInternal->m_Map.m_Crc); + } +} diff -Nru ddnet-11.1.3/src/game/mapbugs.h ddnet-11.1.8/src/game/mapbugs.h --- ddnet-11.1.3/src/game/mapbugs.h 1970-01-01 00:00:00.000000000 +0000 +++ ddnet-11.1.8/src/game/mapbugs.h 2018-05-13 20:23:11.000000000 +0000 @@ -0,0 +1,32 @@ +#ifndef GAME_MAPBUGS_H +#define GAME_MAPBUGS_H + +enum +{ +#define MAPBUG(constname, string) constname, +#include "mapbugs_list.h" +#undef MAPBUG + NUM_BUGS, +}; + +enum +{ + MAPBUGUPDATE_OK, + MAPBUGUPDATE_NOTFOUND, + MAPBUGUPDATE_OVERRIDDEN, +}; + +class CMapBugs +{ + friend CMapBugs GetMapBugs(const char *pName, int Size, int Crc); + void *m_pData; + unsigned int m_Extra; + +public: + bool Contains(int Bug) const; + int Update(const char *pBug); + void Dump() const; +}; + +CMapBugs GetMapBugs(const char *pName, int Size, int Crc); +#endif // GAME_MAPBUGS_H diff -Nru ddnet-11.1.3/src/game/mapbugs_list.h ddnet-11.1.8/src/game/mapbugs_list.h --- ddnet-11.1.3/src/game/mapbugs_list.h 1970-01-01 00:00:00.000000000 +0000 +++ ddnet-11.1.8/src/game/mapbugs_list.h 2018-05-13 20:23:11.000000000 +0000 @@ -0,0 +1 @@ +MAPBUG(BUG_GRENADE_DOUBLEEXPLOSION, "grenade-doubleexplosion@ddnet.tw") diff -Nru ddnet-11.1.3/src/game/server/ddracechat.cpp ddnet-11.1.8/src/game/server/ddracechat.cpp --- ddnet-11.1.3/src/game/server/ddracechat.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/server/ddracechat.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -563,11 +563,13 @@ if (!pPlayer) return; + const char* pTimeout = pResult->NumArguments() > 0 ? pResult->GetString(0) : pPlayer->m_TimeoutCode; + for(int i = 0; i < pSelf->Server()->MaxClients(); i++) { if (i == pResult->m_ClientID) continue; if (!pSelf->m_apPlayers[i]) continue; - if (str_comp(pSelf->m_apPlayers[i]->m_TimeoutCode, pResult->GetString(0))) continue; + if (str_comp(pSelf->m_apPlayers[i]->m_TimeoutCode, pTimeout)) continue; if (pSelf->Server()->SetTimedOut(i, pResult->m_ClientID)) { if (pSelf->m_apPlayers[i]->GetCharacter()) pSelf->SendTuningParams(i, pSelf->m_apPlayers[i]->GetCharacter()->m_TuneZone); @@ -627,10 +629,29 @@ str_copy(aCountry, g_Config.m_SvSqlServerName, sizeof(aCountry)); } - pSelf->Score()->SaveTeam(Team, pCode, pResult->m_ClientID, aCountry); + char aValidServerNames[sizeof(g_Config.m_SvSqlValidServerNames)]; + str_copy(aValidServerNames, g_Config.m_SvSqlValidServerNames, sizeof(aValidServerNames)); + char *p = strtok(aValidServerNames, ",");; + + while(p) + { + if(str_comp(p, aCountry) == 0) + { + pSelf->Score()->SaveTeam(Team, pCode, pResult->m_ClientID, aCountry); + + if(g_Config.m_SvUseSQL) + pPlayer->m_LastSQLQuery = pSelf->Server()->Tick(); + + return; + } + + p = strtok(NULL, ","); + } + + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "Unknown server name '%s'.", aCountry); + pSelf->SendChatTarget(pResult->m_ClientID, aBuf); - if(g_Config.m_SvUseSQL) - pPlayer->m_LastSQLQuery = pSelf->Server()->Tick(); #endif } @@ -750,42 +771,46 @@ if (pResult->NumArguments() > 0) Lock = !pResult->GetInteger(0); - if(Team > TEAM_FLOCK && Team < TEAM_SUPER) + if(Team <= TEAM_FLOCK || Team >= TEAM_SUPER) { - char aBuf[512]; - if(Lock) - { - ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.SetTeamLock(Team, false); + pSelf->Console()->Print( + IConsole::OUTPUT_LEVEL_STANDARD, + "print", + "This team can't be locked"); + return; + } - str_format(aBuf, sizeof(aBuf), "'%s' unlocked your team.", pSelf->Server()->ClientName(pResult->m_ClientID)); + if(pSelf->ProcessSpamProtection(pResult->m_ClientID)) + return; - for (int i = 0; i < MAX_CLIENTS; i++) - if (((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(i) == Team) - pSelf->SendChatTarget(i, aBuf); - } - else if(!g_Config.m_SvTeamLock) - { - pSelf->Console()->Print( - IConsole::OUTPUT_LEVEL_STANDARD, - "print", - "Team locking is disabled on this server"); - } - else - { - ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.SetTeamLock(Team, true); + char aBuf[512]; + if(Lock) + { + ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.SetTeamLock(Team, false); - str_format(aBuf, sizeof(aBuf), "'%s' locked your team. After the race started killing will kill everyone in your team.", pSelf->Server()->ClientName(pResult->m_ClientID)); + str_format(aBuf, sizeof(aBuf), "'%s' unlocked your team.", pSelf->Server()->ClientName(pResult->m_ClientID)); - for (int i = 0; i < MAX_CLIENTS; i++) - if (((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(i) == Team) - pSelf->SendChatTarget(i, aBuf); - } + for (int i = 0; i < MAX_CLIENTS; i++) + if (((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(i) == Team) + pSelf->SendChatTarget(i, aBuf); } - else + else if(!g_Config.m_SvTeamLock) + { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "print", - "This team can't be locked"); + "Team locking is disabled on this server"); + } + else + { + ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.SetTeamLock(Team, true); + + str_format(aBuf, sizeof(aBuf), "'%s' locked your team. After the race started killing will kill everyone in your team.", pSelf->Server()->ClientName(pResult->m_ClientID)); + + for (int i = 0; i < MAX_CLIENTS; i++) + if (((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(i) == Team) + pSelf->SendChatTarget(i, aBuf); + } } void CGameContext::ConInviteTeam(IConsole::IResult *pResult, void *pUserData) @@ -1132,9 +1157,21 @@ return; if (pResult->NumArguments()) + { + if (pPlayer->m_ShowAll == (bool)pResult->GetInteger(0)) + return; + pPlayer->m_ShowAll = pResult->GetInteger(0); + } else + { pPlayer->m_ShowAll = !pPlayer->m_ShowAll; + } + + if (pPlayer->m_ShowAll) + pSelf->SendChatTarget(pResult->m_ClientID, "You will now see all tees on this server, no matter the distance"); + else + pSelf->SendChatTarget(pResult->m_ClientID, "You will no longer see all tees on this server"); } void CGameContext::ConSpecTeam(IConsole::IResult *pResult, void *pUserData) diff -Nru ddnet-11.1.3/src/game/server/ddracechat.h ddnet-11.1.8/src/game/server/ddracechat.h --- ddnet-11.1.3/src/game/server/ddracechat.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/server/ddracechat.h 2018-05-13 20:23:11.000000000 +0000 @@ -23,7 +23,7 @@ CHAT_COMMAND("specvoted", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConToggleSpecVoted, this, "Toggles spec on the currently voted player") CHAT_COMMAND("dnd", "", CFGFLAG_CHAT|CFGFLAG_SERVER|CFGFLAG_NONTEEHISTORIC, ConDND, this, "Toggle Do Not Disturb (no chat and server messages)") CHAT_COMMAND("mapinfo", "?r[map]", CFGFLAG_CHAT|CFGFLAG_SERVER, ConMapInfo, this, "Show info about the map with name r gives (current map by default)") -CHAT_COMMAND("timeout", "s[code]", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTimeout, this, "Set timeout protection code s") +CHAT_COMMAND("timeout", "?s[code]", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTimeout, this, "Set timeout protection code s") CHAT_COMMAND("save", "r[code]", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSave, this, "Save team with code r to current server. To save to another server, use '/save s r' where s = server (case-sensitive: GER, RUS, etc) and r = code") CHAT_COMMAND("load", "r[code]", CFGFLAG_CHAT|CFGFLAG_SERVER, ConLoad, this, "Load with code r") CHAT_COMMAND("map", "?r[map]", CFGFLAG_CHAT|CFGFLAG_SERVER|CFGFLAG_NONTEEHISTORIC, ConMap, this, "Vote a map by name") diff -Nru ddnet-11.1.3/src/game/server/ddracecommands.cpp ddnet-11.1.8/src/game/server/ddracecommands.cpp --- ddnet-11.1.3/src/game/server/ddracecommands.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/server/ddracecommands.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -345,6 +345,50 @@ pPlayer->ForcePause(Seconds); } +void CGameContext::VoteMute(IConsole::IResult *pResult, NETADDR *pAddr, int Secs, + const char *pDisplayName, int AuthedID) +{ + char aBuf[128]; + bool Found = 0; + + pAddr->port = 0; // ignore port number for vote mutes + + // find a matching vote mute for this ip, update expiration time if found + for(int i = 0; i < m_NumVoteMutes; i++) + { + if(net_addr_comp(&m_aVoteMutes[i].m_Addr, pAddr) == 0) + { + m_aVoteMutes[i].m_Expire = Server()->Tick() + + Secs * Server()->TickSpeed(); + Found = 1; + break; + } + } + + if(!Found) // nothing found so far, find a free slot.. + { + if(m_NumVoteMutes < MAX_VOTE_BANS) + { + m_aVoteMutes[m_NumVoteMutes].m_Addr = *pAddr; + m_aVoteMutes[m_NumVoteMutes].m_Expire = Server()->Tick() + + Secs * Server()->TickSpeed(); + m_NumVoteMutes++; + Found = 1; + } + } + if(Found) + { + if(pDisplayName) + { + str_format(aBuf, sizeof aBuf, "'%s' banned '%s' for %d seconds from voting.", + Server()->ClientName(AuthedID), pDisplayName, Secs); + Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemute", aBuf); + } + } + else // no free slot found + Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemute", "vote mute array is full"); +} + void CGameContext::Mute(IConsole::IResult *pResult, NETADDR *Addr, int Secs, const char *pDisplayName) { @@ -388,6 +432,24 @@ Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", "mute array is full"); } +void CGameContext::ConVoteMute(IConsole::IResult *pResult, void *pUserData) +{ + CGameContext *pSelf = (CGameContext *)pUserData; + int Victim = pResult->GetVictim(); + + if(Victim < 0 || Victim > MAX_CLIENTS || !pSelf->m_apPlayers[Victim]) + { + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemute", "Client ID not found"); + return; + } + + NETADDR Addr; + pSelf->Server()->GetClientAddr(Victim, &Addr); + + pSelf->VoteMute(pResult, &Addr, clamp(pResult->GetInteger(1), 1, 86400), + pSelf->Server()->ClientName(Victim), pResult->m_ClientID); +} + void CGameContext::ConMute(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; diff -Nru ddnet-11.1.3/src/game/server/entities/projectile.cpp ddnet-11.1.8/src/game/server/entities/projectile.cpp --- ddnet-11.1.3/src/game/server/entities/projectile.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/server/entities/projectile.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -29,6 +29,7 @@ m_Type = Type; m_Pos = Pos; m_Direction = Dir; + m_InitialLifeSpan = Span; m_LifeSpan = Span; m_Owner = Owner; m_Force = Force; @@ -152,10 +153,18 @@ { if(m_Explosive/*??*/ && (!pTargetChr || (pTargetChr && (!m_Freeze || (m_Weapon == WEAPON_SHOTGUN && Collide))))) { - GameServer()->CreateExplosion(ColPos, m_Owner, m_Weapon, m_Owner == -1, (!pTargetChr ? -1 : pTargetChr->Team()), - (m_Owner != -1)? TeamMask : -1LL); - GameServer()->CreateSound(ColPos, m_SoundImpact, - (m_Owner != -1)? TeamMask : -1LL); + int Number = 1; + if(GameServer()->EmulateBug(BUG_GRENADE_DOUBLEEXPLOSION) && m_LifeSpan == -1 && m_InitialLifeSpan == 0) + { + Number = 2; + } + for(int i = 0; i < Number; i++) + { + GameServer()->CreateExplosion(ColPos, m_Owner, m_Weapon, m_Owner == -1, (!pTargetChr ? -1 : pTargetChr->Team()), + (m_Owner != -1)? TeamMask : -1LL); + GameServer()->CreateSound(ColPos, m_SoundImpact, + (m_Owner != -1)? TeamMask : -1LL); + } } else if(pTargetChr && m_Freeze && ((m_Layer == LAYER_SWITCH && GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pTargetChr->Team()]) || m_Layer != LAYER_SWITCH)) pTargetChr->Freeze(); @@ -180,11 +189,13 @@ return; } else + { if (!m_Freeze) { GameServer()->m_World.DestroyEntity(this); return; } + } } if(m_LifeSpan == -1) { diff -Nru ddnet-11.1.3/src/game/server/entities/projectile.h ddnet-11.1.8/src/game/server/entities/projectile.h --- ddnet-11.1.3/src/game/server/entities/projectile.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/server/entities/projectile.h 2018-05-13 20:23:11.000000000 +0000 @@ -33,6 +33,7 @@ private: vec2 m_Direction; + int m_InitialLifeSpan; int m_LifeSpan; int m_Owner; int m_Type; diff -Nru ddnet-11.1.3/src/game/server/entity.h ddnet-11.1.8/src/game/server/entity.h --- ddnet-11.1.3/src/game/server/entity.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/server/entity.h 2018-05-13 20:23:11.000000000 +0000 @@ -11,15 +11,13 @@ public: \ void *operator new(size_t Size) \ { \ - void *p = mem_alloc(Size, 1); \ - /*dbg_msg("", "++ %p %d", p, size);*/ \ + void *p = malloc(Size); \ mem_zero(p, Size); \ return p; \ } \ void operator delete(void *pPtr) \ { \ - /*dbg_msg("", "-- %p", p);*/ \ - mem_free(pPtr); \ + free(pPtr); \ } \ private: diff -Nru ddnet-11.1.3/src/game/server/gamecontext.cpp ddnet-11.1.8/src/game/server/gamecontext.cpp --- ddnet-11.1.3/src/game/server/gamecontext.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/server/gamecontext.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -53,6 +53,7 @@ m_pVoteOptionHeap = new CHeap(); m_pScore = 0; m_NumMutes = 0; + m_NumVoteMutes = 0; } m_ChatResponseTargetID = -1; m_aDeleteTempfile[0] = 0; @@ -123,6 +124,11 @@ return m_apPlayers[ClientID]->GetCharacter(); } +bool CGameContext::EmulateBug(int Bug) +{ + return m_MapBugs.Contains(Bug); +} + void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount, int64_t Mask) { float a = 3 * 3.14159f / 2 + Angle; @@ -736,7 +742,7 @@ continue; // don't count votes by blacklisted clients - if (g_Config.m_SvDnsblVote && !m_pServer->DnsblWhite(i)) + if(g_Config.m_SvDnsblVote && !m_pServer->DnsblWhite(i)) continue; int ActVote = m_apPlayers[i]->m_Vote; @@ -775,7 +781,7 @@ VetoStop = true; } - // Check if a active moderator has voted. + // Check if an active moderator has voted. if (m_apPlayers[i] && m_apPlayers[i]->m_Vote != 0 && m_apPlayers[i]->m_Moderating) { if (m_apPlayers[i]->m_Vote == 1) @@ -784,13 +790,13 @@ Console()->ExecuteLine(m_aVoteCommand); Server()->SetRconCID(IServer::RCON_CID_SERV); EndVote(); - SendChat(-1, CGameContext::CHAT_ALL, "Vote passed enforced by server moderator"); + SendChat(-1, CGameContext::CHAT_ALL, "Vote passed enforced by authorized player"); return; } else if (m_apPlayers[i]->m_Vote == -1) { EndVote(); - SendChat(-1, CGameContext::CHAT_ALL, "Vote failed enforced by server moderator"); + SendChat(-1, CGameContext::CHAT_ALL, "Vote failed enforced by authorized player"); return; } } @@ -846,7 +852,7 @@ else if(m_VoteEnforce == VOTE_ENFORCE_YES_ADMIN) { char aBuf[64]; - str_format(aBuf, sizeof(aBuf),"Vote passed enforced by server moderator"); + str_format(aBuf, sizeof(aBuf),"Vote passed enforced by authorized player"); Console()->ExecuteLine(m_aVoteCommand, m_VoteEnforcer); SendChat(-1, CGameContext::CHAT_ALL, aBuf); EndVote(); @@ -854,7 +860,7 @@ else if(m_VoteEnforce == VOTE_ENFORCE_NO_ADMIN) { char aBuf[64]; - str_format(aBuf, sizeof(aBuf),"Vote failed enforced by server moderator"); + str_format(aBuf, sizeof(aBuf),"Vote failed enforced by authorized player"); EndVote(); SendChat(-1, CGameContext::CHAT_ALL, aBuf); } @@ -1351,6 +1357,21 @@ return; } + NETADDR Addr; + Server()->GetClientAddr(ClientID, &Addr); + Addr.port = 0; // ignore port number + int VoteMuted = 0; + for(int i = 0; i < m_NumVoteMutes && !VoteMuted; i++) + if(!net_addr_comp(&Addr, &m_aVoteMutes[i].m_Addr)) + VoteMuted = (m_aVoteMutes[i].m_Expire - Server()->Tick()) / Server()->TickSpeed(); + if(VoteMuted > 0) + { + char aChatmsg[64]; + str_format(aChatmsg, sizeof(aChatmsg), "You are not permitted to vote for the next %d seconds.", VoteMuted); + SendChatTarget(ClientID, aChatmsg); + return; + } + char aChatmsg[512] = {0}; char aDesc[VOTE_DESC_LENGTH] = {0}; char aCmd[VOTE_CMD_LENGTH] = {0}; @@ -1509,7 +1530,7 @@ int KickedAuthed = Server()->GetAuthedState(KickID); if(KickedAuthed > 0 && KickedAuthed >= Authed) { - SendChatTarget(ClientID, "You can't kick moderators"); + SendChatTarget(ClientID, "You can't kick authorized players"); m_apPlayers[ClientID]->m_Last_KickVote = time_get(); char aBufKick[128]; str_format(aBufKick, sizeof(aBufKick), "'%s' called for vote to kick you", Server()->ClientName(ClientID)); @@ -2056,6 +2077,38 @@ } } +void CGameContext::ConMapbug(IConsole::IResult *pResult, void *pUserData) +{ + CGameContext *pSelf = (CGameContext *)pUserData; + const char *pMapBugName = pResult->GetString(0); + + if(pSelf->m_pController) + { + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mapbugs", "can't add map bugs after the game started"); + return; + } + + switch(pSelf->m_MapBugs.Update(pMapBugName)) + { + case MAPBUGUPDATE_OK: + break; + case MAPBUGUPDATE_OVERRIDDEN: + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mapbugs", "map-internal setting overridden by database"); + break; + case MAPBUGUPDATE_NOTFOUND: + { + char aBuf[64]; + str_format(aBuf, sizeof(aBuf), "unknown map bug '%s', ignoring", pMapBugName); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mapbugs", aBuf); + + } + break; + default: + dbg_assert(0, "unreachable"); + } + +} + void CGameContext::ConSwitchOpen(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; @@ -2394,7 +2447,7 @@ { if(str_comp_nocase(pValue, pOption->m_aDescription) == 0) { - str_format(aBuf, sizeof(aBuf), "moderator forced server option '%s' (%s)", pValue, pReason); + str_format(aBuf, sizeof(aBuf), "authroized player forced server option '%s' (%s)", pValue, pReason); pSelf->SendChatTarget(-1, aBuf); pSelf->Console()->ExecuteLine(pOption->m_aCommand); break; @@ -2508,6 +2561,7 @@ Console()->Register("tune_zone_reset", "?i[zone]", CFGFLAG_SERVER, ConTuneResetZone, this, "reset zone tuning in zone x or in all zones"); Console()->Register("tune_zone_enter", "i[zone] s[message]", CFGFLAG_SERVER|CFGFLAG_GAME, ConTuneSetZoneMsgEnter, this, "which message to display on zone enter; use 0 for normal area"); Console()->Register("tune_zone_leave", "i[zone] s[message]", CFGFLAG_SERVER|CFGFLAG_GAME, ConTuneSetZoneMsgLeave, this, "which message to display on zone leave; use 0 for normal area"); + Console()->Register("mapbug", "s[mapbug]", CFGFLAG_SERVER|CFGFLAG_GAME, ConMapbug, this, "Enable map compatibility mode using the specified bug (example: grenade-doublexplosion@ddnet.tw)"); Console()->Register("switch_open", "i['0'|'1']", CFGFLAG_SERVER|CFGFLAG_GAME, ConSwitchOpen, this, "Whether a switch is open by default (otherwise closed)"); Console()->Register("pause_game", "", CFGFLAG_SERVER, ConPause, this, "Pause/unpause game"); Console()->Register("change_map", "?r[map]", CFGFLAG_SERVER|CFGFLAG_STORE, ConChangeMap, this, "Change map"); @@ -2555,6 +2609,12 @@ m_Layers.Init(Kernel()); m_Collision.Init(&m_Layers); + char aMapName[128]; + int MapSize; + int MapCrc; + Server()->GetMapInfo(aMapName, sizeof(aMapName), &MapSize, &MapCrc); + m_MapBugs = GetMapBugs(aMapName, MapSize, MapCrc); + // reset everything here //world = new GAMEWORLD; //players = new CPlayer[MAX_CLIENTS]; @@ -2611,6 +2671,8 @@ LoadMapSettings(); + m_MapBugs.Dump(); + m_pController = new CGameControllerDDRace(this); ((CGameControllerDDRace*)m_pController)->m_Teams.Reset(); @@ -2658,9 +2720,9 @@ GameInfo.m_pTuning = Tuning(); GameInfo.m_pUuids = &g_UuidManager; - char aMapName[128]; - Server()->GetMapInfo(aMapName, sizeof(aMapName), &GameInfo.m_MapSize, &GameInfo.m_MapCrc); GameInfo.m_pMapName = aMapName; + GameInfo.m_MapSize = MapSize; + GameInfo.m_MapCrc = MapCrc; m_TeeHistorian.Reset(&GameInfo, TeeHistorianWrite, this); @@ -2855,21 +2917,21 @@ while((pLine = LineReader.Get())) { int Length = str_length(pLine) + 1; - char *pCopy = (char *)mem_alloc(Length, 1); + char *pCopy = (char *)malloc(Length); mem_copy(pCopy, pLine, Length); aLines.add(pCopy); TotalLength += Length; } io_close(File); - char *pSettings = (char *)mem_alloc(TotalLength, 1); + char *pSettings = (char *)malloc(TotalLength); int Offset = 0; for(int i = 0; i < aLines.size(); i++) { int Length = str_length(aLines[i]) + 1; mem_copy(pSettings + Offset, aLines[i], Length); Offset += Length; - mem_free(aLines[i]); + free(aLines[i]); } CDataFileReader Reader; @@ -3481,7 +3543,7 @@ char aBuf[256]; const char *pOption = Success ? "yes" : "no"; - str_format(aBuf, sizeof(aBuf), "moderator forced vote %s", pOption); + str_format(aBuf, sizeof(aBuf), "authorized player forced vote %s", pOption); SendChatTarget(-1, aBuf); str_format(aBuf, sizeof(aBuf), "forcing vote %s", pOption); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); diff -Nru ddnet-11.1.3/src/game/server/gamecontext.h ddnet-11.1.8/src/game/server/gamecontext.h --- ddnet-11.1.3/src/game/server/gamecontext.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/server/gamecontext.h 2018-05-13 20:23:11.000000000 +0000 @@ -8,6 +8,7 @@ #include #include +#include #include #include "eventhandler.h" @@ -69,6 +70,7 @@ CTeeHistorian m_TeeHistorian; ASYNCIO *m_pTeeHistorianFile; CUuid m_GameUuid; + CMapBugs m_MapBugs; static void CommandCallback(int ClientID, int FlagMask, const char *pCmd, IConsole::IResult *pResult, void *pUser); static void TeeHistorianWrite(const void *pData, int DataSize, void *pUser); @@ -81,6 +83,7 @@ static void ConTuneResetZone(IConsole::IResult *pResult, void *pUserData); static void ConTuneSetZoneMsgEnter(IConsole::IResult *pResult, void *pUserData); static void ConTuneSetZoneMsgLeave(IConsole::IResult *pResult, void *pUserData); + static void ConMapbug(IConsole::IResult *pResult, void *pUserData); static void ConSwitchOpen(IConsole::IResult *pResult, void *pUserData); static void ConPause(IConsole::IResult *pResult, void *pUserData); static void ConChangeMap(IConsole::IResult *pResult, void *pUserData); @@ -129,6 +132,7 @@ // helper functions class CCharacter *GetPlayerChar(int ClientID); + bool EmulateBug(int Bug); //int m_LockTeams; @@ -342,6 +346,7 @@ static void ConRescue(IConsole::IResult *pResult, void *pUserData); static void ConProtectedKill(IConsole::IResult *pResult, void *pUserData); + static void ConVoteMute(IConsole::IResult *pResult, void *pUserData); static void ConMute(IConsole::IResult *pResult, void *pUserData); static void ConMuteID(IConsole::IResult *pResult, void *pUserData); static void ConMuteIP(IConsole::IResult *pResult, void *pUserData); @@ -358,16 +363,25 @@ enum { MAX_MUTES=32, + MAX_VOTE_BANS=32, }; struct CMute { NETADDR m_Addr; int m_Expire; }; + struct CVoteMute + { + NETADDR m_Addr; + int m_Expire; + }; CMute m_aMutes[MAX_MUTES]; int m_NumMutes; + CVoteMute m_aVoteMutes[MAX_VOTE_BANS]; + int m_NumVoteMutes; void Mute(IConsole::IResult *pResult, NETADDR *Addr, int Secs, const char *pDisplayName); + void VoteMute(IConsole::IResult *pResult, NETADDR *pAddr, int Secs, const char *pDisplayName, int AuthedID); void Whisper(int ClientID, char *pStr); void WhisperID(int ClientID, int VictimID, char *pMessage); void Converse(int ClientID, char *pStr); diff -Nru ddnet-11.1.3/src/game/variables.h ddnet-11.1.8/src/game/variables.h --- ddnet-11.1.3/src/game/variables.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/variables.h 2018-05-13 20:23:11.000000000 +0000 @@ -48,19 +48,9 @@ MACRO_CONFIG_INT(ClWarningTeambalance, cl_warning_teambalance, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Warn about team balance") -#if defined(__ANDROID__) -// Disable dynamic camera on Android, screen becomes jerky when you tap joystick -MACRO_CONFIG_INT(ClMouseDeadzone, cl_mouse_deadzone, 800, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") -#else -MACRO_CONFIG_INT(ClMouseDeadzone, cl_mouse_deadzone, 300, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") -#endif -MACRO_CONFIG_INT(ClMouseFollowfactor, cl_mouse_followfactor, 60, 0, 200, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") -#if defined(__ANDROID__) -// Prevent crosshair from moving out of screen on Android +MACRO_CONFIG_INT(ClMouseDeadzone, cl_mouse_deadzone, 0, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") +MACRO_CONFIG_INT(ClMouseFollowfactor, cl_mouse_followfactor, 0, 0, 200, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") MACRO_CONFIG_INT(ClMouseMaxDistance, cl_mouse_max_distance, 400, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") -#else -MACRO_CONFIG_INT(ClMouseMaxDistance, cl_mouse_max_distance, 800, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") -#endif MACRO_CONFIG_INT(ClDyncam, cl_dyncam, 0, 0, 1, CFGFLAG_CLIENT, "Enable dyncam") MACRO_CONFIG_INT(ClDyncamMaxDistance, cl_dyncam_max_distance, 1000, 0, 2000, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Maximal dynamic camera distance") @@ -96,7 +86,7 @@ MACRO_CONFIG_INT(UiToolboxPage, ui_toolbox_page, 0, 0, 2, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Toolbox page") MACRO_CONFIG_STR(UiServerAddress, ui_server_address, 64, "localhost:8303", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface server address") MACRO_CONFIG_INT(UiScale, ui_scale, 100, 50, 150, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface scale") -MACRO_CONFIG_INT(UiMousesens, ui_mousesens, 200, 5, 100000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Mouse sensitivity for menus/editor") +MACRO_CONFIG_INT(UiMousesens, ui_mousesens, 200, 1, 100000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Mouse sensitivity for menus/editor") MACRO_CONFIG_INT(UiColorHue, ui_color_hue, 160, 0, 255, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface color hue") MACRO_CONFIG_INT(UiColorSat, ui_color_sat, 70, 0, 255, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface color saturation") diff -Nru ddnet-11.1.3/src/game/version.h ddnet-11.1.8/src/game/version.h --- ddnet-11.1.3/src/game/version.h 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/game/version.h 2018-05-13 20:23:11.000000000 +0000 @@ -2,9 +2,9 @@ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #ifndef GAME_VERSION_H #define GAME_VERSION_H -#define GAME_VERSION "0.6.4, 11.1.3" +#define GAME_VERSION "0.6.4, 11.1.8" #define GAME_NETVERSION "0.6 626fce9a778df4d4" -#define GAME_RELEASE_VERSION "11.1.3" -#define CLIENT_VERSIONNR 11013 +#define GAME_RELEASE_VERSION "11.1.8" +#define CLIENT_VERSIONNR 11018 extern const char *GIT_SHORTREV_HASH; #endif diff -Nru ddnet-11.1.3/src/test/mapbugs.cpp ddnet-11.1.8/src/test/mapbugs.cpp --- ddnet-11.1.3/src/test/mapbugs.cpp 1970-01-01 00:00:00.000000000 +0000 +++ ddnet-11.1.8/src/test/mapbugs.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -0,0 +1,36 @@ +#include + +#include + +TEST(MapBugs, Contains) +{ + EXPECT_TRUE(GetMapBugs("Binary", 2022597, 0x0ae3a3d5).Contains(BUG_GRENADE_DOUBLEEXPLOSION)); + EXPECT_FALSE(GetMapBugs("Binarx", 2022597, 0x0ae3a3d5).Contains(BUG_GRENADE_DOUBLEEXPLOSION)); + EXPECT_FALSE(GetMapBugs("Binary", 2022597, 0x0ae3a3d6).Contains(BUG_GRENADE_DOUBLEEXPLOSION)); + EXPECT_FALSE(GetMapBugs("Binary", 2022598, 0x0ae3a3d5).Contains(BUG_GRENADE_DOUBLEEXPLOSION)); + EXPECT_FALSE(GetMapBugs("dm1", 5805, 0xf2159e6e).Contains(BUG_GRENADE_DOUBLEEXPLOSION)); +} + +TEST(MapBugs, Update) +{ + { + CMapBugs Binary = GetMapBugs("Binary", 2022597, 0x0ae3a3d5); + EXPECT_EQ(Binary.Update("grenade-doubleexplosion@ddnet.tw"), MAPBUGUPDATE_OVERRIDDEN); + EXPECT_EQ(Binary.Update("doesntexist@invalid"), MAPBUGUPDATE_NOTFOUND); + EXPECT_TRUE(Binary.Contains(BUG_GRENADE_DOUBLEEXPLOSION)); + } + { + CMapBugs Dm1 = GetMapBugs("dm1", 5805, 0xf2159e6e); + EXPECT_FALSE(Dm1.Contains(BUG_GRENADE_DOUBLEEXPLOSION)); + EXPECT_EQ(Dm1.Update("doesntexist@invalid"), MAPBUGUPDATE_NOTFOUND); + EXPECT_FALSE(Dm1.Contains(BUG_GRENADE_DOUBLEEXPLOSION)); + EXPECT_EQ(Dm1.Update("grenade-doubleexplosion@ddnet.tw"), MAPBUGUPDATE_OK); + EXPECT_TRUE(Dm1.Contains(BUG_GRENADE_DOUBLEEXPLOSION)); + } +} + +TEST(MapBugs, Dump) +{ + GetMapBugs("Binary", 2022597, 0x0ae3a3d5).Dump(); + GetMapBugs("dm1", 5805, 0xf2159e6e).Dump(); +} diff -Nru ddnet-11.1.3/src/tools/config_store.cpp ddnet-11.1.8/src/tools/config_store.cpp --- ddnet-11.1.3/src/tools/config_store.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/tools/config_store.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -24,21 +24,21 @@ while((pLine = LineReader.Get())) { int Length = str_length(pLine) + 1; - char *pCopy = (char *)mem_alloc(Length, 1); + char *pCopy = (char *)malloc(Length); mem_copy(pCopy, pLine, Length); aLines.add(pCopy); TotalLength += Length; } io_close(File); - pSettings = (char *)mem_alloc(TotalLength, 1); + pSettings = (char *)malloc(TotalLength); int Offset = 0; for(int i = 0; i < aLines.size(); i++) { int Length = str_length(aLines[i]) + 1; mem_copy(pSettings + Offset, aLines[i], Length); Offset += Length; - mem_free(aLines[i]); + free(aLines[i]); } CDataFileReader Reader; diff -Nru ddnet-11.1.3/src/tools/crapnet.cpp ddnet-11.1.8/src/tools/crapnet.cpp --- ddnet-11.1.3/src/tools/crapnet.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/tools/crapnet.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -79,7 +79,7 @@ } // create new packet - CPacket *p = (CPacket *)mem_alloc(sizeof(CPacket)+Bytes, 1); + CPacket *p = (CPacket *)malloc(sizeof(CPacket) + Bytes); if(net_addr_comp(&From, &Dest) == 0) p->m_SendTo = Src; // from the server @@ -198,7 +198,7 @@ } - mem_free(p); + free(p); } } diff -Nru ddnet-11.1.3/src/tools/dilate.cpp ddnet-11.1.8/src/tools/dilate.cpp --- ddnet-11.1.3/src/tools/dilate.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/tools/dilate.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -62,9 +62,9 @@ return 1; } - pBuffer[0] = (CPixel*)mem_alloc(Png.width*Png.height*sizeof(CPixel), 1); - pBuffer[1] = (CPixel*)mem_alloc(Png.width*Png.height*sizeof(CPixel), 1); - pBuffer[2] = (CPixel*)mem_alloc(Png.width*Png.height*sizeof(CPixel), 1); + pBuffer[0] = (CPixel *)malloc(Png.width * Png.height * sizeof(CPixel)); + pBuffer[1] = (CPixel *)malloc(Png.width * Png.height * sizeof(CPixel)); + pBuffer[2] = (CPixel *)malloc(Png.width * Png.height * sizeof(CPixel)); png_get_data(&Png, (unsigned char *)pBuffer[0]); png_close_file(&Png); diff -Nru ddnet-11.1.3/src/tools/map_replace_image.cpp ddnet-11.1.8/src/tools/map_replace_image.cpp --- ddnet-11.1.3/src/tools/map_replace_image.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/tools/map_replace_image.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -46,7 +46,7 @@ return 0; } - pBuffer = (unsigned char *)mem_alloc(Png.width * Png.height * Png.bpp, 1); + pBuffer = (unsigned char *)malloc(Png.width * Png.height * Png.bpp); png_get_data(&Png, pBuffer); png_close_file(&Png); diff -Nru ddnet-11.1.3/src/tools/tileset_borderadd.cpp ddnet-11.1.8/src/tools/tileset_borderadd.cpp --- ddnet-11.1.3/src/tools/tileset_borderadd.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/tools/tileset_borderadd.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -57,8 +57,8 @@ int w = Png.width; int h = Png.height; - pBuffer[0] = (CPixel*)mem_alloc(w*h*sizeof(CPixel), 1); - pBuffer[1] = (CPixel*)mem_alloc((w+16*4)*(h+16*4)*sizeof(CPixel), 1); + pBuffer[0] = (CPixel *)malloc(w * h * sizeof(CPixel)); + pBuffer[1] = (CPixel *)malloc((w + 16 * 4) * (h + 16 * 4) * sizeof(CPixel)); png_get_data(&Png, (unsigned char *)pBuffer[0]); png_close_file(&Png); diff -Nru ddnet-11.1.3/src/tools/tileset_borderfix.cpp ddnet-11.1.8/src/tools/tileset_borderfix.cpp --- ddnet-11.1.3/src/tools/tileset_borderfix.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/tools/tileset_borderfix.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -69,8 +69,8 @@ int w = Png.width; int h = Png.height; - pBuffer[0] = (CPixel*)mem_alloc(w*h*sizeof(CPixel), 1); - pBuffer[1] = (CPixel*)mem_alloc(w*h*sizeof(CPixel), 1); + pBuffer[0] = (CPixel *)malloc(w * h * sizeof(CPixel)); + pBuffer[1] = (CPixel *)malloc(w * h * sizeof(CPixel)); png_get_data(&Png, (unsigned char *)pBuffer[0]); png_close_file(&Png); diff -Nru ddnet-11.1.3/src/tools/tileset_borderrem.cpp ddnet-11.1.8/src/tools/tileset_borderrem.cpp --- ddnet-11.1.3/src/tools/tileset_borderrem.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/tools/tileset_borderrem.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -57,8 +57,8 @@ int w = Png.width; int h = Png.height; - pBuffer[0] = (CPixel*)mem_alloc(w*h*sizeof(CPixel), 1); - pBuffer[1] = (CPixel*)mem_alloc((w-16*4)*(h-16*4)*sizeof(CPixel), 1); + pBuffer[0] = (CPixel *)malloc(w * h * sizeof(CPixel)); + pBuffer[1] = (CPixel *)malloc((w - 16 * 4) * (h - 16 * 4) * sizeof(CPixel)); png_get_data(&Png, (unsigned char *)pBuffer[0]); png_close_file(&Png); diff -Nru ddnet-11.1.3/src/tools/tileset_borderset.cpp ddnet-11.1.8/src/tools/tileset_borderset.cpp --- ddnet-11.1.3/src/tools/tileset_borderset.cpp 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/src/tools/tileset_borderset.cpp 2018-05-13 20:23:11.000000000 +0000 @@ -49,8 +49,8 @@ int w = Png.width; int h = Png.height; - pBuffer[0] = (CPixel*)mem_alloc(w*h*sizeof(CPixel), 1); - pBuffer[1] = (CPixel*)mem_alloc(w*h*sizeof(CPixel), 1); + pBuffer[0] = (CPixel *)malloc(w * h * sizeof(CPixel)); + pBuffer[1] = (CPixel *)malloc(w * h * sizeof(CPixel)); png_get_data(&Png, (unsigned char *)pBuffer[0]); png_close_file(&Png); diff -Nru ddnet-11.1.3/.travis.yml ddnet-11.1.8/.travis.yml --- ddnet-11.1.3/.travis.yml 2018-04-05 11:48:38.000000000 +0000 +++ ddnet-11.1.8/.travis.yml 2018-05-13 20:23:11.000000000 +0000 @@ -30,3 +30,4 @@ branches: except: - staging.tmp + - testing.tmp