Skip to content

Commit

Permalink
Cleanup xash3d_types.h from engine-specific macros and types
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Jan 22, 2025
1 parent 787444f commit 375998d
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 58 deletions.
71 changes: 21 additions & 50 deletions common/xash3d_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@
#include STDINT_H
#include <assert.h>

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
Expand All @@ -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 ))
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 2 additions & 0 deletions engine/client/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 10 additions & 4 deletions engine/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 2 additions & 0 deletions engine/common/cvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
9 changes: 9 additions & 0 deletions engine/common/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 3 additions & 3 deletions engine/platform/sdl/sys_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
1 change: 1 addition & 0 deletions engine/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 )

Expand Down
2 changes: 2 additions & 0 deletions filesystem/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 6 additions & 0 deletions public/crtlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down

0 comments on commit 375998d

Please sign in to comment.