remove global_define.h and adjust platform header includes

- Remove unused MRMutex
- Remove unused generate_key
This commit is contained in:
brainiac 2025-12-18 00:40:06 -08:00 committed by Alex
parent b95016c92f
commit c191ec02d4
59 changed files with 37 additions and 330 deletions

View File

@ -23,7 +23,6 @@
#include "common/events/player_event_logs.h"
#include "common/evolving_items.h"
#include "common/file.h"
#include "common/global_define.h"
#include "common/path_manager.h"
#include "common/platform.h"
#include "common/repositories/base_data_repository.h"

View File

@ -23,7 +23,6 @@
#include "common/events/player_event_logs.h"
#include "common/evolving_items.h"
#include "common/file.h"
#include "common/global_define.h"
#include "common/path_manager.h"
#include "common/platform.h"
#include "common/repositories/base_data_repository.h"

View File

@ -604,7 +604,6 @@ set(common_headers
file.h
fixed_memory_hash_set.h
fixed_memory_variable_hash_set.h
global_define.h
guild_base.h
guilds.h
http/httplib.h

View File

@ -14,7 +14,7 @@
// so we need not to check the version (because we only support _MSC_VER >= 1100)!
#pragma once
#include <windows.h>
#include "common/platform/win/include_windows.h"
// special defines for VC5/6 (if no actual PSDK is installed):
#if _MSC_VER < 1300

View File

@ -17,7 +17,6 @@
*/
#include "common/base_packet.h"
#include "common/global_define.h"
#include "common/misc.h"
#include "common/packet_dump.h"

View File

@ -18,20 +18,11 @@
#pragma once
#include "common/platform/inet.h"
#include "common/serialize_buffer.h"
#include "common/types.h"
#include <cstdio>
#include <cstring>
#ifdef _WINDOWS
#include <time.h>
#include <winsock2.h>
#include <windows.h>
#else
#include <sys/time.h>
#include <netinet/in.h>
#endif
class BasePacket {
public:

View File

@ -1,7 +1,5 @@
#include "bodytypes.h"
#include "common/global_define.h"
std::string BodyType::GetName(uint8 body_type_id)
{
return IsValid(body_type_id) ? body_type_names[body_type_id] : "UNKNOWN BODY TYPE";

View File

@ -19,7 +19,6 @@
#include "classes.h"
#include "common/data_verification.h"
#include "common/global_define.h"
#include "fmt/format.h"

View File

@ -1,6 +1,5 @@
#include "compression.h"
#include "common/global_define.h"
#include "common/types.h"
#include "zlib.h"

View File

@ -18,11 +18,9 @@
#pragma once
#include "common/global_define.h"
#include "common/mutex.h"
#ifndef WIN32
#include <pthread.h>
#endif
#include "common/platform/posix/include_pthreads.h"
#include "common/platform/win/include_windows.h"
//Sombody, someday needs to figure out how to implement a condition
//system on windows...

View File

@ -2,7 +2,6 @@
#include "common/eqemu_config.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/http/httplib.h"
#include "common/http/uri.h"
#include "common/json/json.h"
@ -16,10 +15,6 @@
#include <cstdio>
#include <vector>
#ifdef _WINDOWS
#define popen _popen
#endif
void SendCrashReport(const std::string &crash_report)
{
// can configure multiple endpoints if need be

View File

@ -22,9 +22,9 @@
#include "common/eq_packet_structs.h"
#include "common/events/player_event_logs.h"
#include "common/extprofile.h"
#include "common/global_define.h"
#include "common/http/httplib.h"
#include "common/http/uri.h"
#include "common/platform/win/include_windows.h"
#include "common/repositories/account_repository.h"
#include "common/repositories/adventure_stats_repository.h"
#include "common/repositories/bot_data_repository.h"
@ -56,29 +56,9 @@
#include "common/strings.h"
#include "common/zone_store.h"
#include "mysqld_error.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <algorithm>
// Disgrace: for windows compile
#ifdef _WINDOWS
#include <windows.h>
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else
#include "unix.h"
#include <netinet/in.h>
#include <sys/time.h>
#endif
extern Client client;
Database::Database() { }

View File

@ -21,7 +21,6 @@
#include "common/dbcore.h"
#include "common/eq_packet_structs.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/linked_list.h"
#include "common/types.h"

View File

@ -28,17 +28,10 @@
#include "common/strings.h"
#include "common/termcolor/rang.hpp"
#include <cstdio>
#include <ctime>
#include <iterator>
#include <string>
#if _WIN32
#include <windows.h>
#else
#include <sys/time.h>
#include <thread>
#endif
#define DATABASE_DUMP_PATH "backups/"

View File

@ -18,7 +18,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "database.h"
#include "common/global_define.h"
#include "common/platform/inet.h"
#include "common/platform/platform"
#include "common/platform/win/include_windows.h"
#include "common/repositories/character_corpses_repository.h"
#include "common/repositories/data_buckets_repository.h"
#include "common/repositories/dynamic_zone_members_repository.h"
@ -34,22 +36,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "common/rulesys.h"
#include "common/strings.h"
#include "common/timer.h"
#include <iomanip>
#include <iostream>
// Disgrace: for windows compile
#ifdef _WINDOWS
#include <windows.h>
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else
#include "common/unix.h"
#include "zone/zonedb.h"
#include <netinet/in.h>
#include <sys/time.h>
#endif
bool Database::AddClientToInstance(uint16 instance_id, uint32 character_id)

View File

@ -17,7 +17,6 @@
*/
#include "common/emu_opcodes.h"
#include "common/global_define.h"
const char *OpcodeNames[_maxEmuOpcode+1] = {
"OP_Unknown",

View File

@ -18,7 +18,6 @@
#include "eq_packet.h"
#include "common/global_define.h"
#include "common/misc.h"
#include "common/op_codes.h"
#ifndef STATIC_OPCODE

View File

@ -2,7 +2,6 @@
#include "common/eq_stream_ident.h"
#include "common/eq_stream_proxy.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/misc.h"
#include <utility>

View File

@ -2,7 +2,6 @@
#include "eq_stream_proxy.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/opcodemgr.h"
#include "common/struct_strategy.h"

View File

@ -19,7 +19,6 @@
#include "eqdb.h"
#include "common/database.h"
#include "common/global_define.h"
#include "mysql.h"
#include <cstring>

View File

@ -18,7 +18,6 @@
#include "eqdb_res.h"
#include "common/global_define.h"
#include "mysql.h"
std::vector<std::string> EQDBRes::fetch_row_array() {

View File

@ -19,7 +19,6 @@
#include "eqemu_config.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/json/json.hpp"
#include "common/misc_functions.h"
#include "common/strings.h"

View File

@ -20,19 +20,11 @@
#include "common/eq_packet_structs.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include <fstream>
#include <iostream>
#include <memory.h>
/*#ifdef _CRTDBG_MAP_ALLOC
#undef new
#endif*/
/*#ifdef _CRTDBG_MAP_ALLOC
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif*/
#define EQT_VERSION 1000
//Constructor

View File

@ -1,8 +1,7 @@
#pragma once
#include "uv.h"
#include <functional>
#include "common/platform/win/include_windows.h" // uv.h is going to include it so lets do it first.
#include "uv.h" // FIXME: hide this
namespace EQ
{

View File

@ -18,8 +18,6 @@
#include "extprofile.h"
#include "common/global_define.h"
//Set defaults in the extended profile...
void InitExtendedProfile(ExtendedProfile_Struct *p) {
memset(p, 0, sizeof(ExtendedProfile_Struct));

View File

@ -17,17 +17,3 @@
*/
#pragma once
// WHY IS THIS UP HERE
#if defined(_DEBUG) && defined(WIN32)
#ifndef _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#endif
#endif
#ifdef _WINDOWS
#include <winsock2.h>
#include <windows.h>
#endif

View File

@ -1,6 +1,5 @@
#include "misc.h"
#include "common/global_define.h"
#include "common/strings.h"
#include "common/types.h"
@ -12,9 +11,6 @@
#include <stdlib.h>
#include <string>
#include <time.h>
#ifndef WIN32
#include <sys/time.h>
#endif
std::map<int,std::string> DBFieldNames;
@ -341,23 +337,6 @@ char *bptr;
return (bptr-buffer);
}
std::string generate_key(int length)
{
std::string key;
//TODO: write this for win32...
#ifndef WIN32
int i;
timeval now;
static const char *chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for(i=0;i<length;i++) {
gettimeofday(&now,nullptr);
srand(now.tv_sec^now.tv_usec);
key+=(char)chars[(int) (36.0*rand()/(RAND_MAX+1.0))];
}
#endif
return key;
}
void print_hex(const char *data, unsigned long length) {
char buffer[80];
uint32 offset;

View File

@ -24,6 +24,5 @@ std::string timestamp(time_t now=0);
std::string long2ip(unsigned long ip);
std::string pop_arg(std::string &s, std::string seps, bool obey_quotes);
int EQsprintf(char *buffer, const char *pattern, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5, const char *arg6, const char *arg7, const char *arg8, const char *arg9);
std::string generate_key(int length);
void build_hex_line(const char *buffer, unsigned long length, unsigned long offset, char *out_buffer, unsigned char padding=4);
void print_hex(const char *buffer, unsigned long length);

View File

@ -18,7 +18,6 @@
#include "misc_functions.h"
#include "common/global_define.h"
#include "common/seperator.h"
#include "common/strings.h"
#include "common/timer.h"
@ -30,11 +29,9 @@
#ifdef _WINDOWS
#include <io.h>
#include <windows.h>
#include <Windows.h>
#include <WinSock2.h>
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else
#include <netinet/in.h>
#include <sys/socket.h>

View File

@ -18,8 +18,6 @@
#include "mutex.h"
#include "common/global_define.h"
#include <iostream>
#define DEBUG_MUTEX_CLASS 0
@ -163,100 +161,3 @@ void LockMutex::lock() {
mut->lock();
locked = true;
}
MRMutex::MRMutex() {
rl = 0;
wr = 0;
rl = 0;
}
MRMutex::~MRMutex() {
#ifdef _EQDEBUG
if (wl || rl) {
std::cout << "MRMutex::~MRMutex: poor cleanup detected: rl=" << rl << ", wl=" << wl << std::endl;
}
#endif
}
void MRMutex::ReadLock() {
while (!TryReadLock()) {
Sleep(1);
}
}
bool MRMutex::TryReadLock() {
MCounters.lock();
if (!wr && !wl) {
rl++;
MCounters.unlock();
return true;
}
else {
MCounters.unlock();
return false;
}
}
void MRMutex::UnReadLock() {
MCounters.lock();
rl--;
MCounters.unlock();
}
void MRMutex::WriteLock() {
MCounters.lock();
if (!rl && !wl) {
wl++;
MCounters.unlock();
return;
}
else {
wr++;
MCounters.unlock();
while (1) {
Sleep(1);
MCounters.lock();
if (!rl && !wl) {
wr--;
MCounters.unlock();
return;
}
MCounters.lock();
}
}
}
bool MRMutex::TryWriteLock() {
MCounters.lock();
if (!rl && !wl) {
wl++;
MCounters.unlock();
return true;
}
else {
MCounters.unlock();
return false;
}
}
void MRMutex::UnWriteLock() {
MCounters.lock();
wl--;
MCounters.unlock();
}
int32 MRMutex::ReadLockCount() {
MCounters.lock();
int32 ret = rl;
MCounters.unlock();
return ret;
}
int32 MRMutex::WriteLockCount() {
MCounters.lock();
int32 ret = wl;
MCounters.unlock();
return ret;
}

View File

@ -19,14 +19,8 @@
#pragma once
#include "common/types.h"
#ifdef _WINDOWS
#include <winsock2.h>
#include <windows.h>
#else
#include "common/unix.h"
#include <pthread.h>
#endif
#include "common/platform/posix/include_pthreads.h"
#include "common/platform/win/include_windows.h"
class Mutex {
public:
@ -38,7 +32,7 @@ public:
bool trylock();
protected:
private:
#if defined WIN32 || defined WIN64
#if defined _WINDOWS
CRITICAL_SECTION CSMutex;
#else
pthread_mutex_t CSMutex;
@ -55,28 +49,3 @@ private:
bool locked;
Mutex* mut;
};
// Somewhat untested...
// Multi-read, single write mutex -Quagmire
class MRMutex {
public:
MRMutex();
~MRMutex();
void ReadLock();
bool TryReadLock();
void UnReadLock();
void WriteLock();
bool TryWriteLock();
void UnWriteLock();
int32 ReadLockCount();
int32 WriteLockCount();
private:
int32 rl; // read locks in effect
int32 wr; // write lock requests pending
int32 wl; // write locks in effect (should never be more than 1)
Mutex MCounters;
};

View File

@ -1,5 +1,3 @@
#include "common/global_define.h"
#include <map>
#include <string>

View File

@ -16,29 +16,17 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "common/global_define.h"
#include "packet_dump_file.h"
#include "common/eq_stream_intf.h"
#include <cstdarg>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
//#ifdef _CRTDBG_MAP_ALLOC
// #undef new
// #define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
//#endif
#include <string.h>
#ifdef _WINDOWS
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else
#include <stdarg.h>
#endif
#include "eq_stream_intf.h"
#include "packet_dump_file.h"
void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
std::ofstream logfile(filename, std::ios::app);

View File

@ -20,8 +20,6 @@
#include "common/types.h"
#include <iostream>
class EQApplicationPacket;
void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, uint32 cols=16, uint32 skip=0);

View File

@ -18,16 +18,13 @@
#include "packet_functions.h"
#include "common/global_define.h"
#include "common/packet_dump.h"
#include "common/platform/inet.h"
#include "zlib.h"
#include <iomanip>
#include <iostream>
#include <string.h>
#ifndef WIN32
#include <netinet/in.h>
#endif
void EncryptProfilePacket(EQApplicationPacket* app) {
//EncryptProfilePacket(app->pBuffer, app->size);

View File

@ -19,7 +19,6 @@
#include "patches.h"
#include "common/global_define.h"
#include "common/patches/rof.h"
#include "common/patches/rof2.h"
#include "common/patches/sod.h"

View File

@ -25,7 +25,6 @@
#include "common/eq_stream_ident.h"
#include "common/eqemu_config.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/inventory_profile.h"
#include "common/misc_functions.h"
#include "common/opcodemgr.h"

View File

@ -26,7 +26,6 @@
#include "common/eq_stream_ident.h"
#include "common/eqemu_config.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/inventory_profile.h"
#include "common/misc_functions.h"
#include "common/opcodemgr.h"

View File

@ -25,7 +25,6 @@
#include "common/eq_stream_ident.h"
#include "common/eqemu_config.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/item_instance.h"
#include "common/misc_functions.h"
#include "common/opcodemgr.h"

View File

@ -25,7 +25,6 @@
#include "common/eq_stream_ident.h"
#include "common/eqemu_config.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/item_instance.h"
#include "common/misc_functions.h"
#include "common/opcodemgr.h"

View File

@ -25,7 +25,6 @@
#include "common/eq_stream_ident.h"
#include "common/eqemu_config.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/guilds.h"
#include "common/item_instance.h"
#include "common/misc_functions.h"

View File

@ -26,7 +26,6 @@
#include "common/eq_stream_ident.h"
#include "common/eqemu_config.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/guilds.h"
#include "common/item_instance.h"
#include "common/misc_functions.h"

View File

@ -6,4 +6,3 @@
#include "common/eqemu_logsys.h"
#include "common/eqemu_logsys_log_aliases.h"
#include "common/features.h"
#include "common/global_define.h"

View File

@ -28,7 +28,6 @@
typedef const char Const_char;
#ifdef EMBPERL
#include "common/global_define.h"
#include "common/eqdb.h"
#include "common/useperl.h"

View File

@ -28,7 +28,6 @@
typedef const char Const_char;
#ifdef EMBPERL
#include "common/global_define.h"
#include "common/eqdb_res.h"
#include "common/useperl.h"

View File

@ -3,5 +3,5 @@
#ifdef _WINDOWS
#include "common/platform/win/include_windows.h"
#else
#include <unistd.h>
#include "common/unix.h"
#endif

View File

@ -18,13 +18,13 @@
#include "proc_launcher.h"
#include "common/global_define.h"
#include "common/types.h"
#include <string>
#include <vector>
#ifdef _WINDOWS
#include <windows.h>
#include "common/platform/win/include_windows.h"
#else
#include <sys/types.h>
#include <sys/wait.h>

View File

@ -18,16 +18,12 @@
#pragma once
#include "common/global_define.h"
#include "common/platform/platform.h"
#include <map>
#include <string>
#include <vector>
#ifdef __FreeBSD__
#include <unistd.h>
#endif
//I forced this object to become a singleton because it registers its
//signal handler for UNIX
class ProcLauncher {

View File

@ -19,7 +19,6 @@
#include "ptimer.h"
#include "common/database.h"
#include "common/global_define.h"
#include "common/strings.h"
#include "common/timer.h"

View File

@ -5,8 +5,6 @@
#include "common/database.h"
#include "common/strings.h"
#include <boost/tuple/tuple_comparison.hpp>
class CharacterEvolvingItemsRepository: public BaseCharacterEvolvingItemsRepository {
public:
// Custom extended repository methods here

View File

@ -5,6 +5,7 @@
#include "common/database.h"
#include "common/dynamic_zone_lockout.h"
#include "common/strings.h"
#include "fmt/ranges.h"
#include <unordered_map>

View File

@ -2,7 +2,6 @@
#include "common/eq_stream_intf.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/opcodemgr.h"
#include <map>

View File

@ -18,8 +18,6 @@
#include "timeoutmgr.h"
#include "common/global_define.h"
//#define TIMEOUT_DEBUG
Timeoutable::Timeoutable(uint32 check_frequency)

View File

@ -20,9 +20,11 @@
// Disgrace: for windows compile
#ifndef WIN32
#include <sys/time.h>
#include <sys/time.h>
#else
#include <sys/timeb.h>
#include <sys/timeb.h>
#include <WinSock2.h>
#undef GetCurrentTime
#endif
uint32 current_time = 0;

View File

@ -22,8 +22,8 @@
// Disgrace: for windows compile
#ifdef _WINDOWS
#include "global_define.h"
int gettimeofday (timeval *tp, ...);
struct timeval;
int gettimeofday (timeval *tp, ...);
#endif
#include <chrono>

View File

@ -14,10 +14,7 @@
* Include windows.h without Windows Sockets 1.1 to prevent conflicts with
* Windows Sockets 2.0.
*/
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include "common/platform/win/include_windows.h"
#include <stdio.h>
#include <stdarg.h>

View File

@ -19,7 +19,6 @@
#include "common/crash.h"
#include "common/eqemu_config.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/path_manager.h"
#include "common/platform.h"
#include "common/proc_launcher.h"
@ -28,11 +27,10 @@
#include "eqlaunch/worldserver.h"
#include "eqlaunch/zone_launch.h"
#include <vector>
#include <csignal>
#include <ctime>
#include <map>
#include <set>
#include <signal.h>
#include <time.h>
bool RunLoops = false;

View File

@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "common/eqemu_config.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "common/servertalk.h"
#include "common/strings.h"
#include "eqlaunch/zone_launch.h"

View File

@ -20,7 +20,6 @@
#include "common/eqemu_config.h"
#include "common/eqemu_logsys.h"
#include "common/global_define.h"
#include "eqlaunch/worldserver.h"
//static const uint32 ZONE_RESTART_DELAY = 10000;