From 375998dffb0b316fd12ca82e72a9bff1c02bd594 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 22 Jan 2025 15:09:18 +0300 Subject: [PATCH] Cleanup xash3d_types.h from engine-specific macros and types --- 3rdparty/mainui | 2 +- common/xash3d_types.h | 71 +++++++++++------------------------ engine/client/client.h | 1 + engine/client/sound.h | 2 + engine/common/common.h | 14 +++++-- engine/common/cvar.h | 2 + engine/common/system.h | 9 +++++ engine/platform/sdl/sys_sdl.c | 6 +-- engine/server/server.h | 1 + filesystem/filesystem.h | 2 + public/crtlib.h | 6 +++ 11 files changed, 58 insertions(+), 58 deletions(-) diff --git a/3rdparty/mainui b/3rdparty/mainui index 734a6d1ca2..695ea1be2e 160000 --- a/3rdparty/mainui +++ b/3rdparty/mainui @@ -1 +1 @@ -Subproject commit 734a6d1ca26e9ca0965aa868c69c4da5ad76ab50 +Subproject commit 695ea1be2e546a50586bc74e8d148bbe566f7931 diff --git a/common/xash3d_types.h b/common/xash3d_types.h index f246f16e6d..ecac1ffb82 100644 --- a/common/xash3d_types.h +++ b/common/xash3d_types.h @@ -16,19 +16,17 @@ #include STDINT_H #include -typedef unsigned char byte; -typedef int sound_t; -typedef float vec_t; -typedef vec_t vec2_t[2]; -typedef vec_t vec3_t[3]; -typedef vec_t vec4_t[4]; -typedef vec_t quat_t[4]; -typedef byte rgba_t[4]; // unsigned byte colorpack -typedef byte rgb_t[3]; // unsigned byte colorpack -typedef vec_t matrix3x4[3][4]; -typedef vec_t matrix4x4[4][4]; - -typedef uint32_t poolhandle_t; +typedef uint8_t byte; +typedef float vec_t; +typedef vec_t vec2_t[2]; +typedef vec_t vec3_t[3]; +typedef vec_t vec4_t[4]; +typedef vec_t quat_t[4]; +typedef byte rgba_t[4]; // unsigned byte colorpack +typedef byte rgb_t[3]; // unsigned byte colorpack +typedef vec_t matrix3x4[3][4]; +typedef vec_t matrix4x4[4][4]; +typedef uint32_t poolhandle_t; #undef true #undef false @@ -39,18 +37,10 @@ typedef enum { false, true } qboolean; typedef int qboolean; #endif -typedef uint64_t longtime_t; - -#define MAX_STRING 256 // generic string -#define MAX_INFO_STRING 256 // infostrings are transmitted across network -#define MAX_SERVERINFO_STRING 512 // server handles too many settings. expand to 1024? -#define MAX_LOCALINFO_STRING 32768 // localinfo used on server and not sended to the clients -#define MAX_SYSPATH 1024 // system filepath -#define MAX_VA_STRING 1024 // string length returned by va() -#define MAX_PRINT_MSG 8192 // how many symbols can handle single call of Con_Printf or Con_DPrintf -#define MAX_TOKEN 2048 // parse token length -#define MAX_MODS 512 // environment games that engine can keep visible -#define MAX_USERMSG_LENGTH 2048 // don't modify it's relies on a client-side definitions +#define MAX_STRING 256 // generic string +#define MAX_VA_STRING 1024 // compatibility macro +#define MAX_SYSPATH 1024 // system filepath +#define MAX_MODS 512 // environment games that engine can keep visible #define BIT( n ) ( 1U << ( n )) #define BIT64( n ) ( 1ULL << ( n )) @@ -209,35 +199,16 @@ _inline float LittleFloat( float f ) #endif -typedef unsigned int dword; -typedef unsigned int uint; -typedef unsigned long ulong; -typedef char string[MAX_STRING]; -typedef struct file_s file_t; // normal file -typedef struct stream_s stream_t; // sound stream for background music playing -typedef off_t fs_offset_t; +typedef unsigned int dword; +typedef unsigned int uint; +typedef char string[MAX_STRING]; +typedef off_t fs_offset_t; #if XASH_WIN32 -typedef int fs_size_t; // return type of _read, _write funcs +typedef int fs_size_t; // return type of _read, _write funcs #else /* !XASH_WIN32 */ -typedef ssize_t fs_size_t; +typedef ssize_t fs_size_t; #endif /* !XASH_WIN32 */ -typedef struct dllfunc_s -{ - const char *name; - void **func; -} dllfunc_t; - -typedef struct dll_info_s -{ - const char *name; // name of library - const dllfunc_t *fcts; // list of dll exports - const size_t num_fcts; - qboolean crash; // crash if dll not found - void *link; // hinstance of loading library -} dll_info_t; - -typedef void (*setpair_t)( const char *key, const void *value, const void *buffer, void *numpairs ); typedef void *(*pfnCreateInterface_t)( const char *, int * ); // config strings are a general means of communication from diff --git a/engine/client/client.h b/engine/client/client.h index 8b6d5c0524..def9e32b5e 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -1119,6 +1119,7 @@ void Con_PageUp( int lines ); // // s_main.c // +typedef int sound_t; void S_StreamAviSamples( void *Avi, int entnum, float fvol, float attn, float synctime ); void S_StartBackgroundTrack( const char *intro, const char *loop, int position, qboolean fullpath ); void S_StopBackgroundTrack( void ); diff --git a/engine/client/sound.h b/engine/client/sound.h index 4a8819c5ba..51ffe6a05a 100644 --- a/engine/client/sound.h +++ b/engine/client/sound.h @@ -171,6 +171,8 @@ typedef struct int source; // may be game, menu, etc } bg_track_t; +typedef int sound_t; + //==================================================================== #define MAX_DYNAMIC_CHANNELS (60 + NUM_AMBIENTS) diff --git a/engine/common/common.h b/engine/common/common.h index 92f2ad6b72..b808b9f4c2 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -108,14 +108,14 @@ typedef enum #include "com_model.h" #include "com_strings.h" #include "crtlib.h" -#include "cvar.h" -#include "con_nprint.h" -#include "crclib.h" -#include "ref_api.h" #define FSCALLBACK_OVERRIDE_OPEN #define FSCALLBACK_OVERRIDE_LOADFILE #define FSCALLBACK_OVERRIDE_MALLOC_LIKE #include "fscallback.h" +#include "cvar.h" +#include "con_nprint.h" +#include "crclib.h" +#include "ref_api.h" // PERFORMANCE INFO #define MIN_FPS 20.0f // host minimum fps value for maxfps. @@ -146,6 +146,11 @@ typedef enum #define MAX_STATIC_ENTITIES 32 // static entities that moved on the client when level is spawn #endif +#define MAX_SERVERINFO_STRING 512 // server handles too many settings. expand to 1024? +#define MAX_PRINT_MSG 8192 // how many symbols can handle single call of Con_Printf or Con_DPrintf +#define MAX_TOKEN 2048 // parse token length +#define MAX_USERMSG_LENGTH 2048 // don't modify it's relies on a client-side definitions + #define GameState (&host.game) #define FORCE_DRAW_VERSION_TIME 5.0 // draw version for 5 seconds @@ -528,6 +533,7 @@ typedef struct // // soundlib // +typedef struct stream_s stream_t; void Sound_Init( void ); void Sound_Shutdown( void ); void FS_FreeSound( wavdata_t *pack ); diff --git a/engine/common/cvar.h b/engine/common/cvar.h index c9ab02f23c..3960fbc2bd 100644 --- a/engine/common/cvar.h +++ b/engine/common/cvar.h @@ -30,6 +30,8 @@ typedef struct pending_cvar_s char cv_name[]; } pending_cvar_t; +typedef void (*setpair_t)( const char *key, const void *value, const void *buffer, void *numpairs ); + cvar_t *Cvar_GetList( void ); #define Cvar_FindVar( name ) Cvar_FindVarExt( name, 0 ) convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group ); diff --git a/engine/common/system.h b/engine/common/system.h index 401e3e780c..0b79ed6468 100644 --- a/engine/common/system.h +++ b/engine/common/system.h @@ -41,6 +41,15 @@ NOTE: never change this structure because all dll descriptions in xash code writes into struct by offsets not names ======================================================================== */ +typedef struct dll_info_s +{ + const char *name; // name of library + const dllfunc_t *fcts; // list of dll exports + const size_t num_fcts; + qboolean crash; // crash if dll not found + void *link; // hinstance of loading library +} dll_info_t; + extern int error_on_exit; double Sys_DoubleTime( void ); char *Sys_GetClipboardData( void ); diff --git a/engine/platform/sdl/sys_sdl.c b/engine/platform/sdl/sys_sdl.c index c2bd960b22..cf4ccb0b1e 100644 --- a/engine/platform/sdl/sys_sdl.c +++ b/engine/platform/sdl/sys_sdl.c @@ -20,9 +20,9 @@ GNU General Public License for more details. #if XASH_TIMER == TIMER_SDL double Platform_DoubleTime( void ) { - static longtime_t g_PerformanceFrequency; - static longtime_t g_ClockStart; - longtime_t CurrentTime; + static Uint64 g_PerformanceFrequency; + static Uint64 g_ClockStart; + Uint64 CurrentTime; if( !g_PerformanceFrequency ) { diff --git a/engine/server/server.h b/engine/server/server.h index d7c9234726..6ec14e788b 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -66,6 +66,7 @@ extern int SV_UPDATE_BACKUP; #define MAX_PUSHED_ENTS 256 #define MAX_VIEWENTS 128 +#define MAX_LOCALINFO_STRING 32768 // localinfo used on server and not sended to the clients #define MAX_ENT_LEAFS( ext ) (( ext ) ? MAX_ENT_LEAFS_32 : MAX_ENT_LEAFS_16 ) diff --git a/filesystem/filesystem.h b/filesystem/filesystem.h index c82307cde3..a0feff41c2 100644 --- a/filesystem/filesystem.h +++ b/filesystem/filesystem.h @@ -143,6 +143,8 @@ typedef struct fs_globals_t int numgames; } fs_globals_t; +typedef struct file_s file_t; + typedef struct fs_api_t { qboolean (*InitStdio)( qboolean unused_set_to_true, const char *rootdir, const char *basedir, const char *gamedir, const char *rodir ); diff --git a/public/crtlib.h b/public/crtlib.h index 36b9aedcf0..19f84bbf93 100644 --- a/public/crtlib.h +++ b/public/crtlib.h @@ -107,6 +107,12 @@ int matchpattern_with_separator( const char *in, const char *pattern, qboolean c // // dllhelpers.c // +typedef struct dllfunc_s +{ + const char *name; + void **func; +} dllfunc_t; + void ClearExports( const dllfunc_t *funcs, size_t num_funcs ); qboolean ValidateExports( const dllfunc_t *funcs, size_t num_funcs );