// Copyright (C) 2007 EQ2EMulator Development Team - GPL v3+ License #pragma once #include #include using namespace std; // Safe string to unsigned long conversion #define atoul(str) strtoul(str, NULL, 10) // Safe string to 64-bit integer conversion #define atoi64(str) strtoll(str, NULL, 10) // Legacy type definitions for backward compatibility typedef unsigned char int8; typedef unsigned short int16; typedef unsigned int int32; typedef unsigned char uint8; typedef signed char sint8; typedef unsigned short uint16; typedef signed short sint16; typedef unsigned int uint32; typedef signed int sint32; typedef unsigned long long int64; typedef unsigned long long uint64; typedef signed long long sint64; typedef unsigned long ulong; typedef unsigned short ushort; typedef unsigned char uchar; // Thread return type for Linux systems typedef void* ThreadReturnType; typedef int SOCKET; #define THREAD_RETURN(x) return(x); // Safe deletion macros #define safe_delete(d) if(d) { delete d; d=0; } #define safe_delete_array(d) if(d) { delete[] d; d=0; } // Bit manipulation macros #define L32(i) ((int32) i) #define H32(i) ((int32) (i >> 32)) #define L16(i) ((int16) i) // Windows compatibility types for Linux typedef unsigned long DWORD; typedef unsigned char BYTE; typedef char CHAR; typedef unsigned short WORD; typedef float FLOAT; typedef FLOAT *PFLOAT; typedef BYTE *PBYTE,*LPBYTE; typedef int *PINT,*LPINT; typedef WORD *PWORD,*LPWORD; typedef long *LPLONG, LONG; typedef DWORD *PDWORD,*LPDWORD; typedef int INT; typedef unsigned int UINT,*PUINT,*LPUINT; // DLL function export macro for Linux #define DLLFUNC extern "C" #pragma pack(1) /** * Provides byte-level access to a 16-bit unsigned integer * Allows manipulation of individual bytes within the value */ struct uint16_breakdown { union { uint16 all; struct { uint8 b1; uint8 b2; } bytes; }; // Assignment operator - sets the entire 16-bit value inline uint16& operator=(const uint16& val) { return (all=val); } // Address operator - returns pointer to the 16-bit value inline uint16* operator&() { return &all; } // Conversion operator - allows implicit conversion to uint16 inline operator uint16&() { return all; } // Access to first byte of the 16-bit value inline uint8& b1() { return bytes.b1; } // Access to second byte of the 16-bit value inline uint8& b2() { return bytes.b2; } }; /** * Provides word and byte-level access to a 32-bit unsigned integer * Allows manipulation of individual words and bytes within the value */ struct uint32_breakdown { union { uint32 all; struct { uint16 w1; uint16 w2; } words; struct { uint8 b1; union { struct { uint8 b2; uint8 b3; } middle; uint16 w2_3; // word bytes 2 to 3 }; uint8 b4; } bytes; }; // Assignment operator - sets the entire 32-bit value inline uint32& operator=(const uint32& val) { return (all=val); } // Address operator - returns pointer to the 32-bit value inline uint32* operator&() { return &all; } // Conversion operator - allows implicit conversion to uint32 inline operator uint32&() { return all; } // Access to first word (bits 0-15) of the 32-bit value inline uint16& w1() { return words.w1; } // Access to second word (bits 16-31) of the 32-bit value inline uint16& w2() { return words.w2; } // Access to combined bytes 2-3 as a word inline uint16& w2_3() { return bytes.w2_3; } // Access to first byte of the 32-bit value inline uint8& b1() { return bytes.b1; } // Access to second byte of the 32-bit value inline uint8& b2() { return bytes.middle.b2; } // Access to third byte of the 32-bit value inline uint8& b3() { return bytes.middle.b3; } // Access to fourth byte of the 32-bit value inline uint8& b4() { return bytes.b4; } }; /** * String structure with 32-bit size prefix * Used for network protocol serialization */ struct EQ2_32BitString { int32 size; // Length of the string data string data; // The actual string content }; /** * String structure with 16-bit size prefix * Used for network protocol serialization with smaller strings */ struct EQ2_16BitString { int16 size; // Length of the string data string data; // The actual string content }; /** * String structure with 8-bit size prefix * Used for network protocol serialization with very small strings */ struct EQ2_8BitString { int8 size; // Length of the string data string data; // The actual string content }; /** * RGB color representation * Each component ranges from 0-255 */ struct EQ2_Color { int8 red; // Red component (0-255) int8 green; // Green component (0-255) int8 blue; // Blue component (0-255) }; /** * Game world time representation * Stores the current in-game date and time */ struct WorldTime { int16 year; // Game year int month; // Month (1-12) int day; // Day of month int hour; // Hour (0-23) int minute; // Minute (0-59) }; /** * Database query type enumeration * Defines the different types of SQL operations */ typedef enum QUERY_TYPE { Q_SELECT, // SELECT query for data retrieval Q_UPDATE, // UPDATE query for modifying existing records Q_REPLACE, // REPLACE query for insert-or-update operations Q_INSERT, // INSERT query for adding new records Q_DELETE, // DELETE query for removing records Q_DBMS // Database management system query } QUERY_TYPE; #pragma pack()