4710: Add some modernize-* clang-tidy checks r=edg-l a=def-

Some of them are now possible with C++ > 11. This includes https://github.com/ddnet/ddnet/pull/4709

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2022-02-15 07:17:06 +00:00 committed by GitHub
commit 218f4a4768
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 223 additions and 236 deletions

View file

@ -40,7 +40,25 @@ Checks: >
-misc-non-private-member-variables-in-classes,
-misc-static-assert,
-misc-unused-parameters,
modernize-avoid-bind,
modernize-concat-nested-namespaces,
modernize-deprecated-headers,
modernize-deprecated-ios-base-aliases,
modernize-loop-convert,
modernize-make-unique,
modernize-make-shared,
modernize-redundant-void-arg,
modernize-replace-auto-ptr,
modernize-replace-disallow-copy-and-assign-macro,
modernize-replace-random-shuffle,
modernize-shrink-to-fit,
modernize-unary-static-assert,
modernize-use-bool-literals,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-transparent-functors,
modernize-use-uncaught-exceptions,
readability-*,
-readability-braces-around-statements,
-readability-convert-member-functions-to-static,

View file

@ -17,8 +17,7 @@ jobs:
os: [ubuntu-latest, macOS-latest, windows-latest, ubuntu-18.04]
include:
- os: ubuntu-latest
cmake-args: -G "Unix Makefiles"
build-args: --parallel
cmake-args: -G Ninja
package-file: DDNet-*-linux_x86_64.tar.xz
fancy: true
env:
@ -26,7 +25,7 @@ jobs:
CXXFLAGS: -Werror
- os: ubuntu-18.04
cmake-path: /usr/bin/
cmake-args: -G "Unix Makefiles"
cmake-args: -G Ninja
package-file: DDNet-*-linux_x86_64.tar.xz
fancy: false
env:
@ -34,8 +33,7 @@ jobs:
CXXFLAGS: -Werror
GTEST_FILTER: -*SQLite*
- os: macOS-latest
cmake-args: -G "Unix Makefiles"
build-args: --parallel
cmake-args: -G Ninja
package-file: DDNet-*-macos.dmg
fancy: false
env:
@ -59,7 +57,7 @@ jobs:
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update -y
sudo apt-get install pkg-config cmake libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev -y
sudo apt-get install pkg-config cmake ninja-build libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev -y
- name: Prepare Linux (fancy)
if: contains(matrix.os, 'ubuntu') && matrix.fancy
@ -80,7 +78,7 @@ jobs:
if: contains(matrix.os, 'macOS')
run: |
brew update || true
brew install pkg-config sdl2 python3
brew install pkg-config sdl2 python3 ninja
brew upgrade freetype
pip3 install dmgbuild
sudo rm -rf /Library/Developer/CommandLineTools

View file

@ -20,11 +20,11 @@ jobs:
- name: Install clang-tidy
run: |
sudo apt-get update -y
sudo apt-get install pkg-config cmake libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev clang-tidy -y
sudo apt-get install pkg-config cmake ninja-build libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev clang-tidy -y
- name: Build with clang-tidy
run: |
mkdir clang-tidy
cd clang-tidy
cmake -G "Unix Makefiles" -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-warnings-as-errors=*" -DCMAKE_C_CLANG_TIDY="clang-tidy;-warnings-as-errors=*" -DCMAKE_BUILD_TYPE=Debug -Werror=dev -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=. ..
cmake --build . --config Debug --parallel --target everything -- --keep-going
cmake -G Ninja -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-warnings-as-errors=*" -DCMAKE_C_CLANG_TIDY="clang-tidy;-warnings-as-errors=*" -DCMAKE_BUILD_TYPE=Debug -Werror=dev -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=. ..
cmake --build . --config Debug --target everything -- -k 0

View file

@ -55,7 +55,7 @@ jobs:
run: |
mkdir release
cd release
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DANTIBOT=ON -DMYSQL=ON -DWEBSOCKETS=ON ..
cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DANTIBOT=ON -DMYSQL=ON -DWEBSOCKETS=ON ..
cmake --build . --config RelWithDebInfo --target everything
- name: Perform CodeQL Analysis

View file

@ -19,11 +19,11 @@ jobs:
- name: Prepare
run: |
sudo apt-get update -y
sudo apt-get install clang-format imagemagick ddnet-tools shellcheck pkg-config cmake libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev pylint3 python3-clang -y
sudo apt-get install clang-format imagemagick ddnet-tools shellcheck pkg-config cmake ninja-build libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev pylint3 python3-clang -y
mkdir release
cd release
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DDOWNLOAD_GTEST=OFF -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=. ..
cmake --build . --config Release --target dilate --parallel
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DDOWNLOAD_GTEST=OFF -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=. ..
cmake --build . --config Release --target dilate
- name: Check clang-format
run: clang-format -version
- name: Check fix_style

View file

@ -184,12 +184,12 @@ endif()
if(NOT MSVC AND NOT HAIKU)
if(CMAKE_VERSION VERSION_LESS 3.1 OR TARGET_OS STREQUAL "mac")
check_cxx_compiler_flag(-std=gnu++11 FLAG_SUPPORTED_std_gnu__11)
if(FLAG_SUPPORTED_std_gnu__11)
check_cxx_compiler_flag(-std=gnu++17 FLAG_SUPPORTED_std_gnu__17)
if(FLAG_SUPPORTED_std_gnu__17)
if(CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17")
else()
set(CMAKE_CXX_FLAGS -std=gnu++11)
set(CMAKE_CXX_FLAGS -std=gnu++17)
endif()
endif()
endif()
@ -2803,7 +2803,7 @@ endforeach()
foreach(target ${TARGETS_OWN})
if((CMAKE_VERSION VERSION_GREATER 3.1 OR CMAKE_VERSION VERSION_EQUAL 3.1) AND NOT TARGET_OS STREQUAL "mac")
set_property(TARGET ${target} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${target} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${target} PROPERTY CXX_STANDARD_REQUIRED ON)
endif()

View file

@ -5,9 +5,9 @@
#include "hash_ctxt.h"
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <cstddef>
#include <cstdint>
#include <cstring>
typedef uint32_t u32;
typedef uint64_t u64;

View file

@ -1,12 +1,12 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <ctype.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <cctype>
#include <cmath>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include "system.h"
#if !defined(CONF_PLATFORM_MACOS)
@ -24,7 +24,7 @@
#endif
#if defined(CONF_FAMILY_UNIX)
#include <signal.h>
#include <csignal>
#include <sys/time.h>
#include <sys/utsname.h>
#include <sys/wait.h>
@ -32,7 +32,7 @@
/* unix net includes */
#include <arpa/inet.h>
#include <errno.h>
#include <cerrno>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
@ -557,7 +557,7 @@ static void aio_thread(void *user)
ASYNCIO *aio = (ASYNCIO *)user;
lock_wait(aio->lock);
while(1)
while(true)
{
struct BUFFERS buffers;
int result_io_error;
@ -1347,7 +1347,7 @@ static int parse_int(int *out, const char **str)
i = **str - '0';
(*str)++;
while(1)
while(true)
{
if(**str < '0' || **str > '9')
{
@ -2727,7 +2727,7 @@ void str_clean_whitespaces(char *str_in)
read++;
/* end of read string is detected in the loop */
while(1)
while(true)
{
/* skip whitespace */
int found_whitespace = 0;
@ -3439,7 +3439,7 @@ int str_utf8_decode(const char **ptr)
int utf8_code_point = 0;
int utf8_bytes_seen = 0;
int utf8_bytes_needed = 0;
while(1)
while(true)
{
unsigned char byte = str_byte_next(ptr);
if(utf8_bytes_needed == 0)
@ -3904,7 +3904,7 @@ int secure_rand_below(int below)
{
unsigned int mask = find_next_power_of_two_minus_one(below);
dbg_assert(below > 0, "below must be positive");
while(1)
while(true)
{
unsigned int n;
secure_random_fill(&n, sizeof(n));
@ -4054,7 +4054,7 @@ int os_version_str(char *version, int length)
*newline = 0;
}
str_format(extra, sizeof(extra), "; %s", buf + offset + 12);
} while(0);
} while(false);
str_format(version, length, "%s %s (%s, %s)%s", u.sysname, u.release, u.machine, u.version, extra);
return 0;

View file

@ -2,7 +2,7 @@
#include "../system.h"
#include <stddef.h>
#include <cstddef>
static int str_utf8_skeleton(int ch, const int **skeleton, int *skeleton_len)
{
@ -88,7 +88,7 @@ int str_utf8_comp_confusable(const char *str1, const char *str2)
str_utf8_skeleton_begin(&skel1, str1);
str_utf8_skeleton_begin(&skel2, str2);
while(1)
while(true)
{
int ch1 = str_utf8_skeleton_next(&skel1);
int ch2 = str_utf8_skeleton_next(&skel2);

View file

@ -1,4 +1,4 @@
#include <stdlib.h>
#include <cstdlib>
#include "tolower_data.h"

View file

@ -1824,7 +1824,7 @@ void CCommandProcessorFragment_OpenGL2::Cmd_CreateBufferObject(const CCommandBuf
{
for(int i = m_BufferObjectIndices.size(); i < Index + 1; ++i)
{
m_BufferObjectIndices.push_back(SBufferObject(0));
m_BufferObjectIndices.emplace_back(0);
}
}

View file

@ -4,9 +4,9 @@
#if defined(BACKEND_AS_OPENGL_ES) || !defined(CONF_BACKEND_OPENGL_ES)
#include <cstdio>
#include <engine/shared/linereader.h>
#include <engine/storage.h>
#include <stdio.h>
#include <string>
#include <vector>
@ -42,18 +42,18 @@ bool CGLSL::LoadShader(CGLSLCompiler *pCompiler, IStorage *pStorage, const char
if(pCompiler->m_OpenGLVersionMajor == 3)
{
if(pCompiler->m_OpenGLVersionMinor == 0)
Lines.push_back(std::string("#version 130 \r\n"));
Lines.emplace_back("#version 130 \r\n");
if(pCompiler->m_OpenGLVersionMinor == 1)
Lines.push_back(std::string("#version 140 \r\n"));
Lines.emplace_back("#version 140 \r\n");
if(pCompiler->m_OpenGLVersionMinor == 2)
Lines.push_back(std::string("#version 150 \r\n"));
Lines.emplace_back("#version 150 \r\n");
}
else if(pCompiler->m_OpenGLVersionMajor == 2)
{
if(pCompiler->m_OpenGLVersionMinor == 0)
Lines.push_back(std::string("#version 110 \r\n"));
Lines.emplace_back("#version 110 \r\n");
if(pCompiler->m_OpenGLVersionMinor == 1)
Lines.push_back(std::string("#version 120 \r\n"));
Lines.emplace_back("#version 120 \r\n");
}
}
@ -61,14 +61,14 @@ bool CGLSL::LoadShader(CGLSLCompiler *pCompiler, IStorage *pStorage, const char
{
if(Type == GL_FRAGMENT_SHADER)
{
Lines.push_back("precision highp float; \r\n");
Lines.push_back("precision highp sampler2D; \r\n");
Lines.push_back("precision highp sampler3D; \r\n");
Lines.push_back("precision highp samplerCube; \r\n");
Lines.push_back("precision highp samplerCubeShadow; \r\n");
Lines.push_back("precision highp sampler2DShadow; \r\n");
Lines.push_back("precision highp sampler2DArray; \r\n");
Lines.push_back("precision highp sampler2DArrayShadow; \r\n");
Lines.emplace_back("precision highp float; \r\n");
Lines.emplace_back("precision highp sampler2D; \r\n");
Lines.emplace_back("precision highp sampler3D; \r\n");
Lines.emplace_back("precision highp samplerCube; \r\n");
Lines.emplace_back("precision highp samplerCubeShadow; \r\n");
Lines.emplace_back("precision highp sampler2DShadow; \r\n");
Lines.emplace_back("precision highp sampler2DArray; \r\n");
Lines.emplace_back("precision highp sampler2DArrayShadow; \r\n");
}
}
@ -79,7 +79,7 @@ bool CGLSL::LoadShader(CGLSLCompiler *pCompiler, IStorage *pStorage, const char
if(Type == GL_FRAGMENT_SHADER && !IsNewOpenGL && pCompiler->m_OpenGLVersionMajor <= 3 && pCompiler->m_HasTextureArray)
{
Lines.push_back(std::string("#extension GL_EXT_texture_array : enable\r\n"));
Lines.emplace_back("#extension GL_EXT_texture_array : enable\r\n");
}
CLineReader LineReader;

View file

@ -72,7 +72,7 @@ void CGLSLProgram::DetachAllShaders()
{
TWGLuint aShaders[100];
GLsizei ReturnedCount = 0;
while(1)
while(true)
{
glGetAttachedShaders(m_ProgramID, 100, &ReturnedCount, aShaders);

View file

@ -18,7 +18,7 @@
#include <base/detect.h>
#include <base/math.h>
#include <cmath>
#include <stdlib.h>
#include <cstdlib>
#include "SDL_hints.h"
#include "SDL_pixels.h"
@ -193,9 +193,7 @@ void CCommandProcessorFragment_SDL::Cmd_WindowDestroyNtf(const CCommandBuffer::S
#endif
}
CCommandProcessorFragment_SDL::CCommandProcessorFragment_SDL()
{
}
CCommandProcessorFragment_SDL::CCommandProcessorFragment_SDL() = default;
bool CCommandProcessorFragment_SDL::RunCommand(const CCommandBuffer::SCommand *pBaseCommand)
{

View file

@ -6,7 +6,7 @@
#include <climits>
#include <new>
#include <stdarg.h>
#include <cstdarg>
#include <tuple>
#include <base/hash_ctxt.h>
@ -376,7 +376,7 @@ CClient::CClient() :
m_CurrentInput[0] = 0;
m_CurrentInput[1] = 0;
m_LastDummy = 0;
m_LastDummy = false;
mem_zero(&m_aInputs, sizeof(m_aInputs));
@ -2518,7 +2518,7 @@ void CClient::Update()
{
// switch dummy snapshot
int64_t Now = m_GameTime[!g_Config.m_ClDummy].Get(time_get());
while(1)
while(true)
{
CSnapshotStorage::CHolder *pCur = m_aSnapshots[!g_Config.m_ClDummy][SNAP_CURRENT];
int64_t TickStart = (pCur->m_Tick) * time_freq() / 50;
@ -2557,7 +2557,7 @@ void CClient::Update()
Repredict = 1;
}
while(1)
while(true)
{
CSnapshotStorage::CHolder *pCur = m_aSnapshots[g_Config.m_ClDummy][SNAP_CURRENT];
int64_t TickStart = (pCur->m_Tick) * time_freq() / 50;
@ -2979,7 +2979,7 @@ void CClient::Run()
int64_t LastTime = time_get_microseconds();
int64_t LastRenderTime = time_get();
while(1)
while(true)
{
set_new_tick();

View file

@ -24,7 +24,7 @@
#include <engine/shared/image_manipulation.h>
#include <math.h> // cosf, sinf, log2f
#include <cmath> // cosf, sinf, log2f
#if defined(CONF_VIDEORECORDER)
#include "video.h"
@ -1252,7 +1252,7 @@ int CGraphics_Threaded::CreateQuadContainer(bool AutomaticUpload)
if(m_FirstFreeQuadContainer == -1)
{
Index = m_QuadContainers.size();
m_QuadContainers.push_back(SQuadContainer(AutomaticUpload));
m_QuadContainers.emplace_back(AutomaticUpload);
}
else
{
@ -1293,7 +1293,7 @@ void CGraphics_Threaded::QuadContainerUpload(int ContainerIndex)
SBufferContainerInfo Info;
Info.m_Stride = sizeof(CCommandBuffer::SVertex);
Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
Info.m_Attributes.emplace_back();
SBufferContainerInfo::SAttribute *pAttr = &Info.m_Attributes.back();
pAttr->m_DataTypeCount = 2;
pAttr->m_FuncType = 0;
@ -1301,7 +1301,7 @@ void CGraphics_Threaded::QuadContainerUpload(int ContainerIndex)
pAttr->m_pOffset = 0;
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex;
Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
Info.m_Attributes.emplace_back();
pAttr = &Info.m_Attributes.back();
pAttr->m_DataTypeCount = 2;
pAttr->m_FuncType = 0;
@ -1309,7 +1309,7 @@ void CGraphics_Threaded::QuadContainerUpload(int ContainerIndex)
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());
Info.m_Attributes.emplace_back();
pAttr = &Info.m_Attributes.back();
pAttr->m_DataTypeCount = 4;
pAttr->m_FuncType = 0;
@ -1333,7 +1333,7 @@ void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CQuadItem *pA
for(int i = 0; i < Num; ++i)
{
Container.m_Quads.push_back(SQuadContainer::SQuad());
Container.m_Quads.emplace_back();
SQuadContainer::SQuad &Quad = Container.m_Quads.back();
Quad.m_aVertices[0].m_Pos.x = pArray[i].m_X;
@ -1379,7 +1379,7 @@ void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CFreeformItem
for(int i = 0; i < Num; ++i)
{
Container.m_Quads.push_back(SQuadContainer::SQuad());
Container.m_Quads.emplace_back();
SQuadContainer::SQuad &Quad = Container.m_Quads.back();
Quad.m_aVertices[0].m_Pos.x = pArray[i].m_X0;
@ -1946,7 +1946,7 @@ int CGraphics_Threaded::CreateBufferContainer(SBufferContainerInfo *pContainerIn
if(m_FirstFreeVertexArrayInfo == -1)
{
Index = m_VertexArrayInfo.size();
m_VertexArrayInfo.push_back(SVertexArrayInfo());
m_VertexArrayInfo.emplace_back();
}
else
{
@ -2420,7 +2420,7 @@ void CGraphics_Threaded::GotResized(int w, int h, int RefreshRate)
void CGraphics_Threaded::AddWindowResizeListener(WINDOW_RESIZE_FUNC pFunc, void *pUser)
{
m_ResizeListeners.push_back(SWindowResizeListener(pFunc, pUser));
m_ResizeListeners.emplace_back(pFunc, pUser);
}
int CGraphics_Threaded::GetWindowScreen()

View file

@ -8,7 +8,7 @@
#include <game/version.h>
#if !defined(CONF_FAMILY_WINDOWS)
#include <signal.h>
#include <csignal>
#endif
#define WIN32_LEAN_AND_MEAN
@ -201,9 +201,7 @@ CHead::CHead(const char *pUrl, CTimeout Timeout, HTTPLOG LogProgress) :
{
}
CHead::~CHead()
{
}
CHead::~CHead() = default;
bool CHead::AfterInit(void *pCurl)
{

View file

@ -6,7 +6,7 @@
#include "serverbrowser_ping_cache.h"
#include <algorithm>
#include <limits.h>
#include <climits>
#include <base/hash_ctxt.h>
#include <base/math.h>
@ -1194,7 +1194,7 @@ void CServerBrowser::Update(bool ForceResort)
CServerEntry *pEntry = m_pFirstReqServer;
int Count = 0;
while(1)
while(true)
{
if(!pEntry) // no more entries
break;
@ -1223,7 +1223,7 @@ void CServerBrowser::Update(bool ForceResort)
{
//reset old ones
pEntry = m_pFirstReqServer;
while(1)
while(true)
{
if(!pEntry) // no more entries
break;
@ -1239,7 +1239,7 @@ void CServerBrowser::Update(bool ForceResort)
else if(Count == 0 && m_CurrentMaxRequests == 1) //we reached the limit, just release all left requests. IF a server sends us a packet, a new request will be added automatically, so we can delete all
{
pEntry = m_pFirstReqServer;
while(1)
while(true)
{
if(!pEntry) // no more entries
break;

View file

@ -6,14 +6,14 @@
#include <sqlite3.h>
#include <algorithm>
#include <stdio.h>
#include <cstdio>
#include <vector>
class CServerBrowserPingCache : public IServerBrowserPingCache
{
public:
CServerBrowserPingCache(IConsole *pConsole, IStorage *pStorage);
virtual ~CServerBrowserPingCache() {}
virtual ~CServerBrowserPingCache() = default;
void Load();

View file

@ -21,7 +21,7 @@ extern "C" {
#include <opusfile.h>
#include <wavpack.h>
}
#include <math.h>
#include <cmath>
enum
{

View file

@ -264,7 +264,7 @@ class CTextRender : public IEngineTextRender
int WordLength(const char *pText)
{
const char *pCursor = pText;
while(1)
while(true)
{
if(*pCursor == 0)
return pCursor - pText;
@ -666,7 +666,7 @@ public:
m_DefaultTextContainerInfo.m_Stride = sizeof(STextCharQuadVertex);
m_DefaultTextContainerInfo.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
m_DefaultTextContainerInfo.m_Attributes.emplace_back();
SBufferContainerInfo::SAttribute *pAttr = &m_DefaultTextContainerInfo.m_Attributes.back();
pAttr->m_DataTypeCount = 2;
pAttr->m_FuncType = 0;
@ -674,7 +674,7 @@ public:
pAttr->m_pOffset = 0;
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
pAttr->m_VertBufferBindingIndex = -1;
m_DefaultTextContainerInfo.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
m_DefaultTextContainerInfo.m_Attributes.emplace_back();
pAttr = &m_DefaultTextContainerInfo.m_Attributes.back();
pAttr->m_DataTypeCount = 2;
pAttr->m_FuncType = 0;
@ -682,7 +682,7 @@ public:
pAttr->m_pOffset = (void *)(sizeof(float) * 2);
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
pAttr->m_VertBufferBindingIndex = -1;
m_DefaultTextContainerInfo.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
m_DefaultTextContainerInfo.m_Attributes.emplace_back();
pAttr = &m_DefaultTextContainerInfo.m_Attributes.back();
pAttr->m_DataTypeCount = 4;
pAttr->m_FuncType = 0;
@ -1267,7 +1267,7 @@ public:
// don't add text that isn't drawn, the color overwrite is used for that
if(m_Color.a != 0.f && IsRendered)
{
TextContainer.m_StringInfo.m_CharacterQuads.push_back(STextCharQuad());
TextContainer.m_StringInfo.m_CharacterQuads.emplace_back();
STextCharQuad &TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads.back();
TextCharQuad.m_Vertices[0].m_X = CharX;
@ -1371,7 +1371,7 @@ public:
if(SelectionStarted && IsRendered)
{
SelectionQuads.push_back(IGraphics::CQuadItem(SelX, DrawY, SelWidth, Size));
SelectionQuads.emplace_back(SelX, DrawY, SelWidth, Size);
}
LastSelX = SelX;

View file

@ -7,7 +7,7 @@
#include <engine/storage.h>
#include <game/version.h>
#include <stdlib.h> // system
#include <cstdlib> // system
using std::map;
using std::string;

View file

@ -195,9 +195,7 @@ CAntibot::CAntibot() :
m_pServer(0), m_pConsole(0), m_pGameServer(0), m_Initialized(false)
{
}
CAntibot::~CAntibot()
{
}
CAntibot::~CAntibot() = default;
void CAntibot::Init()
{
m_pServer = Kernel()->RequestInterface<IServer>();

View file

@ -3,6 +3,8 @@
#include <engine/console.h>
#include <memory>
// helper struct to hold thread data
struct CSqlExecData
{
@ -14,7 +16,7 @@ struct CSqlExecData
CDbConnectionPool::FWrite pFunc,
std::unique_ptr<const ISqlData> pThreadData,
const char *pName);
~CSqlExecData() {}
~CSqlExecData() = default;
enum
{
@ -61,9 +63,7 @@ CDbConnectionPool::CDbConnectionPool() :
thread_init_and_detach(CDbConnectionPool::Worker, this, "database worker thread");
}
CDbConnectionPool::~CDbConnectionPool()
{
}
CDbConnectionPool::~CDbConnectionPool() = default;
void CDbConnectionPool::Print(IConsole *pConsole, Mode DatabaseMode)
{
@ -86,7 +86,7 @@ void CDbConnectionPool::Execute(
std::unique_ptr<const ISqlData> pSqlRequestData,
const char *pName)
{
m_aTasks[FirstElem++].reset(new CSqlExecData(pFunc, std::move(pSqlRequestData), pName));
m_aTasks[FirstElem++] = std::make_unique<CSqlExecData>(pFunc, std::move(pSqlRequestData), pName);
FirstElem %= sizeof(m_aTasks) / sizeof(m_aTasks[0]);
m_NumElem.Signal();
}
@ -96,7 +96,7 @@ void CDbConnectionPool::ExecuteWrite(
std::unique_ptr<const ISqlData> pSqlRequestData,
const char *pName)
{
m_aTasks[FirstElem++].reset(new CSqlExecData(pFunc, std::move(pSqlRequestData), pName));
m_aTasks[FirstElem++] = std::make_unique<CSqlExecData>(pFunc, std::move(pSqlRequestData), pName);
FirstElem %= sizeof(m_aTasks) / sizeof(m_aTasks[0]);
m_NumElem.Signal();
}
@ -130,7 +130,7 @@ void CDbConnectionPool::Worker()
// enter fail mode when a sql request fails, skip read request during it and
// write to the backup database until all requests are handled
bool FailMode = false;
while(1)
while(true)
{
if(FailMode && m_NumElem.GetApproximateValue() == 0)
{

View file

@ -48,7 +48,7 @@
#include <windows.h>
#endif
#include <signal.h>
#include <csignal>
volatile sig_atomic_t InterruptSignaled = 0;

View file

@ -159,7 +159,7 @@ int CConsole::ParseArgs(CResult *pResult, const char *pFormat)
pStr = pResult->m_pArgsStart;
while(1)
while(true)
{
if(!Command)
break;
@ -198,7 +198,7 @@ int CConsole::ParseArgs(CResult *pResult, const char *pFormat)
pResult->AddArgument(pStr);
pDst = pStr; // we might have to process escape data
while(1)
while(true)
{
if(pStr[0] == '"')
break;

View file

@ -126,7 +126,7 @@ bool CDataFileReader::Open(class IStorage *pStorage, const char *pFilename, int
sha256_init(&Sha256Ctxt);
unsigned char aBuffer[BUFFER_SIZE];
while(1)
while(true)
{
unsigned Bytes = io_read(File, aBuffer, BUFFER_SIZE);
if(Bytes <= 0)
@ -144,14 +144,14 @@ bool CDataFileReader::Open(class IStorage *pStorage, const char *pFilename, int
if(sizeof(Header) != io_read(File, &Header, sizeof(Header)))
{
dbg_msg("datafile", "couldn't load header");
return 0;
return false;
}
if(Header.m_aID[0] != 'A' || Header.m_aID[1] != 'T' || Header.m_aID[2] != 'A' || Header.m_aID[3] != 'D')
{
if(Header.m_aID[0] != 'D' || Header.m_aID[1] != 'A' || Header.m_aID[2] != 'T' || Header.m_aID[3] != 'A')
{
dbg_msg("datafile", "wrong signature. %x %x %x %x", Header.m_aID[0], Header.m_aID[1], Header.m_aID[2], Header.m_aID[3]);
return 0;
return false;
}
}
@ -161,7 +161,7 @@ bool CDataFileReader::Open(class IStorage *pStorage, const char *pFilename, int
if(Header.m_Version != 3 && Header.m_Version != 4)
{
dbg_msg("datafile", "wrong version. version=%x", Header.m_Version);
return 0;
return false;
}
// read in the rest except the data

View file

@ -152,7 +152,7 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con
else
{
// write map data
while(1)
while(true)
{
unsigned char aChunk[1024 * 64];
int Bytes = io_read(MapFile, &aChunk, sizeof(aChunk));
@ -373,7 +373,7 @@ void CDemoRecorder::AddDemoMarker()
if(m_NumTimelineMarkers > 0)
{
int Diff = m_LastTickMarker - m_aTimelineMarkers[m_NumTimelineMarkers - 1];
if(Diff < SERVER_TICK_SPEED * 1.0f)
if(Diff < (float)SERVER_TICK_SPEED)
return;
}
@ -487,7 +487,7 @@ void CDemoPlayer::ScanFile()
StartPos = io_tell(m_File);
m_Info.m_SeekablePoints = 0;
while(1)
while(true)
{
long CurrentPos = io_tell(m_File);
@ -554,7 +554,7 @@ void CDemoPlayer::DoTick()
if(m_UpdateIntraTimesFunc)
m_UpdateIntraTimesFunc();
while(1)
while(true)
{
if(ReadChunkHeader(&ChunkType, &ChunkSize, &ChunkTick))
{
@ -672,7 +672,7 @@ void CDemoPlayer::DoTick()
void CDemoPlayer::Pause()
{
m_Info.m_Info.m_Paused = 1;
m_Info.m_Info.m_Paused = true;
#if defined(CONF_VIDEORECORDER)
if(IVideo::Current() && g_Config.m_ClVideoPauseWithDemo)
IVideo::Current()->Pause(true);
@ -685,7 +685,7 @@ void CDemoPlayer::Unpause()
{
/*m_Info.start_tick = m_Info.current_tick;
m_Info.start_time = time_get();*/
m_Info.m_Info.m_Paused = 0;
m_Info.m_Info.m_Paused = false;
}
#if defined(CONF_VIDEORECORDER)
if(IVideo::Current() && g_Config.m_ClVideoPauseWithDemo)
@ -924,7 +924,7 @@ int CDemoPlayer::SeekPercent(float Percent)
int CDemoPlayer::SeekTime(float Seconds)
{
int WantedTick = m_Info.m_Info.m_CurrentTick + (Seconds * SERVER_TICK_SPEED);
int WantedTick = m_Info.m_Info.m_CurrentTick + (Seconds * (float)SERVER_TICK_SPEED);
return SetPos(WantedTick);
}
@ -991,7 +991,7 @@ int CDemoPlayer::Update(bool RealTime)
int64_t Freq = time_freq();
m_Info.m_CurrentTime += (int64_t)(Deltatime * (double)m_Info.m_Info.m_Speed);
while(1)
while(true)
{
int64_t CurtickStart = (m_Info.m_Info.m_CurrentTick) * Freq / SERVER_TICK_SPEED;

View file

@ -9,9 +9,7 @@
#include <engine/shared/network.h>
#include <engine/storage.h>
CHostLookup::CHostLookup()
{
}
CHostLookup::CHostLookup() = default;
CHostLookup::CHostLookup(const char *pHostname, int Nettype)
{

View file

@ -5,8 +5,8 @@
#include <engine/shared/config.h>
#include <cstdlib>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

View file

@ -211,7 +211,7 @@ int CHuffman::Decompress(const void *pInput, int InputSize, void *pOutput, int O
CNode *pEof = &m_aNodes[HUFFMAN_EOF_SYMBOL];
CNode *pNode = 0;
while(1)
while(true)
{
// {A} try to load a node now, this will reduce dependency at location {D}
pNode = 0;
@ -246,7 +246,7 @@ int CHuffman::Decompress(const void *pInput, int InputSize, void *pOutput, int O
Bitcount -= HUFFMAN_LUTBITS;
// walk the tree bit by bit
while(1)
while(true)
{
// traverse tree
pNode = &m_aNodes[pNode->m_aLeafs[Bits & 1]];

View file

@ -18,9 +18,7 @@ IJob &IJob::operator=(const IJob &Other)
return *this;
}
IJob::~IJob()
{
}
IJob::~IJob() = default;
int IJob::Status()
{

View file

@ -15,7 +15,7 @@ char *CLineReader::Get()
unsigned LineStart = m_BufferPos;
bool CRLFBreak = false;
while(1)
while(true)
{
if(m_BufferPos >= m_BufferSize)
{

View file

@ -3,9 +3,7 @@
#include "map.h"
#include <engine/storage.h>
CMap::CMap()
{
}
CMap::CMap() = default;
void *CMap::GetData(int Index)
{

View file

@ -1,6 +1,6 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <stdio.h> // sscanf
#include <cstdio> // sscanf
#include <base/system.h>
@ -155,7 +155,7 @@ public:
CLineReader LineReader;
LineReader.Init(File);
while(1)
while(true)
{
CMasterInfo Info = {{0}};
const char *pLine = LineReader.Get();

View file

@ -26,7 +26,7 @@ int CNetRecvUnpacker::FetchChunk(CNetChunk *pChunk)
CNetChunkHeader Header;
unsigned char *pEnd = m_Data.m_aChunkData + m_Data.m_DataSize;
while(1)
while(true)
{
unsigned char *pData = m_Data.m_aChunkData;

View file

@ -57,7 +57,7 @@ int CNetClient::ResetErrorString()
int CNetClient::Recv(CNetChunk *pChunk)
{
while(1)
while(true)
{
// check for a chunk
if(m_RecvUnpacker.FetchChunk(pChunk))

View file

@ -68,7 +68,7 @@ void CNetConnection::Init(NETSOCKET Socket, bool BlockCloseMsg)
void CNetConnection::AckChunks(int Ack)
{
while(1)
while(true)
{
CNetChunkResend *pResend = m_Buffer.First();
if(!pResend)

View file

@ -627,7 +627,7 @@ static bool IsDDNetControlMsg(const CNetPacketConstruct *pPacket)
*/
int CNetServer::Recv(CNetChunk *pChunk, SECURITY_TOKEN *pResponseToken)
{
while(1)
while(true)
{
NETADDR Addr;

View file

@ -66,7 +66,7 @@ void *CRingBufferBase::Allocate(int Size)
if(WantedSize > m_Size)
return 0;
while(1)
while(true)
{
// check for space
if(m_pProduce->m_Free)
@ -153,7 +153,7 @@ void *CRingBufferBase::Prev(void *pCurrent)
{
CItem *pItem = ((CItem *)pCurrent) - 1;
while(1)
while(true)
{
pItem = PrevBlock(pItem);
if(pItem == m_pProduce)
@ -167,7 +167,7 @@ void *CRingBufferBase::Next(void *pCurrent)
{
CItem *pItem = ((CItem *)pCurrent) - 1;
while(1)
while(true)
{
pItem = NextBlock(pItem);
if(pItem == m_pProduce)

View file

@ -3,7 +3,7 @@
#include <base/hash_ctxt.h>
#include <engine/shared/packer.h>
#include <stdio.h>
#include <cstdio>
static const CUuid TEEWORLDS_NAMESPACE = {{// "e05ddaaa-c4e6-4cfb-b642-5d48e80c0029"
0xe0, 0x5d, 0xda, 0xaa, 0xc4, 0xe6, 0x4c, 0xfb,
@ -67,8 +67,7 @@ int ParseUuid(CUuid *pUuid, const char *pBuffer)
return 1;
}
aCopy[8] = aCopy[13] = aCopy[18] = aCopy[23] = 0;
if(0 ||
str_hex_decode(pUuid->m_aData + 0, 4, aCopy + 0) ||
if(static_cast<bool>(str_hex_decode(pUuid->m_aData + 0, 4, aCopy + 0)) ||
str_hex_decode(pUuid->m_aData + 4, 2, aCopy + 9) ||
str_hex_decode(pUuid->m_aData + 6, 2, aCopy + 14) ||
str_hex_decode(pUuid->m_aData + 8, 2, aCopy + 19) ||

View file

@ -683,7 +683,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
if(*p == 0)
return;
auto &&FChatMsgCheckAndPrint = [=](CLine *pLine) {
auto &&FChatMsgCheckAndPrint = [this](CLine *pLine) {
if(pLine->m_ClientID < 0) // server or client message
{
if(Client()->State() != IClient::STATE_DEMOPLAYBACK)

View file

@ -3,9 +3,9 @@
#include <base/tl/sorted_array.h>
#include <limits.h>
#include <climits>
#include <cmath>
#include <limits>
#include <math.h>
#include <game/generated/client_data.h>

View file

@ -339,12 +339,12 @@ bool AddTile(std::vector<SGraphicTile> &TmpTiles, std::vector<SGraphicTileTexure
{
if(Index)
{
TmpTiles.push_back(SGraphicTile());
TmpTiles.emplace_back();
SGraphicTile &Tile = TmpTiles.back();
SGraphicTileTexureCoords *pTileTex = NULL;
if(DoTextureCoords)
{
TmpTileTexCoords.push_back(SGraphicTileTexureCoords());
TmpTileTexCoords.emplace_back();
SGraphicTileTexureCoords &TileTex = TmpTileTexCoords.back();
pTileTex = &TileTex;
}
@ -844,7 +844,7 @@ void CMapLayers::OnMapLoad()
// then create the buffer container
SBufferContainerInfo ContainerInfo;
ContainerInfo.m_Stride = (DoTextureCoords ? (sizeof(float) * 2 + sizeof(vec3)) : 0);
ContainerInfo.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
ContainerInfo.m_Attributes.emplace_back();
SBufferContainerInfo::SAttribute *pAttr = &ContainerInfo.m_Attributes.back();
pAttr->m_DataTypeCount = 2;
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
@ -854,7 +854,7 @@ void CMapLayers::OnMapLoad()
pAttr->m_VertBufferBindingIndex = BufferObjectIndex;
if(DoTextureCoords)
{
ContainerInfo.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
ContainerInfo.m_Attributes.emplace_back();
pAttr = &ContainerInfo.m_Attributes.back();
pAttr->m_DataTypeCount = 3;
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
@ -948,7 +948,7 @@ void CMapLayers::OnMapLoad()
// then create the buffer container
SBufferContainerInfo ContainerInfo;
ContainerInfo.m_Stride = (Textured ? (sizeof(STmpQuadTextured) / 4) : (sizeof(STmpQuad) / 4));
ContainerInfo.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
ContainerInfo.m_Attributes.emplace_back();
SBufferContainerInfo::SAttribute *pAttr = &ContainerInfo.m_Attributes.back();
pAttr->m_DataTypeCount = 4;
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
@ -956,7 +956,7 @@ void CMapLayers::OnMapLoad()
pAttr->m_pOffset = 0;
pAttr->m_FuncType = 0;
pAttr->m_VertBufferBindingIndex = BufferObjectIndex;
ContainerInfo.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
ContainerInfo.m_Attributes.emplace_back();
pAttr = &ContainerInfo.m_Attributes.back();
pAttr->m_DataTypeCount = 4;
pAttr->m_Type = GRAPHICS_TYPE_UNSIGNED_BYTE;
@ -966,7 +966,7 @@ void CMapLayers::OnMapLoad()
pAttr->m_VertBufferBindingIndex = BufferObjectIndex;
if(Textured)
{
ContainerInfo.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
ContainerInfo.m_Attributes.emplace_back();
pAttr = &ContainerInfo.m_Attributes.back();
pAttr->m_DataTypeCount = 2;
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;

View file

@ -390,9 +390,9 @@ std::vector<CTheme> &CMenuBackground::GetThemes()
if(m_lThemes.empty()) // not loaded yet
{
// when adding more here, make sure to change the value of PREDEFINED_THEMES_COUNT too
m_lThemes.push_back(CTheme("", true, true)); // no theme
m_lThemes.push_back(CTheme("auto", true, true)); // auto theme
m_lThemes.push_back(CTheme("rand", true, true)); // random theme
m_lThemes.emplace_back("", true, true); // no theme
m_lThemes.emplace_back("auto", true, true); // auto theme
m_lThemes.emplace_back("rand", true, true); // random theme
Storage()->ListDirectory(IStorage::TYPE_ALL, "themes", ThemeScan, (CMenuBackground *)this);
Storage()->ListDirectory(IStorage::TYPE_ALL, "themes", ThemeIconScan, (CMenuBackground *)this);

View file

@ -5,7 +5,7 @@
#include <base/tl/array.h>
#include <math.h>
#include <cmath>
#include <base/math.h>
#include <base/system.h>

View file

@ -1449,7 +1449,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
class CLanguage
{
public:
CLanguage() {}
CLanguage() = default;
CLanguage(const char *n, const char *f, int Code) :
m_Name(n), m_FileName(f), m_CountryCode(Code) {}

View file

@ -200,7 +200,7 @@ void CPlayers::RenderPlayer(
AttackTime = (Client()->PredIntraGameTick(g_Config.m_ClDummy) + (Client()->PredGameTick(g_Config.m_ClDummy) - 1 - Player.m_AttackTick)) / (float)SERVER_TICK_SPEED;
LastAttackTime = (s_LastPredIntraTick + (Client()->PredGameTick(g_Config.m_ClDummy) - 1 - Player.m_AttackTick)) / (float)SERVER_TICK_SPEED;
}
float AttackTicksPassed = AttackTime * SERVER_TICK_SPEED;
float AttackTicksPassed = AttackTime * (float)SERVER_TICK_SPEED;
float Angle;
if(Local && Client()->State() != IClient::STATE_DEMOPLAYBACK)

View file

@ -1,6 +1,6 @@
/* (c) Redix and Sushi */
#include <ctype.h>
#include <cctype>
#include <base/system.h>
#include <engine/serverbrowser.h>

View file

@ -1,6 +1,6 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <math.h>
#include <cmath>
#include <base/math.h>
#include <base/system.h>

View file

@ -1,7 +1,7 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <limits.h>
#include <climits>
#include <engine/demo.h>
#include <engine/graphics.h>

View file

@ -1074,7 +1074,7 @@ void CGameClient::InvalidateSnapshot()
void CGameClient::OnNewSnapshot()
{
auto &&Evolve = [=](CNetObj_Character *pCharacter, int Tick) {
auto &&Evolve = [this](CNetObj_Character *pCharacter, int Tick) {
CWorldCore TempWorld;
CCharacterCore TempCore;
CTeamsCore TempTeams;
@ -1344,8 +1344,8 @@ void CGameClient::OnNewSnapshot()
}
else if(Item.m_Type == NETOBJTYPE_GAMEINFO)
{
static bool s_GameOver = 0;
static bool s_GamePaused = 0;
static bool s_GameOver = false;
static bool s_GamePaused = false;
m_Snap.m_pGameInfoObj = (const CNetObj_GameInfo *)pData;
bool CurrentTickGameOver = (bool)(m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_GAMEOVER);
if(!s_GameOver && CurrentTickGameOver)
@ -1813,7 +1813,7 @@ void CGameClient::OnPredict()
// detect mispredictions of other players and make corrections smoother when possible
static vec2 s_aLastPos[MAX_CLIENTS] = {{0, 0}};
static bool s_aLastActive[MAX_CLIENTS] = {0};
static bool s_aLastActive[MAX_CLIENTS] = {false};
if(g_Config.m_ClAntiPingSmooth && Predict() && AntiPingPlayers() && m_NewTick && abs(m_PredictedTick - Client()->PredGameTick(g_Config.m_ClDummy)) <= 1 && abs(Client()->GameTick(g_Config.m_ClDummy) - Client()->PrevGameTick(g_Config.m_ClDummy)) <= 2)
{
@ -2622,7 +2622,7 @@ int CGameClient::SwitchStateTeam()
bool CGameClient::IsLocalCharSuper()
{
if(m_Snap.m_LocalClientID < 0)
return 0;
return false;
return m_aClients[m_Snap.m_LocalClientID].m_Super;
}

View file

@ -369,8 +369,8 @@ void CCharacter::FireWeapon()
ProjStartPos, //Pos
Direction, //Dir
Lifetime, //Span
0, //Freeze
0, //Explosive
false, //Freeze
false, //Explosive
0, //Force
-1 //SoundImpact
);
@ -397,8 +397,8 @@ void CCharacter::FireWeapon()
ProjStartPos, //Pos
vec2(cosf(a), sinf(a)) * Speed, //Dir
(int)(GameWorld()->GameTickSpeed() * Tuning()->m_ShotgunLifetime), //Span
0, //Freeze
0, //Explosive
false, //Freeze
false, //Explosive
0, //Force
-1 //SoundImpact
);
@ -424,7 +424,7 @@ void CCharacter::FireWeapon()
ProjStartPos, //Pos
Direction, //Dir
Lifetime, //Span
0, //Freeze
false, //Freeze
true, //Explosive
0, //Force
SOUND_GRENADE_EXPLODE //SoundImpact
@ -1064,7 +1064,7 @@ CCharacter::CCharacter(CGameWorld *pGameWorld, int ID, CNetObj_Character *pChar,
mem_zero(&m_SavedInput, sizeof(m_SavedInput));
m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
m_ProximityRadius = ms_PhysSize;
m_Core.m_LeftWall = 1;
m_Core.m_LeftWall = true;
m_ReloadTimer = 0;
m_NumObjectsHit = 0;
m_LastRefillJumps = false;
@ -1101,8 +1101,8 @@ void CCharacter::ResetPrediction()
m_NumInputs = 0;
m_FreezeTime = 0;
m_FreezeTick = 0;
m_DeepFreeze = 0;
m_LiveFreeze = 0;
m_DeepFreeze = false;
m_LiveFreeze = false;
m_FrozenLastTick = false;
m_Super = false;
for(int w = 0; w < NUM_WEAPONS; w++)

View file

@ -173,7 +173,7 @@ CProjectile::CProjectile(CGameWorld *pGameWorld, int ID, CProjectileData *pProj,
{
m_Owner = -1;
m_Bouncing = 0;
m_Freeze = 0;
m_Freeze = false;
m_Explosive = (pProj->m_Type == WEAPON_GRENADE) && (fabs(1.0f - length(m_Direction)) < 0.015f);
}
m_Type = pProj->m_Type;

View file

@ -1,4 +1,4 @@
#include <ctype.h>
#include <cctype>
#include <list>
#include <base/math.h>

View file

@ -1,6 +1,6 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <math.h>
#include <cmath>
#include <base/math.h>

View file

@ -1,8 +1,8 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <base/math.h>
#include <cmath>
#include <engine/graphics.h>
#include <math.h>
#include "render.h"

View file

@ -6,9 +6,9 @@
#include <antibot/antibot_data.h>
#include <cmath>
#include <engine/kernel.h>
#include <engine/map.h>
#include <math.h>
#include <game/collision.h>
#include <game/layers.h>

View file

@ -1,5 +1,5 @@
#include <inttypes.h>
#include <stdio.h> // sscanf
#include <cinttypes>
#include <cstdio> // sscanf
#include <engine/console.h>
#include <engine/shared/linereader.h>

View file

@ -9,9 +9,7 @@ CLayerGame::CLayerGame(int w, int h) :
m_Game = 1;
}
CLayerGame::~CLayerGame()
{
}
CLayerGame::~CLayerGame() = default;
CTile CLayerGame::GetTile(int x, int y)
{

View file

@ -17,9 +17,7 @@ CLayerQuads::CLayerQuads()
m_Image = -1;
}
CLayerQuads::~CLayerQuads()
{
}
CLayerQuads::~CLayerQuads() = default;
void CLayerQuads::Render(bool QuadPicker)
{

View file

@ -12,9 +12,7 @@ CLayerSounds::CLayerSounds()
m_Sound = -1;
}
CLayerSounds::~CLayerSounds()
{
}
CLayerSounds::~CLayerSounds() = default;
void CLayerSounds::Render(bool Tileset)
{

View file

@ -182,7 +182,7 @@ void CCharacterCore::Tick(bool UseInput)
m_HookPos = m_Pos + TargetDirection * PhysSize * 1.5f;
m_HookDir = TargetDirection;
m_HookedPlayer = -1;
m_HookTick = SERVER_TICK_SPEED * (1.25f - m_Tuning.m_HookDuration);
m_HookTick = (float)SERVER_TICK_SPEED * (1.25f - m_Tuning.m_HookDuration);
m_TriggeredEvents |= COREEVENT_HOOK_LAUNCH;
}
}

View file

@ -484,8 +484,8 @@ void CCharacter::FireWeapon()
ProjStartPos, //Pos
Direction, //Dir
Lifetime, //Span
0, //Freeze
0, //Explosive
false, //Freeze
false, //Explosive
0, //Force
-1 //SoundImpact
);
@ -541,7 +541,7 @@ void CCharacter::FireWeapon()
ProjStartPos, //Pos
Direction, //Dir
Lifetime, //Span
0, //Freeze
false, //Freeze
true, //Explosive
0, //Force
SOUND_GRENADE_EXPLODE //SoundImpact

View file

@ -6,6 +6,7 @@
#include "teeinfo.h"
#include <antibot/antibot_data.h>
#include <base/math.h>
#include <cstring>
#include <engine/console.h>
#include <engine/engine.h>
#include <engine/map.h>
@ -18,7 +19,6 @@
#include <game/collision.h>
#include <game/gamecore.h>
#include <game/version.h>
#include <string.h>
#include <game/generated/protocol7.h>
#include <game/generated/protocolglue.h>
@ -648,8 +648,8 @@ void CGameContext::SendVoteStatus(int ClientID, int Total, int Yes, int No)
if(Total > VANILLA_MAX_CLIENTS && m_apPlayers[ClientID] && m_apPlayers[ClientID]->GetClientVersion() <= VERSION_DDRACE)
{
Yes = float(Yes) * VANILLA_MAX_CLIENTS / float(Total);
No = float(No) * VANILLA_MAX_CLIENTS / float(Total);
Yes = float(Yes * VANILLA_MAX_CLIENTS) / float(Total);
No = float(No * VANILLA_MAX_CLIENTS) / float(Total);
Total = VANILLA_MAX_CLIENTS;
}
@ -3872,7 +3872,7 @@ void CGameContext::Whisper(int ClientID, char *pStr)
pName = pStr;
char *pDst = pStr; // we might have to process escape data
while(1)
while(true)
{
if(pStr[0] == '"')
{
@ -3911,7 +3911,7 @@ void CGameContext::Whisper(int ClientID, char *pStr)
else
{
pName = pStr;
while(1)
while(true)
{
if(pStr[0] == 0)
{

View file

@ -45,9 +45,7 @@ IGameController::IGameController(class CGameContext *pGameServer)
m_CurrentRecord = 0;
}
IGameController::~IGameController()
{
}
IGameController::~IGameController() = default;
void IGameController::DoActivityCheck()
{

View file

@ -21,10 +21,7 @@ CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) :
InitTeleporter();
}
CGameControllerDDRace::~CGameControllerDDRace()
{
// Nothing to clean
}
CGameControllerDDRace::~CGameControllerDDRace() = default;
CScore *CGameControllerDDRace::Score()
{

View file

@ -106,7 +106,7 @@ void CPlayer::Reset()
m_ShowOthers = g_Config.m_SvShowOthersDefault;
m_ShowAll = g_Config.m_SvShowAllDefault;
m_ShowDistance = vec2(1200, 800);
m_SpecTeam = 0;
m_SpecTeam = false;
m_NinjaJetpack = false;
m_Paused = PAUSE_NONE;

View file

@ -9,13 +9,7 @@
#include "teams.h"
#include <engine/shared/config.h>
CSaveTee::CSaveTee()
{
}
CSaveTee::~CSaveTee()
{
}
CSaveTee::CSaveTee() = default;
void CSaveTee::Save(CCharacter *pChr)
{

View file

@ -14,7 +14,7 @@ class CSaveTee
{
public:
CSaveTee();
~CSaveTee();
~CSaveTee() = default;
void Save(CCharacter *pchr);
void Load(CCharacter *pchr, int Team, bool IsSwap = false);
char *GetString(const CSaveTeam *pTeam);

View file

@ -18,6 +18,7 @@
#include <algorithm>
#include <cstring>
#include <fstream>
#include <memory>
#include <random>
std::shared_ptr<CScorePlayerResult> CScore::NewSqlPlayerResult(int ClientID)
@ -39,7 +40,7 @@ void CScore::ExecPlayerThread(
auto pResult = NewSqlPlayerResult(ClientID);
if(pResult == nullptr)
return;
auto Tmp = std::unique_ptr<CSqlPlayerRequest>(new CSqlPlayerRequest(pResult));
auto Tmp = std::make_unique<CSqlPlayerRequest>(pResult);
str_copy(Tmp->m_aName, pName, sizeof(Tmp->m_aName));
str_copy(Tmp->m_aMap, g_Config.m_SvMap, sizeof(Tmp->m_aMap));
str_copy(Tmp->m_aServer, g_Config.m_SvSqlServerName, sizeof(Tmp->m_aServer));
@ -78,7 +79,7 @@ CScore::CScore(CGameContext *pGameServer, CDbConnectionPool *pPool) :
m_pServer(pGameServer->Server())
{
auto InitResult = std::make_shared<CScoreInitResult>();
auto Tmp = std::unique_ptr<CSqlInitData>(new CSqlInitData(InitResult));
auto Tmp = std::make_unique<CSqlInitData>(InitResult);
((CGameControllerDDRace *)(pGameServer->m_pController))->m_pInitResult = InitResult;
str_copy(Tmp->m_aMap, g_Config.m_SvMap, sizeof(Tmp->m_aMap));
@ -97,7 +98,7 @@ CScore::CScore(CGameContext *pGameServer, CDbConnectionPool *pPool) :
char aWord[32] = {0};
sscanf(pLine, "%*s %31s", aWord);
aWord[31] = 0;
m_aWordlist.push_back(aWord);
m_aWordlist.emplace_back(aWord);
}
io_close(File);
}
@ -146,7 +147,7 @@ void CScore::SaveScore(int ClientID, float Time, const char *pTimestamp, float C
if(pCurPlayer->m_ScoreFinishResult != nullptr)
dbg_msg("sql", "WARNING: previous save score result didn't complete, overwriting it now");
pCurPlayer->m_ScoreFinishResult = std::make_shared<CScorePlayerResult>();
auto Tmp = std::unique_ptr<CSqlScoreData>(new CSqlScoreData(pCurPlayer->m_ScoreFinishResult));
auto Tmp = std::make_unique<CSqlScoreData>(pCurPlayer->m_ScoreFinishResult);
str_copy(Tmp->m_aMap, g_Config.m_SvMap, sizeof(Tmp->m_aMap));
FormatUuid(GameServer()->GameUuid(), Tmp->m_aGameUuid, sizeof(Tmp->m_aGameUuid));
Tmp->m_ClientID = ClientID;
@ -169,7 +170,7 @@ void CScore::SaveTeamScore(int *pClientIDs, unsigned int Size, float Time, const
if(GameServer()->m_apPlayers[pClientIDs[i]]->m_NotEligibleForFinish)
return;
}
auto Tmp = std::unique_ptr<CSqlTeamScoreData>(new CSqlTeamScoreData());
auto Tmp = std::make_unique<CSqlTeamScoreData>();
for(unsigned int i = 0; i < Size; i++)
str_copy(Tmp->m_aaNames[i], Server()->ClientName(pClientIDs[i]), sizeof(Tmp->m_aaNames[i]));
Tmp->m_Size = Size;
@ -249,7 +250,7 @@ void CScore::RandomMap(int ClientID, int Stars)
auto pResult = std::make_shared<CScoreRandomMapResult>(ClientID);
GameServer()->m_SqlRandomMapResult = pResult;
auto Tmp = std::unique_ptr<CSqlRandomMapRequest>(new CSqlRandomMapRequest(pResult));
auto Tmp = std::make_unique<CSqlRandomMapRequest>(pResult);
Tmp->m_Stars = Stars;
str_copy(Tmp->m_aCurrentMap, g_Config.m_SvMap, sizeof(Tmp->m_aCurrentMap));
str_copy(Tmp->m_aServerType, g_Config.m_SvServerType, sizeof(Tmp->m_aServerType));
@ -263,7 +264,7 @@ void CScore::RandomUnfinishedMap(int ClientID, int Stars)
auto pResult = std::make_shared<CScoreRandomMapResult>(ClientID);
GameServer()->m_SqlRandomMapResult = pResult;
auto Tmp = std::unique_ptr<CSqlRandomMapRequest>(new CSqlRandomMapRequest(pResult));
auto Tmp = std::make_unique<CSqlRandomMapRequest>(pResult);
Tmp->m_Stars = Stars;
str_copy(Tmp->m_aCurrentMap, g_Config.m_SvMap, sizeof(Tmp->m_aCurrentMap));
str_copy(Tmp->m_aServerType, g_Config.m_SvServerType, sizeof(Tmp->m_aServerType));
@ -288,7 +289,7 @@ void CScore::SaveTeam(int ClientID, const char *Code, const char *Server)
return;
pController->m_Teams.SetSaving(Team, SaveResult);
auto Tmp = std::unique_ptr<CSqlTeamSave>(new CSqlTeamSave(SaveResult));
auto Tmp = std::make_unique<CSqlTeamSave>(SaveResult);
str_copy(Tmp->m_aCode, Code, sizeof(Tmp->m_aCode));
str_copy(Tmp->m_aMap, g_Config.m_SvMap, sizeof(Tmp->m_aMap));
str_copy(Tmp->m_aServer, Server, sizeof(Tmp->m_aServer));
@ -321,7 +322,7 @@ void CScore::LoadTeam(const char *Code, int ClientID)
auto SaveResult = std::make_shared<CScoreSaveResult>(ClientID, pController);
SaveResult->m_Status = CScoreSaveResult::LOAD_FAILED;
pController->m_Teams.SetSaving(Team, SaveResult);
auto Tmp = std::unique_ptr<CSqlTeamLoad>(new CSqlTeamLoad(SaveResult));
auto Tmp = std::make_unique<CSqlTeamLoad>(SaveResult);
str_copy(Tmp->m_aCode, Code, sizeof(Tmp->m_aCode));
str_copy(Tmp->m_aMap, g_Config.m_SvMap, sizeof(Tmp->m_aMap));
Tmp->m_ClientID = ClientID;

View file

@ -482,7 +482,7 @@ bool CScoreWorker::SaveTeamScore(IDbConnection *pSqlServer, const ISqlData *pGam
// get the names sorted in a tab separated string
std::vector<std::string> aNames;
for(unsigned int i = 0; i < pData->m_Size; i++)
aNames.push_back(pData->m_aaNames[i]);
aNames.emplace_back(pData->m_aaNames[i]);
std::sort(aNames.begin(), aNames.end());
str_format(aBuf, sizeof(aBuf),

View file

@ -380,7 +380,7 @@ int main(int argc, const char **argv) // ignore_convention
dbg_msg("mastersrv", "started");
while(1)
while(true)
{
m_NetOp.Update();
m_NetChecker.Update();

View file

@ -2,7 +2,7 @@
#include <steam/steam_api_flat.h>
#include <stdlib.h>
#include <cstdlib>
extern "C" {

View file

@ -53,7 +53,7 @@ void Run(unsigned short Port, NETADDR Dest)
MMSGS m;
net_init_mmsgs(&m);
while(1)
while(true)
{
static int Lastcfg = 0;
int n = ((time_get() / time_freq()) / m_ConfigInterval) % m_ConfigNumpingconfs;
@ -64,7 +64,7 @@ void Run(unsigned short Port, NETADDR Dest)
Lastcfg = n;
// handle incoming packets
while(1)
while(true)
{
// fetch data
int DataTrash = 0;
@ -142,7 +142,7 @@ void Run(unsigned short Port, NETADDR Dest)
{*/
CPacket *p = 0;
CPacket *pNext = m_pFirst;
while(1)
while(true)
{
p = pNext;
if(!p)

View file

@ -1,10 +1,10 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <base/system.h>
#include <cstdlib> //rand
#include <engine/shared/config.h>
#include <engine/shared/network.h>
#include <mastersrv/mastersrv.h>
#include <stdlib.h> //rand
CNetServer *pNet;
@ -116,7 +116,7 @@ static int Run()
if(!pNet->Open(BindAddr, 0, 0, 0, 0))
return 0;
while(1)
while(true)
{
CNetChunk p;
pNet->Update();

View file

@ -1,11 +1,11 @@
#include <algorithm>
#include <base/math.h>
#include <base/system.h>
#include <cstdint>
#include <engine/shared/datafile.h>
#include <engine/shared/image_manipulation.h>
#include <engine/storage.h>
#include <game/mapitems.h>
#include <stdint.h>
#include <utility>
#include <vector>

View file

@ -17,7 +17,7 @@ void Run(NETADDR Dest)
Socket = net_udp_create(BindAddr);
}
while(1)
while(true)
{
unsigned char aData[1024];
int Size = 0;

View file

@ -1,9 +1,9 @@
#include <base/math.h>
#include <base/system.h>
#include <cstdio>
#include <engine/shared/network.h>
#include <engine/shared/packer.h>
#include <mastersrv/mastersrv.h>
#include <stdio.h>
static CNetClient g_NetOp; // main