From 05af24a05235e751f7d42c527e2665252cbf9882 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Mon, 11 Dec 2023 15:40:09 +0100 Subject: [PATCH] Make less headers depend on `` Move a couple of trivial type definitions to `` instead. --- CMakeLists.txt | 1 + datasrc/network.py | 1 + src/antibot/antibot_data.h | 1 - src/base/hash_ctxt.h | 1 - src/base/system.h | 62 ++----------------- src/base/types.h | 54 ++++++++++++++++ src/engine/client/backend/backend_base.cpp | 1 + src/engine/client/favorites.cpp | 1 + src/engine/client/ghost.h | 2 + src/engine/client/graphics_threaded.h | 1 + src/engine/client/serverbrowser_http.h | 2 +- .../client/serverbrowser_ping_cache.cpp | 1 + src/engine/client/serverbrowser_ping_cache.h | 2 +- src/engine/client/steam.cpp | 1 + src/engine/client/video.h | 1 - src/engine/client/warning.cpp | 14 +++++ src/engine/demo.h | 12 +--- src/engine/discord.h | 1 + src/engine/graphics.h | 1 + src/engine/input.h | 1 + src/engine/kernel.h | 2 - src/engine/map.h | 1 + src/engine/server/databases/connection.cpp | 5 ++ src/engine/server/databases/connection.h | 6 +- src/engine/server/upnp.h | 2 +- src/engine/serverbrowser.h | 2 +- src/engine/shared/console.h | 1 + src/engine/shared/csv.cpp | 2 + src/engine/shared/csv.h | 2 +- src/engine/shared/datafile.h | 2 +- src/engine/shared/demo.cpp | 10 +++ src/engine/shared/fifo.h | 1 + src/engine/shared/filecollection.cpp | 1 + src/engine/shared/filecollection.h | 2 +- src/engine/shared/jsonwriter.cpp | 2 + src/engine/shared/jsonwriter.h | 3 +- src/engine/shared/linereader.cpp | 2 + src/engine/shared/linereader.h | 2 +- src/engine/shared/map.h | 2 +- src/engine/shared/netban.h | 3 +- src/engine/shared/protocol_ex.cpp | 1 + src/engine/shared/serverinfo.cpp | 1 + src/engine/shared/uuid_manager.cpp | 6 ++ src/engine/shared/uuid_manager.h | 4 +- src/engine/steam.h | 2 + src/engine/storage.h | 1 + src/engine/warning.h | 15 ++--- src/game/client/components/voting.h | 2 - src/game/editor/mapitems/sound.h | 3 +- src/game/gamecore.h | 6 +- src/game/teamscore.cpp | 1 + src/test/csv.cpp | 1 + src/test/jsonwriter.cpp | 1 + src/test/linereader.cpp | 1 + src/tools/uuid.cpp | 1 + 55 files changed, 152 insertions(+), 108 deletions(-) create mode 100644 src/engine/client/warning.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 72954eedd..bf2c7bb09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2157,6 +2157,7 @@ if(CLIENT) updater.h video.cpp video.h + warning.cpp ) set_src(GAME_CLIENT GLOB_RECURSE src/game/client animstate.cpp diff --git a/datasrc/network.py b/datasrc/network.py index 7b1b291c6..f35c8a64e 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -51,6 +51,7 @@ Authed = ["NO", "HELPER", "MOD", "ADMIN"] EntityClasses = ["PROJECTILE", "DOOR", "DRAGGER_WEAK", "DRAGGER_NORMAL", "DRAGGER_STRONG", "GUN_NORMAL", "GUN_EXPLOSIVE", "GUN_FREEZE", "GUN_UNFREEZE", "LIGHT", "PICKUP"] RawHeader = ''' +#include #include enum diff --git a/src/antibot/antibot_data.h b/src/antibot/antibot_data.h index ea244aa19..f65f62628 100644 --- a/src/antibot/antibot_data.h +++ b/src/antibot/antibot_data.h @@ -1,7 +1,6 @@ #ifndef ANTIBOT_ANTIBOT_DATA_H #define ANTIBOT_ANTIBOT_DATA_H -#include #include enum diff --git a/src/base/hash_ctxt.h b/src/base/hash_ctxt.h index 2d382a75f..e407f04c3 100644 --- a/src/base/hash_ctxt.h +++ b/src/base/hash_ctxt.h @@ -2,7 +2,6 @@ #define BASE_HASH_CTXT_H #include "hash.h" -#include "system.h" #include #if defined(CONF_OPENSSL) diff --git a/src/base/system.h b/src/base/system.h index 447c8ef7f..c575949e6 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -9,6 +9,7 @@ #define BASE_SYSTEM_H #include "detect.h" +#include "types.h" #ifndef __USE_GNU #define __USE_GNU @@ -226,12 +227,8 @@ enum IOSEEK_START = 0, IOSEEK_CUR = 1, IOSEEK_END = 2, - - IO_MAX_PATH_LENGTH = 512, }; -typedef void *IOHANDLE; - /** * Opens a file. * @@ -741,44 +738,12 @@ ETimeSeason time_season(); * @defgroup Network-General */ -/** - * @ingroup Network-General - */ -typedef struct NETSOCKET_INTERNAL *NETSOCKET; - -/** - * @ingroup Network-General - */ -enum -{ - NETADDR_MAXSTRSIZE = 1 + (8 * 4 + 7) + 1 + 1 + 5 + 1, // [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]:XXXXX - - NETTYPE_LINK_BROADCAST = 4, - - NETTYPE_INVALID = 0, - NETTYPE_IPV4 = 1, - NETTYPE_IPV6 = 2, - NETTYPE_WEBSOCKET_IPV4 = 8, - - NETTYPE_ALL = NETTYPE_IPV4 | NETTYPE_IPV6 | NETTYPE_WEBSOCKET_IPV4, - NETTYPE_MASK = NETTYPE_ALL | NETTYPE_LINK_BROADCAST, -}; - -/** - * @ingroup Network-General - */ -typedef struct NETADDR -{ - unsigned int type; - unsigned char ip[16]; - unsigned short port; - - bool operator==(const NETADDR &other) const; - bool operator!=(const NETADDR &other) const { return !(*this == other); } -} NETADDR; - extern const NETADDR NETADDR_ZEROED; +/** + * @ingroup Network-General + */ + #ifdef CONF_FAMILY_UNIX /** * @ingroup Network-General @@ -1810,16 +1775,8 @@ void str_escape(char **dst, const char *src, const char *end); * * @remark The strings are treated as zero-terminated strings. */ -typedef int (*FS_LISTDIR_CALLBACK)(const char *name, int is_dir, int dir_type, void *user); void fs_listdir(const char *dir, FS_LISTDIR_CALLBACK cb, int type, void *user); -typedef struct -{ - const char *m_pName; - time_t m_TimeCreated; // seconds since UNIX Epoch - time_t m_TimeModified; // seconds since UNIX Epoch -} CFsFileInfo; - /** * Lists the files and folders in a directory and gets additional file information. * @@ -1832,7 +1789,6 @@ typedef struct * * @remark The strings are treated as zero-terminated strings. */ -typedef int (*FS_LISTDIR_CALLBACK_FILEINFO)(const CFsFileInfo *info, int is_dir, int dir_type, void *user); void fs_listdir_fileinfo(const char *dir, FS_LISTDIR_CALLBACK_FILEINFO cb, int type, void *user); /** @@ -2183,14 +2139,6 @@ int str_isallnum_hex(const char *str); unsigned str_quickhash(const char *str); -enum -{ - /** - * The maximum bytes necessary to encode one Unicode codepoint with UTF-8. - */ - UTF8_BYTE_LENGTH = 4, -}; - int str_utf8_to_skeleton(const char *str, int *buf, int buf_len); /* diff --git a/src/base/types.h b/src/base/types.h index ace9dc2f7..ffa1b47ed 100644 --- a/src/base/types.h +++ b/src/base/types.h @@ -1,6 +1,8 @@ #ifndef BASE_TYPES_H #define BASE_TYPES_H +#include + enum class TRISTATE { NONE, @@ -8,4 +10,56 @@ enum class TRISTATE ALL, }; +typedef void *IOHANDLE; + +typedef int (*FS_LISTDIR_CALLBACK)(const char *name, int is_dir, int dir_type, void *user); + +typedef struct +{ + const char *m_pName; + time_t m_TimeCreated; // seconds since UNIX Epoch + time_t m_TimeModified; // seconds since UNIX Epoch +} CFsFileInfo; + +typedef int (*FS_LISTDIR_CALLBACK_FILEINFO)(const CFsFileInfo *info, int is_dir, int dir_type, void *user); + +/** + * @ingroup Network-General + */ +typedef struct NETSOCKET_INTERNAL *NETSOCKET; + +enum +{ + /** + * The maximum bytes necessary to encode one Unicode codepoint with UTF-8. + */ + UTF8_BYTE_LENGTH = 4, + + IO_MAX_PATH_LENGTH = 512, + + NETADDR_MAXSTRSIZE = 1 + (8 * 4 + 7) + 1 + 1 + 5 + 1, // [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]:XXXXX + + NETTYPE_LINK_BROADCAST = 4, + + NETTYPE_INVALID = 0, + NETTYPE_IPV4 = 1, + NETTYPE_IPV6 = 2, + NETTYPE_WEBSOCKET_IPV4 = 8, + + NETTYPE_ALL = NETTYPE_IPV4 | NETTYPE_IPV6 | NETTYPE_WEBSOCKET_IPV4, + NETTYPE_MASK = NETTYPE_ALL | NETTYPE_LINK_BROADCAST, +}; + +/** + * @ingroup Network-General + */ +typedef struct NETADDR +{ + unsigned int type; + unsigned char ip[16]; + unsigned short port; + + bool operator==(const NETADDR &other) const; + bool operator!=(const NETADDR &other) const { return !(*this == other); } +} NETADDR; #endif // BASE_TYPES_H diff --git a/src/engine/client/backend/backend_base.cpp b/src/engine/client/backend/backend_base.cpp index 9e2ad5c4d..168598064 100644 --- a/src/engine/client/backend/backend_base.cpp +++ b/src/engine/client/backend/backend_base.cpp @@ -1,4 +1,5 @@ #include "backend_base.h" +#include #include void *CCommandProcessorFragment_GLBase::Resize(const unsigned char *pData, int Width, int Height, int NewWidth, int NewHeight, int BPP) diff --git a/src/engine/client/favorites.cpp b/src/engine/client/favorites.cpp index 39d015a75..9df4e42af 100644 --- a/src/engine/client/favorites.cpp +++ b/src/engine/client/favorites.cpp @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/src/engine/client/ghost.h b/src/engine/client/ghost.h index f555e1f2d..544b7d044 100644 --- a/src/engine/client/ghost.h +++ b/src/engine/client/ghost.h @@ -3,6 +3,8 @@ #include +#include + enum { MAX_ITEM_SIZE = 128, diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 514680749..eaf0570d6 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -1,6 +1,7 @@ #ifndef ENGINE_CLIENT_GRAPHICS_THREADED_H #define ENGINE_CLIENT_GRAPHICS_THREADED_H +#include #include #include diff --git a/src/engine/client/serverbrowser_http.h b/src/engine/client/serverbrowser_http.h index d75b3d157..b6884f869 100644 --- a/src/engine/client/serverbrowser_http.h +++ b/src/engine/client/serverbrowser_http.h @@ -1,6 +1,6 @@ #ifndef ENGINE_CLIENT_SERVERBROWSER_HTTP_H #define ENGINE_CLIENT_SERVERBROWSER_HTTP_H -#include +#include class CServerInfo; class IConsole; diff --git a/src/engine/client/serverbrowser_ping_cache.cpp b/src/engine/client/serverbrowser_ping_cache.cpp index ff46adf31..d59f1bd83 100644 --- a/src/engine/client/serverbrowser_ping_cache.cpp +++ b/src/engine/client/serverbrowser_ping_cache.cpp @@ -1,5 +1,6 @@ #include "serverbrowser_ping_cache.h" +#include #include #include diff --git a/src/engine/client/serverbrowser_ping_cache.h b/src/engine/client/serverbrowser_ping_cache.h index bacd83782..5c81e939f 100644 --- a/src/engine/client/serverbrowser_ping_cache.h +++ b/src/engine/client/serverbrowser_ping_cache.h @@ -1,6 +1,6 @@ #ifndef ENGINE_CLIENT_SERVERBROWSER_PING_CACHE_H #define ENGINE_CLIENT_SERVERBROWSER_PING_CACHE_H -#include +#include class IConsole; class IStorage; diff --git a/src/engine/client/steam.cpp b/src/engine/client/steam.cpp index f5b3609cd..6c1cd20ea 100644 --- a/src/engine/client/steam.cpp +++ b/src/engine/client/steam.cpp @@ -1,5 +1,6 @@ #include +#include #include #include diff --git a/src/engine/client/video.h b/src/engine/client/video.h index 849a0b725..58f2186ed 100644 --- a/src/engine/client/video.h +++ b/src/engine/client/video.h @@ -2,7 +2,6 @@ #define ENGINE_CLIENT_VIDEO_H #include -#include extern "C" { #include diff --git a/src/engine/client/warning.cpp b/src/engine/client/warning.cpp new file mode 100644 index 000000000..0ed4a9daa --- /dev/null +++ b/src/engine/client/warning.cpp @@ -0,0 +1,14 @@ +#include + +#include + +SWarning::SWarning(const char *pMsg) +{ + str_copy(m_aWarningTitle, ""); + str_copy(m_aWarningMsg, pMsg); +} +SWarning::SWarning(const char *pTitle, const char *pMsg) +{ + str_copy(m_aWarningTitle, pTitle); + str_copy(m_aWarningMsg, pMsg); +} diff --git a/src/engine/demo.h b/src/engine/demo.h index 240551de2..f42193e9b 100644 --- a/src/engine/demo.h +++ b/src/engine/demo.h @@ -8,6 +8,8 @@ #include #include +#include + enum { MAX_TIMELINE_MARKERS = 64 @@ -37,15 +39,7 @@ struct CDemoHeader unsigned char m_aLength[sizeof(int32_t)]; char m_aTimestamp[20]; - bool Valid() const - { - // Check marker and ensure that strings are zero-terminated and valid UTF-8. - return mem_comp(m_aMarker, gs_aHeaderMarker, sizeof(gs_aHeaderMarker)) == 0 && - mem_has_null(m_aNetversion, sizeof(m_aNetversion)) && str_utf8_check(m_aNetversion) && - mem_has_null(m_aMapName, sizeof(m_aMapName)) && str_utf8_check(m_aMapName) && - mem_has_null(m_aType, sizeof(m_aType)) && str_utf8_check(m_aType) && - mem_has_null(m_aTimestamp, sizeof(m_aTimestamp)) && str_utf8_check(m_aTimestamp); - } + bool Valid() const; }; struct CTimelineMarkers diff --git a/src/engine/discord.h b/src/engine/discord.h index 92e4401fa..5b5f0a826 100644 --- a/src/engine/discord.h +++ b/src/engine/discord.h @@ -2,6 +2,7 @@ #define ENGINE_DISCORD_H #include "kernel.h" +#include class IDiscord : public IInterface { diff --git a/src/engine/graphics.h b/src/engine/graphics.h index 502142261..951748b11 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -7,6 +7,7 @@ #include "warning.h" #include +#include #include #include diff --git a/src/engine/input.h b/src/engine/input.h index cbf693faa..87740c2fa 100644 --- a/src/engine/input.h +++ b/src/engine/input.h @@ -4,6 +4,7 @@ #define ENGINE_INPUT_H #include "kernel.h" +#include const int g_MaxKeys = 512; extern const char g_aaKeyStrings[g_MaxKeys][20]; diff --git a/src/engine/kernel.h b/src/engine/kernel.h index 95cab9f71..7412142a0 100644 --- a/src/engine/kernel.h +++ b/src/engine/kernel.h @@ -3,8 +3,6 @@ #ifndef ENGINE_KERNEL_H #define ENGINE_KERNEL_H -#include - class IKernel; class IInterface; diff --git a/src/engine/map.h b/src/engine/map.h index 5f5f4c67a..47c2c5ed8 100644 --- a/src/engine/map.h +++ b/src/engine/map.h @@ -5,6 +5,7 @@ #include "kernel.h" #include +#include enum { diff --git a/src/engine/server/databases/connection.cpp b/src/engine/server/databases/connection.cpp index 1609b85a9..de77f31ad 100644 --- a/src/engine/server/databases/connection.cpp +++ b/src/engine/server/databases/connection.cpp @@ -2,6 +2,11 @@ #include +IDbConnection::IDbConnection(const char *pPrefix) +{ + str_copy(m_aPrefix, pPrefix); +} + void IDbConnection::FormatCreateRace(char *aBuf, unsigned int BufferSize, bool Backup) { str_format(aBuf, BufferSize, diff --git a/src/engine/server/databases/connection.h b/src/engine/server/databases/connection.h index 332e278a4..0060c6428 100644 --- a/src/engine/server/databases/connection.h +++ b/src/engine/server/databases/connection.h @@ -2,7 +2,6 @@ #define ENGINE_SERVER_DATABASES_CONNECTION_H #include "connection_pool.h" -#include #include @@ -12,10 +11,7 @@ class IConsole; class IDbConnection { public: - IDbConnection(const char *pPrefix) - { - str_copy(m_aPrefix, pPrefix); - } + IDbConnection(const char *pPrefix); virtual ~IDbConnection() {} IDbConnection &operator=(const IDbConnection &) = delete; virtual void Print(IConsole *pConsole, const char *pMode) = 0; diff --git a/src/engine/server/upnp.h b/src/engine/server/upnp.h index f5c6a7597..6b35db268 100644 --- a/src/engine/server/upnp.h +++ b/src/engine/server/upnp.h @@ -1,7 +1,7 @@ #ifndef ENGINE_SERVER_UPNP_H #define ENGINE_SERVER_UPNP_H -#include +#include class CUPnP { NETADDR m_Addr; diff --git a/src/engine/serverbrowser.h b/src/engine/serverbrowser.h index 1d01d3e8f..c3e83a200 100644 --- a/src/engine/serverbrowser.h +++ b/src/engine/serverbrowser.h @@ -4,7 +4,7 @@ #define ENGINE_SERVERBROWSER_H #include -#include +#include #include #include diff --git a/src/engine/shared/console.h b/src/engine/shared/console.h index f5c4c97ea..bc22e4d1a 100644 --- a/src/engine/shared/console.h +++ b/src/engine/shared/console.h @@ -5,6 +5,7 @@ #include "memheap.h" #include +#include #include #include diff --git a/src/engine/shared/csv.cpp b/src/engine/shared/csv.cpp index 0fc90a879..056091e8c 100644 --- a/src/engine/shared/csv.cpp +++ b/src/engine/shared/csv.cpp @@ -1,5 +1,7 @@ #include "csv.h" +#include + void CsvWrite(IOHANDLE File, int NumColumns, const char *const *ppColumns) { for(int i = 0; i < NumColumns; i++) diff --git a/src/engine/shared/csv.h b/src/engine/shared/csv.h index 9d3de0e04..0417e4548 100644 --- a/src/engine/shared/csv.h +++ b/src/engine/shared/csv.h @@ -1,7 +1,7 @@ #ifndef ENGINE_SHARED_CSV_H #define ENGINE_SHARED_CSV_H -#include +#include void CsvWrite(IOHANDLE File, int NumColumns, const char *const *ppColumns); diff --git a/src/engine/shared/datafile.h b/src/engine/shared/datafile.h index 0d8dd6a39..db77ca41e 100644 --- a/src/engine/shared/datafile.h +++ b/src/engine/shared/datafile.h @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/src/engine/shared/demo.cpp b/src/engine/shared/demo.cpp index 2b10b5554..2eefe2b82 100644 --- a/src/engine/shared/demo.cpp +++ b/src/engine/shared/demo.cpp @@ -31,6 +31,16 @@ static const int gs_NumMarkersOffset = 176; static const ColorRGBA gs_DemoPrintColor{0.75f, 0.7f, 0.7f, 1.0f}; +bool CDemoHeader::Valid() const +{ + // Check marker and ensure that strings are zero-terminated and valid UTF-8. + return mem_comp(m_aMarker, gs_aHeaderMarker, sizeof(gs_aHeaderMarker)) == 0 && + mem_has_null(m_aNetversion, sizeof(m_aNetversion)) && str_utf8_check(m_aNetversion) && + mem_has_null(m_aMapName, sizeof(m_aMapName)) && str_utf8_check(m_aMapName) && + mem_has_null(m_aType, sizeof(m_aType)) && str_utf8_check(m_aType) && + mem_has_null(m_aTimestamp, sizeof(m_aTimestamp)) && str_utf8_check(m_aTimestamp); +} + CDemoRecorder::CDemoRecorder(class CSnapshotDelta *pSnapshotDelta, bool NoMapData) { m_File = 0; diff --git a/src/engine/shared/fifo.h b/src/engine/shared/fifo.h index b844de073..ad431b9bb 100644 --- a/src/engine/shared/fifo.h +++ b/src/engine/shared/fifo.h @@ -1,6 +1,7 @@ #ifndef ENGINE_SHARED_FIFO_H #define ENGINE_SHARED_FIFO_H +#include #include class CFifo diff --git a/src/engine/shared/filecollection.cpp b/src/engine/shared/filecollection.cpp index 8125e8ab9..0dab1c258 100644 --- a/src/engine/shared/filecollection.cpp +++ b/src/engine/shared/filecollection.cpp @@ -2,6 +2,7 @@ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include +#include #include diff --git a/src/engine/shared/filecollection.h b/src/engine/shared/filecollection.h index d284685ac..9a4b561c6 100644 --- a/src/engine/shared/filecollection.h +++ b/src/engine/shared/filecollection.h @@ -3,7 +3,7 @@ #ifndef ENGINE_SHARED_FILECOLLECTION_H #define ENGINE_SHARED_FILECOLLECTION_H -#include +#include #include diff --git a/src/engine/shared/jsonwriter.cpp b/src/engine/shared/jsonwriter.cpp index 5c870e4f5..ca703bf49 100644 --- a/src/engine/shared/jsonwriter.cpp +++ b/src/engine/shared/jsonwriter.cpp @@ -3,6 +3,8 @@ #include "jsonwriter.h" +#include + static char EscapeJsonChar(char c) { switch(c) diff --git a/src/engine/shared/jsonwriter.h b/src/engine/shared/jsonwriter.h index 2365afe2f..83086055a 100644 --- a/src/engine/shared/jsonwriter.h +++ b/src/engine/shared/jsonwriter.h @@ -3,9 +3,10 @@ #ifndef ENGINE_SHARED_JSONWRITER_H #define ENGINE_SHARED_JSONWRITER_H -#include +#include #include +#include /** * JSON writer with abstract writing function. diff --git a/src/engine/shared/linereader.cpp b/src/engine/shared/linereader.cpp index 8cc02a59c..d322ee279 100644 --- a/src/engine/shared/linereader.cpp +++ b/src/engine/shared/linereader.cpp @@ -2,6 +2,8 @@ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include "linereader.h" +#include + void CLineReader::Init(IOHANDLE File) { m_BufferMaxSize = sizeof(m_aBuffer) - 1; diff --git a/src/engine/shared/linereader.h b/src/engine/shared/linereader.h index 6d4aa07e2..7d5f1c5ab 100644 --- a/src/engine/shared/linereader.h +++ b/src/engine/shared/linereader.h @@ -2,7 +2,7 @@ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #ifndef ENGINE_SHARED_LINEREADER_H #define ENGINE_SHARED_LINEREADER_H -#include +#include // buffered stream for reading lines, should perhaps be something smaller class CLineReader diff --git a/src/engine/shared/map.h b/src/engine/shared/map.h index ebb3a8591..c104c6c0a 100644 --- a/src/engine/shared/map.h +++ b/src/engine/shared/map.h @@ -3,7 +3,7 @@ #ifndef ENGINE_SHARED_MAP_H #define ENGINE_SHARED_MAP_H -#include +#include #include "datafile.h" #include diff --git a/src/engine/shared/netban.h b/src/engine/shared/netban.h index fd7dbb8a8..6de37e51d 100644 --- a/src/engine/shared/netban.h +++ b/src/engine/shared/netban.h @@ -1,9 +1,8 @@ #ifndef ENGINE_SHARED_NETBAN_H #define ENGINE_SHARED_NETBAN_H -#include - #include +#include inline int NetComp(const NETADDR *pAddr1, const NETADDR *pAddr2) { diff --git a/src/engine/shared/protocol_ex.cpp b/src/engine/shared/protocol_ex.cpp index 4d44ca7be..51f4b286a 100644 --- a/src/engine/shared/protocol_ex.cpp +++ b/src/engine/shared/protocol_ex.cpp @@ -3,6 +3,7 @@ #include "config.h" #include "uuid_manager.h" +#include #include #include diff --git a/src/engine/shared/serverinfo.cpp b/src/engine/shared/serverinfo.cpp index 9f0f4a1b4..ecccfa599 100644 --- a/src/engine/shared/serverinfo.cpp +++ b/src/engine/shared/serverinfo.cpp @@ -2,6 +2,7 @@ #include "json.h" #include +#include #include #include diff --git a/src/engine/shared/uuid_manager.cpp b/src/engine/shared/uuid_manager.cpp index 4dfb90100..3cff589d6 100644 --- a/src/engine/shared/uuid_manager.cpp +++ b/src/engine/shared/uuid_manager.cpp @@ -1,6 +1,7 @@ #include "uuid_manager.h" #include +#include #include #include @@ -100,6 +101,11 @@ bool CUuid::operator!=(const CUuid &Other) const return !(*this == Other); } +bool CUuid::operator<(const CUuid &Other) const +{ + return mem_comp(this, &Other, sizeof(*this)) < 0; +} + static int GetIndex(int ID) { return ID - OFFSET_UUID; diff --git a/src/engine/shared/uuid_manager.h b/src/engine/shared/uuid_manager.h index c1c607e75..00d1a4822 100644 --- a/src/engine/shared/uuid_manager.h +++ b/src/engine/shared/uuid_manager.h @@ -3,8 +3,6 @@ #include -#include - enum { UUID_MAXSTRSIZE = 37, // 12345678-0123-5678-0123-567890123456 @@ -21,7 +19,7 @@ struct CUuid bool operator==(const CUuid &Other) const; bool operator!=(const CUuid &Other) const; - bool operator<(const CUuid &Other) const { return mem_comp(m_aData, Other.m_aData, sizeof(m_aData)) < 0; } + bool operator<(const CUuid &Other) const; }; extern const CUuid UUID_ZEROED; diff --git a/src/engine/steam.h b/src/engine/steam.h index baf966117..20341e2b0 100644 --- a/src/engine/steam.h +++ b/src/engine/steam.h @@ -1,6 +1,8 @@ #ifndef ENGINE_STEAM_H #define ENGINE_STEAM_H +#include + #include "kernel.h" class ISteam : public IInterface diff --git a/src/engine/storage.h b/src/engine/storage.h index 38d441f39..9380d0dd5 100644 --- a/src/engine/storage.h +++ b/src/engine/storage.h @@ -4,6 +4,7 @@ #define ENGINE_STORAGE_H #include +#include #include "kernel.h" diff --git a/src/engine/warning.h b/src/engine/warning.h index 0214a6b0f..bd1e45e75 100644 --- a/src/engine/warning.h +++ b/src/engine/warning.h @@ -3,17 +3,10 @@ struct SWarning { - SWarning() {} - SWarning(const char *pMsg) - { - str_copy(m_aWarningTitle, ""); - str_copy(m_aWarningMsg, pMsg); - } - SWarning(const char *pTitle, const char *pMsg) - { - str_copy(m_aWarningTitle, pTitle); - str_copy(m_aWarningMsg, pMsg); - } + SWarning() = default; + SWarning(const char *pMsg); + SWarning(const char *pTitle, const char *pMsg); + char m_aWarningTitle[128]; char m_aWarningMsg[256]; bool m_WasShown = false; diff --git a/src/game/client/components/voting.h b/src/game/client/components/voting.h index 077edcb81..f81959a68 100644 --- a/src/game/client/components/voting.h +++ b/src/game/client/components/voting.h @@ -3,8 +3,6 @@ #ifndef GAME_CLIENT_COMPONENTS_VOTING_H #define GAME_CLIENT_COMPONENTS_VOTING_H -#include - #include #include diff --git a/src/game/editor/mapitems/sound.h b/src/game/editor/mapitems/sound.h index 681f9ad30..28b222972 100644 --- a/src/game/editor/mapitems/sound.h +++ b/src/game/editor/mapitems/sound.h @@ -1,8 +1,7 @@ #ifndef GAME_EDITOR_MAPITEMS_SOUND_H #define GAME_EDITOR_MAPITEMS_SOUND_H -#include - +#include #include class CEditorSound : public CEditorComponent diff --git a/src/game/gamecore.h b/src/game/gamecore.h index 8c81c00bd..07c6d188f 100644 --- a/src/game/gamecore.h +++ b/src/game/gamecore.h @@ -3,7 +3,6 @@ #ifndef GAME_GAMECORE_H #define GAME_GAMECORE_H -#include #include #include @@ -191,7 +190,10 @@ class CWorldCore public: CWorldCore() { - mem_zero(m_apCharacters, sizeof(m_apCharacters)); + for(auto &pCharacter : m_apCharacters) + { + pCharacter = nullptr; + } m_pPrng = nullptr; } diff --git a/src/game/teamscore.cpp b/src/game/teamscore.cpp index 968eb8ef9..0835a9814 100644 --- a/src/game/teamscore.cpp +++ b/src/game/teamscore.cpp @@ -1,5 +1,6 @@ /* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */ #include "teamscore.h" +#include #include CTeamsCore::CTeamsCore() diff --git a/src/test/csv.cpp b/src/test/csv.cpp index 905983fdf..2022f98ca 100644 --- a/src/test/csv.cpp +++ b/src/test/csv.cpp @@ -1,6 +1,7 @@ #include "test.h" #include +#include #include static void Expect(int NumColumns, const char *const *ppColumns, const char *pExpected) diff --git a/src/test/jsonwriter.cpp b/src/test/jsonwriter.cpp index f61137c39..c8bcede61 100644 --- a/src/test/jsonwriter.cpp +++ b/src/test/jsonwriter.cpp @@ -3,6 +3,7 @@ #include "test.h" #include +#include #include #include diff --git a/src/test/linereader.cpp b/src/test/linereader.cpp index cd53b38ca..05d93627b 100644 --- a/src/test/linereader.cpp +++ b/src/test/linereader.cpp @@ -1,6 +1,7 @@ #include "test.h" #include +#include #include void TestFileLineReader(const char *pWritten, bool SkipBom, std::initializer_list pReads) diff --git a/src/tools/uuid.cpp b/src/tools/uuid.cpp index 0cb35aa8d..6a6a011c2 100644 --- a/src/tools/uuid.cpp +++ b/src/tools/uuid.cpp @@ -1,4 +1,5 @@ #include +#include #include int main(int argc, const char **argv) {