Skip to content

Commit 08dd8df

Browse files
committed
Update ReHLDS API 3.x
1 parent c8311da commit 08dd8df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+522
-329
lines changed

dep/rehlsdk/common/const.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
#define FL_KILLME (1<<30) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time
7272
#define FL_DORMANT (1<<31) // Entity is dormant, no updates to client
7373

74+
// SV_EmitSound2 flags
75+
#define SND_EMIT2_NOPAS (1<<0) // never to do check PAS
76+
#define SND_EMIT2_INVOKER (1<<1) // do not send to the client invoker
7477

7578
// Engine edict->spawnflags
7679
#define SF_NOTINDEATHMATCH 0x0800 // Do not spawn when deathmatch and loading entities from a file

dep/rehlsdk/common/kbutton.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@
3232
#pragma once
3333
#endif
3434

35-
36-
/* <31b2a> ../common/kbutton.h:7 */
3735
typedef struct kbutton_s
3836
{
3937
int down[2];
4038
int state;
4139
} kbutton_t;
4240

43-
4441
#endif // KBUTTON_H

dep/rehlsdk/common/mathlib.h

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
1-
/***
1+
/*
22
*
3-
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
4-
*
5-
* This product contains software technology licensed from Id
6-
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
7-
* All Rights Reserved.
3+
* This program is free software; you can redistribute it and/or modify it
4+
* under the terms of the GNU General Public License as published by the
5+
* Free Software Foundation; either version 2 of the License, or (at
6+
* your option) any later version.
87
*
9-
* Use, distribution, and modification of this source code and/or resulting
10-
* object code is restricted to non-commercial enhancements to products from
11-
* Valve LLC. All other use, distribution, or modification is prohibited
12-
* without written permission from Valve LLC.
8+
* This program is distributed in the hope that it will be useful, but
9+
* WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* General Public License for more details.
1312
*
14-
****/
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program; if not, write to the Free Software Foundation,
15+
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16+
*
17+
* In addition, as a special exception, the author gives permission to
18+
* link the code of this program with the Half-Life Game Engine ("HL
19+
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
20+
* L.L.C ("Valve"). You must obey the GNU General Public License in all
21+
* respects for all of the code used other than the HL Engine and MODs
22+
* from Valve. If you modify this file, you may extend this exception
23+
* to your version of the file, but you are not obligated to do so. If
24+
* you do not wish to do so, delete this exception statement from your
25+
* version.
26+
*
27+
*/
1528

29+
#ifndef MATHLIB_H
30+
#define MATHLIB_H
31+
#ifdef _WIN32
1632
#pragma once
33+
#endif
1734

18-
19-
/* <42b7f> ../common/mathlib.h:3 */
2035
typedef float vec_t;
2136

22-
/* <42b91> ../common/mathlib.h:6 */
23-
#ifndef DID_VEC3_T_DEFINE
37+
#if !defined DID_VEC3_T_DEFINE && !defined vec3_t
2438
#define DID_VEC3_T_DEFINE
2539
typedef vec_t vec3_t[3];
2640
#endif
2741

28-
/* <80013> ../common/mathlib.h:8 */
2942
typedef vec_t vec4_t[4];
43+
typedef int fixed16_t;
3044

31-
/* <42bac> ../common/mathlib.h:18 */
32-
typedef int fixed16_t; /* size: 4 */
33-
34-
/* <42bb7> ../common/mathlib.h:60 */
3545
typedef union DLONG_u
3646
{
3747
int i[2];
@@ -41,6 +51,50 @@ typedef union DLONG_u
4151

4252
#define M_PI 3.14159265358979323846
4353

54+
#ifdef __cplusplus
55+
#ifdef min
56+
#undef min
57+
#endif
58+
59+
#ifdef max
60+
#undef max
61+
#endif
62+
63+
#ifdef clamp
64+
#undef clamp
65+
#endif
66+
67+
template <typename T>
68+
inline T min(T a, T b) {
69+
return (a < b) ? a : b;
70+
}
71+
72+
template <typename T>
73+
inline T max(T a, T b) {
74+
return (a < b) ? b : a;
75+
}
76+
77+
template <typename T>
78+
inline T clamp(T a, T min, T max) {
79+
return (a > max) ? max : (a < min) ? min : a;
80+
}
81+
82+
template <typename T>
83+
inline T bswap(T s) {
84+
switch (sizeof(T)) {
85+
#ifdef _WIN32
86+
case 2: {auto res = _byteswap_ushort(*(uint16 *)&s); return *(T *)&res;}
87+
case 4: {auto res = _byteswap_ulong(*(uint32 *)(&s)); return *(T *)&res;}
88+
case 8: {auto res = _byteswap_uint64(*(uint64 *)&s); return *(T *)&res;}
89+
#else
90+
case 2: {auto res = _bswap16(*(uint16 *)&s); return *(T *)&res;}
91+
case 4: {auto res = _bswap(*(uint32 *)&s); return *(T *)&res;}
92+
case 8: {auto res = _bswap64(*(uint64 *)&s); return *(T *)&res;}
93+
#endif
94+
default: return s;
95+
}
96+
}
97+
#else // __cplusplus
4498
#ifndef max
4599
#define max(a,b) (((a) > (b)) ? (a) : (b))
46100
#endif
@@ -50,3 +104,6 @@ typedef union DLONG_u
50104
#endif
51105

52106
#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
107+
#endif // __cplusplus
108+
109+
#endif // MATHLIB_H

dep/rehlsdk/common/netadr.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* without written permission from Valve LLC.
1313
*
1414
****/
15-
// netadr.h
15+
1616
#ifndef NETADR_H
1717
#define NETADR_H
1818
#ifdef _WIN32
@@ -31,10 +31,10 @@ typedef enum
3131

3232
typedef struct netadr_s
3333
{
34-
netadrtype_t type;
35-
unsigned char ip[4];
36-
unsigned char ipx[10];
37-
unsigned short port;
34+
netadrtype_t type;
35+
unsigned char ip[4];
36+
unsigned char ipx[10];
37+
unsigned short port;
3838
} netadr_t;
3939

4040
#endif // NETADR_H

dep/rehlsdk/common/qlimits.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@
2525
#define MAX_LIGHTSTYLE_INDEX_BITS 6
2626
#define MAX_LIGHTSTYLES (1<<MAX_LIGHTSTYLE_INDEX_BITS)
2727

28-
// Resource counts;
28+
// Resource counts
2929
#define MAX_MODEL_INDEX_BITS 9 // sent as a short
3030
#define MAX_MODELS (1<<MAX_MODEL_INDEX_BITS)
3131
#define MAX_SOUND_INDEX_BITS 9
3232
#define MAX_SOUNDS (1<<MAX_SOUND_INDEX_BITS)
33+
#define MAX_SOUNDS_HASHLOOKUP_SIZE (MAX_SOUNDS * 2 - 1)
3334

3435
#define MAX_GENERIC_INDEX_BITS 9
3536
#define MAX_GENERIC (1<<MAX_GENERIC_INDEX_BITS)
3637
#define MAX_DECAL_INDEX_BITS 9
3738
#define MAX_BASE_DECALS (1<<MAX_DECAL_INDEX_BITS)
3839

40+
#define MAX_EVENTS 256
41+
#define MAX_PACKET_ENTITIES 256 // 256 visible entities per frame
42+
3943
#endif // QLIMITS_H

dep/rehlsdk/common/quakedef.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,15 @@
2727
*/
2828
#pragma once
2929

30-
/* <19039> ../common/quakedef.h:29 */
31-
typedef int BOOL; /* size: 4 */
30+
typedef int BOOL;
3231

3332
// user message
3433
#define MAX_USER_MSG_DATA 192
3534

36-
/* <627f> ../common/quakedef.h:137 */
3735
//moved to com_model.h
3836
//typedef struct cache_user_s
3937
//{
4038
// void *data;
4139
//} cache_user_t;
4240

43-
/* <4313b> ../common/quakedef.h:162 */
4441
typedef int (*pfnUserMsgHook)(const char *, int, void *);

dep/rehlsdk/common/vmodes.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
*/
2828
#pragma once
2929

30-
31-
/* <430ee> ../common/vmodes.h:40 */
3230
typedef struct rect_s
3331
{
3432
int left, right, top, bottom;

dep/rehlsdk/engine/bspfile.h

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,46 +27,47 @@
2727
*/
2828
#pragma once
2929

30-
#define BSPVERSION 30
30+
// header
31+
#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28)
32+
#define HLBSP_VERSION 30 // half-life regular version
33+
3134
#define MAX_MAP_HULLS 4
3235

3336
#define CONTENTS_ORIGIN -7 // removed at csg time
3437
#define CONTENTS_CLIP -8 // changed to contents_solid
35-
#define CONTENTS_CURRENT_0 -9
36-
#define CONTENTS_CURRENT_90 -10
38+
#define CONTENTS_CURRENT_0 -9
39+
#define CONTENTS_CURRENT_90 -10
3740
#define CONTENTS_CURRENT_180 -11
3841
#define CONTENTS_CURRENT_270 -12
39-
#define CONTENTS_CURRENT_UP -13
42+
#define CONTENTS_CURRENT_UP -13
4043
#define CONTENTS_CURRENT_DOWN -14
4144

4245
#define CONTENTS_TRANSLUCENT -15
4346

44-
#define LUMP_ENTITIES 0
47+
#define LUMP_ENTITIES 0
4548
#define LUMP_PLANES 1
46-
#define LUMP_TEXTURES 2
47-
#define LUMP_VERTEXES 3
48-
#define LUMP_VISIBILITY 4
49+
#define LUMP_TEXTURES 2
50+
#define LUMP_VERTEXES 3
51+
#define LUMP_VISIBILITY 4
4952
#define LUMP_NODES 5
50-
#define LUMP_TEXINFO 6
53+
#define LUMP_TEXINFO 6
5154
#define LUMP_FACES 7
52-
#define LUMP_LIGHTING 8
53-
#define LUMP_CLIPNODES 9
55+
#define LUMP_LIGHTING 8
56+
#define LUMP_CLIPNODES 9
5457
#define LUMP_LEAFS 10
55-
#define LUMP_MARKSURFACES 11
58+
#define LUMP_MARKSURFACES 11
5659
#define LUMP_EDGES 12
57-
#define LUMP_SURFEDGES 13
60+
#define LUMP_SURFEDGES 13
5861
#define LUMP_MODELS 14
5962

60-
#define HEADER_LUMPS 15
63+
#define HEADER_LUMPS 15
6164

62-
/* <a1fc> ../engine/bspfile.h:41 */
63-
typedef struct lump_s
65+
typedef struct lump_s
6466
{
6567
int fileofs;
6668
int filelen;
6769
} lump_t;
6870

69-
/* <a22c> ../engine/bspfile.h:64 */
7071
typedef struct dmodel_s
7172
{
7273
float mins[3], maxs[3];
@@ -76,21 +77,18 @@ typedef struct dmodel_s
7677
int firstface, numfaces;
7778
} dmodel_t;
7879

79-
/* <a2c2> ../engine/bspfile.h:73 */
8080
typedef struct dheader_s
8181
{
8282
int version;
8383
lump_t lumps[15];
8484
} dheader_t;
8585

86-
/* <485b2> ../engine/bspfile.h:79 */
8786
typedef struct dmiptexlump_s
8887
{
8988
int _nummiptex;
9089
int dataofs[4];
9190
} dmiptexlump_t;
9291

93-
/* <1ce18> ../engine/bspfile.h:86 */
9492
typedef struct miptex_s
9593
{
9694
char name[16];
@@ -99,21 +97,18 @@ typedef struct miptex_s
9997
unsigned offsets[4];
10098
} miptex_t;
10199

102-
/* <48652> ../engine/bspfile.h:94 */
103100
typedef struct dvertex_s
104101
{
105102
float point[3];
106103
} dvertex_t;
107104

108-
/* <48674> ../engine/bspfile.h:110 */
109105
typedef struct dplane_s
110106
{
111107
float normal[3];
112108
float dist;
113109
int type;
114110
} dplane_t;
115111

116-
/* <486b2> ../engine/bspfile.h:132 */
117112
typedef struct dnode_s
118113
{
119114
int planenum;
@@ -124,28 +119,24 @@ typedef struct dnode_s
124119
unsigned short numfaces;
125120
} dnode_t;
126121

127-
/* <a332> ../engine/bspfile.h:142 */
128122
typedef struct dclipnode_s
129123
{
130124
int planenum;
131125
short children[2]; // negative numbers are contents
132126
} dclipnode_t;
133127

134-
/* <4876a> ../engine/bspfile.h:149 */
135128
typedef struct texinfo_s
136129
{
137130
float vecs[2][4];
138131
int _miptex;
139132
int flags;
140133
} texinfo_t;
141134

142-
/* <487c2> ../engine/bspfile.h:159 */
143135
typedef struct dedge_s
144136
{
145137
unsigned short v[2];
146138
} dedge_t;
147139

148-
/* <487f2> ../engine/bspfile.h:165 */
149140
typedef struct dface_s
150141
{
151142
short planenum;

dep/rehlsdk/engine/cmd_rehlds.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@
2929

3030
#include "archtypes.h"
3131

32-
/* <8f1> ../engine/cmd.h:65 */
3332
typedef void(*xcommand_t)(void);
34-
35-
/* <904> ../engine/cmd.h:71 */
3633
typedef struct cmd_function_s
3734
{
3835
struct cmd_function_s *next;
@@ -41,7 +38,6 @@ typedef struct cmd_function_s
4138
int flags;
4239
} cmd_function_t;
4340

44-
/* <95a> ../engine/cmd.h:80 */
4541
typedef enum cmd_source_s
4642
{
4743
src_client = 0, // came in over a net connection as a clc_stringcmd. host_client will be valid during this state.

0 commit comments

Comments
 (0)