From 3d7101876fe0e6a08347e3a39e57d3a9af196e44 Mon Sep 17 00:00:00 2001 From: brainiac Date: Thu, 18 Dec 2025 00:40:31 -0800 Subject: [PATCH] normalize includes: common --- common/cli/eqemu_command_handler.h | 12 ++--- common/crash.cpp | 4 +- common/database.h | 11 ----- common/database_instances.cpp | 2 +- common/dbcore.cpp | 16 +------ common/dbcore.h | 2 - common/eq_packet.cpp | 2 + common/eqemu_logsys.cpp | 4 +- common/event/event_loop.h | 4 +- common/event/timer.h | 1 + common/file.cpp | 13 +----- common/fixed_memory_hash_set.h | 2 +- common/fixed_memory_variable_hash_set.h | 2 +- common/http/httplib.h | 2 +- common/item_instance.cpp | 2 +- common/light_source.cpp | 2 +- common/md5.cpp | 2 +- common/memory_buffer.h | 2 +- common/misc.cpp | 6 +-- common/misc.h | 2 +- common/misc_functions.cpp | 60 +++---------------------- common/misc_functions.h | 7 +-- common/net/reliable_stream_connection.h | 1 - common/opcodemgr.cpp | 2 +- common/packet_dump.cpp | 2 +- common/packet_functions.cpp | 3 +- common/pch/std-pch.h | 5 +++ common/proc_launcher.cpp | 6 +-- common/proc_launcher.h | 1 + common/profanity_manager.cpp | 2 +- common/random.h | 1 - common/seperator.h | 4 +- common/serialize_buffer.h | 1 + common/server_event_scheduler.cpp | 2 +- common/server_event_scheduler.h | 2 +- common/servertalk.h | 1 + common/skills.cpp | 2 +- common/types.h | 3 +- common/unix.cpp | 4 +- 39 files changed, 59 insertions(+), 143 deletions(-) diff --git a/common/cli/eqemu_command_handler.h b/common/cli/eqemu_command_handler.h index d0b0b5b5e..7ccd30dd9 100644 --- a/common/cli/eqemu_command_handler.h +++ b/common/cli/eqemu_command_handler.h @@ -18,10 +18,13 @@ * */ -#ifndef EQEMU_EQEMU_COMMAND_HANDLER_H -#define EQEMU_EQEMU_COMMAND_HANDLER_H +#pragma once -#include "argh.h" +#include "common/cli/argh.h" + +#include +#include +#include namespace EQEmuCommand { @@ -70,6 +73,3 @@ namespace EQEmuCommand { char **argv ); }; - - -#endif //EQEMU_EQEMU_COMMAND_HANDLER_H diff --git a/common/crash.cpp b/common/crash.cpp index 7cde8bb30..fb8e5a865 100644 --- a/common/crash.cpp +++ b/common/crash.cpp @@ -220,8 +220,8 @@ void set_exception_handler() { } #else -#include -#include +#include +#include #include #include #include diff --git a/common/database.h b/common/database.h index 425cb5818..580d58add 100644 --- a/common/database.h +++ b/common/database.h @@ -60,17 +60,6 @@ struct VarCache_Struct { class PTimerList; -#ifdef _WINDOWS -#if _MSC_VER > 1700 // greater than 2012 (2013+) -# define _ISNAN_(a) std::isnan(a) -#else -# include -# define _ISNAN_(a) _isnan(a) -#endif -#else -# define _ISNAN_(a) std::isnan(a) -#endif - #define SQL(...) #__VA_ARGS__ class Database : public DBcore { diff --git a/common/database_instances.cpp b/common/database_instances.cpp index 117e47b42..674649ff7 100644 --- a/common/database_instances.cpp +++ b/common/database_instances.cpp @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "database.h" #include "common/platform/inet.h" -#include "common/platform/platform" +#include "common/platform/platform.h" #include "common/platform/win/include_windows.h" #include "common/repositories/character_corpses_repository.h" #include "common/repositories/data_buckets_repository.h" diff --git a/common/dbcore.cpp b/common/dbcore.cpp index 6b8ae9dc4..b9afaa1c6 100644 --- a/common/dbcore.cpp +++ b/common/dbcore.cpp @@ -5,24 +5,10 @@ #include "common/mysql_stmt.h" #include "common/strings.h" #include "common/timer.h" +#include "common/types.h" #include "mysqld_error.h" -#include -#include -#include - -#ifdef _WINDOWS -#define snprintf _snprintf -#define strncasecmp _strnicmp -#define strcasecmp _stricmp -#include -#include -#else -#include "common/unix.h" -#include -#endif - #ifdef _EQDEBUG #define DEBUG_MYSQL_QUERIES 0 #else diff --git a/common/dbcore.h b/common/dbcore.h index 978ab96bc..3368dccfc 100644 --- a/common/dbcore.h +++ b/common/dbcore.h @@ -5,8 +5,6 @@ #include "common/types.h" #include "mysql.h" - -#include #include #define CR_SERVER_GONE_ERROR 2006 diff --git a/common/eq_packet.cpp b/common/eq_packet.cpp index 1c494950c..f025efb97 100644 --- a/common/eq_packet.cpp +++ b/common/eq_packet.cpp @@ -28,6 +28,8 @@ #include "common/platform.h" #include +#include +#include EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len) : BasePacket(buf, len), diff --git a/common/eqemu_logsys.cpp b/common/eqemu_logsys.cpp index 8af9dcc6d..9390a15ef 100644 --- a/common/eqemu_logsys.cpp +++ b/common/eqemu_logsys.cpp @@ -29,17 +29,15 @@ #include "common/strings.h" #include "common/termcolor/rang.hpp" +#include #include #include #include #include -#include #ifdef _WINDOWS #include #include -#include -#include #include #include #else diff --git a/common/event/event_loop.h b/common/event/event_loop.h index 4ef532d98..20cc8a10a 100644 --- a/common/event/event_loop.h +++ b/common/event/event_loop.h @@ -1,8 +1,10 @@ #pragma once -#include "common/platform/win/include_windows.h" // uv.h is going to include it so lets do it first. +#include "common/platform/win/include_windows.h" // uv.h is going to include it so let's do it first. #include "uv.h" // FIXME: hide this +#include + namespace EQ { class EventLoop diff --git a/common/event/timer.h b/common/event/timer.h index c9fe757d9..adf5efc36 100644 --- a/common/event/timer.h +++ b/common/event/timer.h @@ -2,6 +2,7 @@ #include "event_loop.h" +#include #include namespace EQ { diff --git a/common/file.cpp b/common/file.cpp index 8d56470b1..3661c2ff9 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -20,6 +20,7 @@ #include "file.h" +#include "common/platform/platform.h" #include "fmt/format.h" #include @@ -28,18 +29,6 @@ #include #include -#ifdef _WINDOWS -#include -#include -#include -#include -#include -#include -#else -#include -#include -#endif - namespace fs = std::filesystem; diff --git a/common/fixed_memory_hash_set.h b/common/fixed_memory_hash_set.h index 17e8d9013..5677427d2 100644 --- a/common/fixed_memory_hash_set.h +++ b/common/fixed_memory_hash_set.h @@ -21,7 +21,7 @@ #include "common/eqemu_exception.h" #include "common/types.h" -#include +#include namespace EQ { diff --git a/common/fixed_memory_variable_hash_set.h b/common/fixed_memory_variable_hash_set.h index f04387c0c..7aa8c6753 100644 --- a/common/fixed_memory_variable_hash_set.h +++ b/common/fixed_memory_variable_hash_set.h @@ -21,7 +21,7 @@ #include "common/eqemu_exception.h" #include "common/types.h" -#include +#include namespace EQ { diff --git a/common/http/httplib.h b/common/http/httplib.h index 3c024f9f0..9ade6d9ef 100644 --- a/common/http/httplib.h +++ b/common/http/httplib.h @@ -272,7 +272,7 @@ inline const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *asn1) { #include #endif -#include "../strings.h" +#include "common/strings.h" /* * Declaration diff --git a/common/item_instance.cpp b/common/item_instance.cpp index c624140e0..64ae0b4cc 100644 --- a/common/item_instance.cpp +++ b/common/item_instance.cpp @@ -24,7 +24,7 @@ #include "common/shareddb.h" #include "common/strings.h" -#include +#include int32 next_item_serial_number = 1; std::unordered_set guids{}; diff --git a/common/light_source.cpp b/common/light_source.cpp index 1574144ad..e4f5336c6 100644 --- a/common/light_source.cpp +++ b/common/light_source.cpp @@ -19,7 +19,7 @@ #include "light_source.h" -#include +#include uint8 EQ::lightsource::TypeToLevel(uint8 light_type) { diff --git a/common/md5.cpp b/common/md5.cpp index 2326fc5e7..16328d695 100644 --- a/common/md5.cpp +++ b/common/md5.cpp @@ -13,7 +13,7 @@ #include "common/strings.h" #include "common/seperator.h" -#include /* for memcpy() */ +#include /* for memcpy() */ MD5::MD5() { memset(pMD5, 0, 16); diff --git a/common/memory_buffer.h b/common/memory_buffer.h index bd191d4a5..3f4ab031b 100644 --- a/common/memory_buffer.h +++ b/common/memory_buffer.h @@ -21,8 +21,8 @@ #include "common/types.h" +#include #include -#include #include #include diff --git a/common/misc.cpp b/common/misc.cpp index 52e5086bb..f3e436ae5 100644 --- a/common/misc.cpp +++ b/common/misc.cpp @@ -4,13 +4,13 @@ #include "common/types.h" #include "zlib.h" +#include +#include #include +#include #include #include -#include -#include #include -#include std::map DBFieldNames; diff --git a/common/misc.h b/common/misc.h index e43bf34c3..d488e854a 100644 --- a/common/misc.h +++ b/common/misc.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #define ITEMFIELDCOUNT 116 diff --git a/common/misc_functions.cpp b/common/misc_functions.cpp index a01e7ce5e..c4bcb7d8e 100644 --- a/common/misc_functions.cpp +++ b/common/misc_functions.cpp @@ -18,69 +18,20 @@ #include "misc_functions.h" +#include "common/platform/inet.h" +#include "common/platform/platform.h" #include "common/seperator.h" #include "common/strings.h" #include "common/timer.h" +#include "common/types.h" -#include -#include -#include -#include +#include -#ifdef _WINDOWS -#include -#include -#include -#define snprintf _snprintf -#else -#include -#include -#include -#include -#include -#include -#include -#ifdef FREEBSD //Timothy Whitman - January 7, 2003 -#include -#include -#endif +#ifndef _WINDOWS #include -#include #include -#include #endif -void CoutTimestamp(bool ms) { - time_t rawtime; - struct tm* gmt_t; - time(&rawtime); - gmt_t = gmtime(&rawtime); - - struct timeval read_time; - gettimeofday(&read_time,0); - - std::cout << (gmt_t->tm_year + 1900) << "/" << std::setw(2) << std::setfill('0') << (gmt_t->tm_mon + 1) << "/" << std::setw(2) << std::setfill('0') << gmt_t->tm_mday << " " << std::setw(2) << std::setfill('0') << gmt_t->tm_hour << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_min << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_sec; - if (ms) - std::cout << "." << std::setw(3) << std::setfill('0') << (read_time.tv_usec / 1000); - std::cout << " GMT"; -} - - -int32 filesize(FILE* fp) { -#ifdef _WINDOWS - return _filelength(_fileno(fp)); -#else - struct stat file_stat; - fstat(fileno(fp), &file_stat); - return (int32) file_stat.st_size; -/* uint32 tmp = 0; - while (!feof(fp)) { - fseek(fp, tmp++, SEEK_SET); - } - return tmp;*/ -#endif -} - uint32 ResolveIP(const char* hostname, char* errbuf) { #ifdef _WINDOWS static InitWinsock ws; @@ -140,7 +91,6 @@ InitWinsock::InitWinsock() { InitWinsock::~InitWinsock() { WSACleanup(); } - #endif diff --git a/common/misc_functions.h b/common/misc_functions.h index 2590877ca..1db55e466 100644 --- a/common/misc_functions.h +++ b/common/misc_functions.h @@ -20,10 +20,6 @@ #include "common/types.h" -#include -#include - - #ifndef ERRBUF_SIZE #define ERRBUF_SIZE 1024 #endif @@ -46,10 +42,9 @@ return; \ } -int32 filesize(FILE* fp); uint32 ResolveIP(const char* hostname, char* errbuf = 0); bool ParseAddress(const char* iAddress, uint32* oIP, uint16* oPort, char* errbuf = 0); -void CoutTimestamp(bool ms = true); + float EQ13toFloat(int d); float EQ19toFloat(int d); float EQHtoFloat(int d); diff --git a/common/net/reliable_stream_connection.h b/common/net/reliable_stream_connection.h index e3f4f16d2..756857c77 100644 --- a/common/net/reliable_stream_connection.h +++ b/common/net/reliable_stream_connection.h @@ -12,7 +12,6 @@ #include #include #include -#include namespace EQ { diff --git a/common/opcodemgr.cpp b/common/opcodemgr.cpp index 771fb439c..b761f3b8c 100644 --- a/common/opcodemgr.cpp +++ b/common/opcodemgr.cpp @@ -21,9 +21,9 @@ #include "common/emu_opcodes.h" #include "common/eqemu_logsys.h" +#include #include #include -#include #include OpcodeManager::OpcodeManager() { diff --git a/common/packet_dump.cpp b/common/packet_dump.cpp index 33c719605..8e638768f 100644 --- a/common/packet_dump.cpp +++ b/common/packet_dump.cpp @@ -20,10 +20,10 @@ #include "common/servertalk.h" +#include #include #include #include -#include void DumpPacketAscii(const uchar* buf, uint32 size, uint32 cols, uint32 skip) { // Output as ASCII diff --git a/common/packet_functions.cpp b/common/packet_functions.cpp index 4979f6d6b..4783db927 100644 --- a/common/packet_functions.cpp +++ b/common/packet_functions.cpp @@ -22,9 +22,8 @@ #include "common/platform/inet.h" #include "zlib.h" -#include +#include #include -#include void EncryptProfilePacket(EQApplicationPacket* app) { //EncryptProfilePacket(app->pBuffer, app->size); diff --git a/common/pch/std-pch.h b/common/pch/std-pch.h index 77ca1ce6f..f8428dda5 100644 --- a/common/pch/std-pch.h +++ b/common/pch/std-pch.h @@ -4,11 +4,16 @@ #include "fmt/format.h" // Lightweight, widely used +#include #include +#include #include +#include #include #include #include +#include #include +#include #include #include diff --git a/common/proc_launcher.cpp b/common/proc_launcher.cpp index 80415fe21..9b1113924 100644 --- a/common/proc_launcher.cpp +++ b/common/proc_launcher.cpp @@ -20,6 +20,9 @@ #include "common/types.h" +#include +#include +#include #include #include @@ -28,14 +31,11 @@ #else #include #include -#include -#include #include #include #include #include #include -#include #endif ProcLauncher ProcLauncher::s_launcher; diff --git a/common/proc_launcher.h b/common/proc_launcher.h index 5f1f7efff..5a9aa421e 100644 --- a/common/proc_launcher.h +++ b/common/proc_launcher.h @@ -19,6 +19,7 @@ #pragma once #include "common/platform/platform.h" +#include "common/types.h" #include #include diff --git a/common/profanity_manager.cpp b/common/profanity_manager.cpp index b25445996..200d11f91 100644 --- a/common/profanity_manager.cpp +++ b/common/profanity_manager.cpp @@ -24,8 +24,8 @@ #include "common/strings.h" #include +#include #include -#include static std::list profanity_list; diff --git a/common/random.h b/common/random.h index a55dece0f..86dfe9b2b 100644 --- a/common/random.h +++ b/common/random.h @@ -19,7 +19,6 @@ #pragma once #include -#include #include #include #include diff --git a/common/seperator.h b/common/seperator.h index f4d6ac380..443f1bf59 100644 --- a/common/seperator.h +++ b/common/seperator.h @@ -25,8 +25,8 @@ #include "common/types.h" -#include -#include +#include +#include class Seperator { diff --git a/common/serialize_buffer.h b/common/serialize_buffer.h index c05456f05..1155d7506 100644 --- a/common/serialize_buffer.h +++ b/common/serialize_buffer.h @@ -3,6 +3,7 @@ #include #include +#include #include #include diff --git a/common/server_event_scheduler.cpp b/common/server_event_scheduler.cpp index 5e964f38b..b7294c5ce 100644 --- a/common/server_event_scheduler.cpp +++ b/common/server_event_scheduler.cpp @@ -5,8 +5,8 @@ #include "common/strings.h" #include +#include #include -#include ServerEventScheduler::ServerEventScheduler() { diff --git a/common/server_event_scheduler.h b/common/server_event_scheduler.h index a3c48e9fd..480f4460e 100644 --- a/common/server_event_scheduler.h +++ b/common/server_event_scheduler.h @@ -2,7 +2,7 @@ #include "common/repositories/server_scheduled_events_repository.h" -#include +#include #include namespace ServerEvents { diff --git a/common/servertalk.h b/common/servertalk.h index 121d6d7de..b41e998a5 100644 --- a/common/servertalk.h +++ b/common/servertalk.h @@ -440,6 +440,7 @@ public: uint32 destination; }; +#pragma pack(push) #pragma pack(1) struct SPackSendQueue { diff --git a/common/skills.cpp b/common/skills.cpp index 85fae5a27..96a7ca27d 100644 --- a/common/skills.cpp +++ b/common/skills.cpp @@ -21,7 +21,7 @@ #include "common/classes.h" -#include +#include bool EQ::skills::IsTradeskill(SkillType skill) { diff --git a/common/types.h b/common/types.h index bb4b39a83..ca00c76b2 100644 --- a/common/types.h +++ b/common/types.h @@ -19,6 +19,7 @@ #pragma once #include + typedef uint8_t byte; typedef uint8_t uint8; typedef uint16_t uint16; @@ -44,7 +45,7 @@ typedef const char Const_char; //for perl XS #ifdef _WINDOWS #if (!defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1900)) - #define snprintf _snprintf + #define snprintf _snprintf #endif #define strncasecmp _strnicmp #define strcasecmp _stricmp diff --git a/common/unix.cpp b/common/unix.cpp index 45702280c..afe3bfef6 100644 --- a/common/unix.cpp +++ b/common/unix.cpp @@ -19,8 +19,8 @@ #include "unix.h" -#include -#include +#include +#include void Sleep(unsigned int x) { if (x > 0)