Skip to content

Commit 695ea1b

Browse files
committed
sdk_includes: update
1 parent 734a6d1 commit 695ea1b

File tree

7 files changed

+295
-265
lines changed

7 files changed

+295
-265
lines changed

enginecallback_menu.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ class EngFuncs
532532
return textfuncs.pfnCompareAdr( a, b );
533533
}
534534

535-
static inline void ClientCmdF( bool now, const char *fmt, ... ) _format( 2 )
535+
static inline void ClientCmdF( bool now, const char *fmt, ... ) FORMAT_CHECK( 2 )
536536
{
537537
va_list va;
538538
char buf[4096];
@@ -544,7 +544,7 @@ class EngFuncs
544544
ClientCmd( now, buf );
545545
}
546546

547-
static inline void CvarSetStringF( const char *cvar, const char *fmt, ... ) _format( 2 )
547+
static inline void CvarSetStringF( const char *cvar, const char *fmt, ... ) FORMAT_CHECK( 2 )
548548
{
549549
va_list va;
550550
char buf[4096];

sdk_includes/common/bspfile.h

-15
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ GNU General Public License for more details.
1616
#ifndef BSPFILE_H
1717
#define BSPFILE_H
1818

19-
//#define SUPPORT_BSP2_FORMAT // allow to loading Darkplaces BSP2 maps (with broke binary compatibility)
20-
2119
/*
2220
==============================================================================
2321
@@ -65,7 +63,6 @@ BRUSH MODELS
6563
#define MAX_MAP_CLIPNODES_BSP2 524288
6664

6765
// these limis not using by modelloader but only for displaying 'mapstats' correctly
68-
#ifdef SUPPORT_BSP2_FORMAT
6966
#define MAX_MAP_MODELS 2048 // embedded models
7067
#define MAX_MAP_ENTSTRING 0x200000 // 2 Mb should be enough
7168
#define MAX_MAP_PLANES 131072 // can be increased without problems
@@ -75,18 +72,6 @@ BRUSH MODELS
7572
#define MAX_MAP_VERTS 524288 // can be increased without problems
7673
#define MAX_MAP_FACES 262144 // can be increased without problems
7774
#define MAX_MAP_MARKSURFACES 524288 // can be increased without problems
78-
#else
79-
// increased to match PrimeXT compilers
80-
#define MAX_MAP_MODELS 1024 // embedded models
81-
#define MAX_MAP_ENTSTRING 0x100000 // 1 Mb should be enough
82-
#define MAX_MAP_PLANES 65536 // can be increased without problems
83-
#define MAX_MAP_NODES 32767 // because negative shorts are leafs
84-
#define MAX_MAP_CLIPNODES MAX_MAP_CLIPNODES_HLBSP // because negative shorts are contents
85-
#define MAX_MAP_LEAFS 32767 // signed short limit
86-
#define MAX_MAP_VERTS 65535 // unsigned short limit
87-
#define MAX_MAP_FACES 65535 // unsigned short limit
88-
#define MAX_MAP_MARKSURFACES 65535 // unsigned short limit
89-
#endif
9075

9176
#define MAX_MAP_ENTITIES 8192 // network limit
9277
#define MAX_MAP_TEXINFO MAX_MAP_FACES // in theory each face may have personal texinfo

sdk_includes/common/com_model.h

+110-25
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,29 @@ typedef struct
6060
vec3_t position;
6161
} mvertex_t;
6262

63-
typedef struct
63+
typedef struct mclipnode32_s
6464
{
65-
int planenum;
66-
#ifdef SUPPORT_BSP2_FORMAT
67-
int children[2]; // negative numbers are contents
68-
#else
69-
short children[2]; // negative numbers are contents
70-
#endif
71-
} mclipnode_t;
65+
int planenum;
66+
int children[2]; // negative numbers are contents
67+
} mclipnode32_t;
68+
69+
typedef struct mclipnode16_s
70+
{
71+
int planenum;
72+
short children[2]; // negative numbers are contents
73+
} mclipnode16_t;
7274

7375
// size is matched but representation is not
74-
typedef struct
76+
typedef struct medge32_s
7577
{
76-
#ifdef SUPPORT_BSP2_FORMAT
7778
unsigned int v[2];
78-
#else
79+
} medge32_t;
80+
81+
typedef struct medge16_s
82+
{
7983
unsigned short v[2];
8084
unsigned int cachededgeoffset;
81-
#endif
82-
} medge_t;
85+
} medge16_t;
8386

8487
typedef struct texture_s
8588
{
@@ -156,13 +159,31 @@ typedef struct mnode_s
156159

157160
// node specific
158161
mplane_t *plane;
159-
struct mnode_s *children[2];
160-
#ifdef SUPPORT_BSP2_FORMAT
161-
int firstsurface;
162-
int numsurfaces;
162+
163+
#if !XASH_64BIT
164+
union
165+
{
166+
struct mnode_s *children_[2];
167+
struct
168+
{
169+
// the ordering is important
170+
int child_0_leaf : 1;
171+
int child_0_off : 23;
172+
int firstsurface_1 : 8;
173+
int child_1_leaf : 1;
174+
int child_1_off : 23;
175+
int numsurfaces_1 : 8;
176+
};
177+
};
178+
unsigned short firstsurface_0;
179+
unsigned short numsurfaces_0;
163180
#else
164-
unsigned short firstsurface;
165-
unsigned short numsurfaces;
181+
// in 64-bit ABI this struct has 4 more bytes of padding, let's use it!
182+
struct mnode_s *children_[2];
183+
unsigned short firstsurface_0;
184+
unsigned short numsurfaces_0;
185+
unsigned short firstsurface_1;
186+
unsigned short numsurfaces_1;
166187
#endif
167188
} mnode_t;
168189

@@ -203,7 +224,6 @@ typedef struct mleaf_s
203224
int nummarksurfaces;
204225
int cluster; // helper to acess to uncompressed visdata
205226
byte ambient_sound_level[NUM_AMBIENTS];
206-
207227
} mleaf_t;
208228

209229
// surface extradata
@@ -291,7 +311,11 @@ struct msurface_s
291311

292312
typedef struct hull_s
293313
{
294-
mclipnode_t *clipnodes;
314+
union
315+
{
316+
mclipnode16_t *clipnodes16;
317+
mclipnode32_t *clipnodes32;
318+
};
295319
mplane_t *planes;
296320
int firstclipnode;
297321
int lastclipnode;
@@ -341,7 +365,12 @@ typedef struct model_s
341365
mvertex_t *vertexes;
342366

343367
int numedges;
344-
medge_t *edges;
368+
union
369+
{
370+
medge16_t *edges16;
371+
medge32_t *edges32;
372+
};
373+
345374

346375
int numnodes;
347376
mnode_t *nodes;
@@ -356,7 +385,11 @@ typedef struct model_s
356385
int *surfedges;
357386

358387
int numclipnodes;
359-
mclipnode_t *clipnodes;
388+
union
389+
{
390+
mclipnode16_t *clipnodes16;
391+
mclipnode32_t *clipnodes32;
392+
};
360393

361394
int nummarksurfaces;
362395
msurface_t **marksurfaces;
@@ -550,16 +583,68 @@ typedef struct
550583
#define ANIM_CYCLE 2
551584
#define MOD_FRAMES 20
552585

553-
554-
555586
#define MAX_DEMOS 32
556587
#define MAX_MOVIES 8
557588
#define MAX_CDTRACKS 32
558589
#define MAX_CLIENT_SPRITES 512 // SpriteTextures (0-256 hud, 256-512 client)
559590
#define MAX_REQUESTS 64
560591

592+
STATIC_CHECK_SIZEOF( mnode_t, 52, 72 );
561593
STATIC_CHECK_SIZEOF( mextrasurf_t, 324, 496 );
562594
STATIC_CHECK_SIZEOF( decal_t, 60, 88 );
563595
STATIC_CHECK_SIZEOF( mfaceinfo_t, 176, 304 );
564596

597+
// model flags (stored in model_t->flags)
598+
#define MODEL_QBSP2 BIT( 28 ) // uses 32-bit types
599+
600+
// access functions
601+
static inline mnode_t *node_child( const mnode_t *n, int side, const model_t *mod )
602+
{
603+
#if !XASH_64BIT
604+
if( unlikely( mod->flags & MODEL_QBSP2 )) // MODEL_QBSP2
605+
{
606+
if( side == 0 )
607+
{
608+
if( n->child_0_leaf )
609+
return (mnode_t *)(mod->leafs + n->child_0_off);
610+
else
611+
return (mnode_t *)(mod->nodes + n->child_0_off);
612+
}
613+
else
614+
{
615+
if( n->child_1_leaf )
616+
return (mnode_t *)(mod->leafs + n->child_1_off);
617+
else
618+
return (mnode_t *)(mod->nodes + n->child_1_off);
619+
}
620+
}
621+
622+
return n->children_[side];
623+
#else
624+
return n->children_[side];
625+
#endif
626+
}
627+
628+
static inline void node_children( mnode_t *children[2], const mnode_t *n, const model_t *mod )
629+
{
630+
children[0] = node_child( n, 0, mod );
631+
children[1] = node_child( n, 1, mod );
632+
}
633+
634+
static inline int node_firstsurface( const mnode_t *n, const model_t *mod )
635+
{
636+
if( mod->flags & MODEL_QBSP2 )
637+
return n->firstsurface_0 + ( n->firstsurface_1 << 16 );
638+
else
639+
return n->firstsurface_0;
640+
}
641+
642+
static inline int node_numsurfaces( const mnode_t *n, const model_t *mod )
643+
{
644+
if( mod->flags & MODEL_QBSP2 )
645+
return n->numsurfaces_0 + ( n->numsurfaces_1 << 16 );
646+
else
647+
return n->numsurfaces_0;
648+
}
649+
565650
#endif//COM_MODEL_H

sdk_includes/common/xash3d_types.h

+32-52
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,17 @@
1616
#include STDINT_H
1717
#include <assert.h>
1818

19-
typedef unsigned char byte;
20-
typedef int sound_t;
21-
typedef float vec_t;
22-
typedef vec_t vec2_t[2];
23-
typedef vec_t vec3_t[3];
24-
typedef vec_t vec4_t[4];
25-
typedef vec_t quat_t[4];
26-
typedef byte rgba_t[4]; // unsigned byte colorpack
27-
typedef byte rgb_t[3]; // unsigned byte colorpack
28-
typedef vec_t matrix3x4[3][4];
29-
typedef vec_t matrix4x4[4][4];
30-
31-
typedef uint32_t poolhandle_t;
19+
typedef uint8_t byte;
20+
typedef float vec_t;
21+
typedef vec_t vec2_t[2];
22+
typedef vec_t vec3_t[3];
23+
typedef vec_t vec4_t[4];
24+
typedef vec_t quat_t[4];
25+
typedef byte rgba_t[4]; // unsigned byte colorpack
26+
typedef byte rgb_t[3]; // unsigned byte colorpack
27+
typedef vec_t matrix3x4[3][4];
28+
typedef vec_t matrix4x4[4][4];
29+
typedef uint32_t poolhandle_t;
3230

3331
#undef true
3432
#undef false
@@ -39,18 +37,10 @@ typedef enum { false, true } qboolean;
3937
typedef int qboolean;
4038
#endif
4139

42-
typedef uint64_t longtime_t;
43-
44-
#define MAX_STRING 256 // generic string
45-
#define MAX_INFO_STRING 256 // infostrings are transmitted across network
46-
#define MAX_SERVERINFO_STRING 512 // server handles too many settings. expand to 1024?
47-
#define MAX_LOCALINFO_STRING 32768 // localinfo used on server and not sended to the clients
48-
#define MAX_SYSPATH 1024 // system filepath
49-
#define MAX_VA_STRING 1024 // string length returned by va()
50-
#define MAX_PRINT_MSG 8192 // how many symbols can handle single call of Con_Printf or Con_DPrintf
51-
#define MAX_TOKEN 2048 // parse token length
52-
#define MAX_MODS 512 // environment games that engine can keep visible
53-
#define MAX_USERMSG_LENGTH 2048 // don't modify it's relies on a client-side definitions
40+
#define MAX_STRING 256 // generic string
41+
#define MAX_VA_STRING 1024 // compatibility macro
42+
#define MAX_SYSPATH 1024 // system filepath
43+
#define MAX_MODS 512 // environment games that engine can keep visible
5444

5545
#define BIT( n ) ( 1U << ( n ))
5646
#define BIT64( n ) ( 1ULL << ( n ))
@@ -73,7 +63,7 @@ typedef uint64_t longtime_t;
7363
#if defined( __GNUC__ )
7464
#if defined( __i386__ )
7565
#define EXPORT __attribute__(( visibility( "default" ), force_align_arg_pointer ))
76-
#define GAME_EXPORT __attribute(( force_align_arg_pointer ))
66+
#define GAME_EXPORT __attribute__(( force_align_arg_pointer ))
7767
#else
7868
#define EXPORT __attribute__(( visibility ( "default" )))
7969
#define GAME_EXPORT
@@ -91,7 +81,13 @@ typedef uint64_t longtime_t;
9181
#endif
9282
#define NORETURN __attribute__(( noreturn ))
9383
#define NONNULL __attribute__(( nonnull ))
94-
#define _format( x ) __attribute__(( format( printf, x, x + 1 )))
84+
#define RETURNS_NONNULL __attribute__(( returns_nonnull ))
85+
#if __clang__
86+
#define PFN_RETURNS_NONNULL // clang has bugged returns_nonnull for functions pointers, it's ignored and generates a warning about objective-c? O_o
87+
#else
88+
#define PFN_RETURNS_NONNULL RETURNS_NONNULL
89+
#endif
90+
#define FORMAT_CHECK( x ) __attribute__(( format( printf, x, x + 1 )))
9591
#define ALLOC_CHECK( x ) __attribute__(( alloc_size( x )))
9692
#define NO_ASAN __attribute__(( no_sanitize( "address" )))
9793
#define WARN_UNUSED_RESULT __attribute__(( warn_unused_result ))
@@ -107,7 +103,9 @@ typedef uint64_t longtime_t;
107103
#define GAME_EXPORT
108104
#define NORETURN
109105
#define NONNULL
110-
#define _format( x )
106+
#define RETURNS_NONNULL
107+
#define PFN_RETURNS_NONNULL
108+
#define FORMAT_CHECK( x )
111109
#define ALLOC_CHECK( x )
112110
#define RENAME_SYMBOL( x )
113111
#define MALLOC
@@ -201,34 +199,16 @@ _inline float LittleFloat( float f )
201199
#endif
202200

203201

204-
typedef unsigned int dword;
205-
typedef unsigned int uint;
206-
typedef unsigned long ulong;
207-
typedef char string[MAX_STRING];
208-
typedef struct file_s file_t; // normal file
209-
typedef struct stream_s stream_t; // sound stream for background music playing
210-
typedef off_t fs_offset_t;
202+
typedef unsigned int dword;
203+
typedef unsigned int uint;
204+
typedef char string[MAX_STRING];
205+
typedef off_t fs_offset_t;
211206
#if XASH_WIN32
212-
typedef int fs_size_t; // return type of _read, _write funcs
207+
typedef int fs_size_t; // return type of _read, _write funcs
213208
#else /* !XASH_WIN32 */
214-
typedef ssize_t fs_size_t;
209+
typedef ssize_t fs_size_t;
215210
#endif /* !XASH_WIN32 */
216211

217-
typedef struct dllfunc_s
218-
{
219-
const char *name;
220-
void **func;
221-
} dllfunc_t;
222-
223-
typedef struct dll_info_s
224-
{
225-
const char *name; // name of library
226-
const dllfunc_t *fcts; // list of dll exports
227-
qboolean crash; // crash if dll not found
228-
void *link; // hinstance of loading library
229-
} dll_info_t;
230-
231-
typedef void (*setpair_t)( const char *key, const void *value, const void *buffer, void *numpairs );
232212
typedef void *(*pfnCreateInterface_t)( const char *, int * );
233213

234214
// config strings are a general means of communication from

0 commit comments

Comments
 (0)