forked from APGRoboCop/foxbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdk_util.h
111 lines (94 loc) · 3.7 KB
/
sdk_util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// vi: set ts=4 sw=4 :
// vim: set tw=75 :
// sdk_util.h - wrapper & extension of util.h from HL SDK
/*
* Copyright (c) 2001 Will Day <willday@hpgx.net>
*
* This file is part of Metamod.
*
* Metamod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* Metamod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Metamod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
// Wrap util.h from SDK with ifndef/endif, to avoid problems from multiple
// inclusions. Dunno why Valve didn't do that in util.h themselves..
#ifndef SDK_UTIL_H
#define SDK_UTIL_H
// We're not including the DBG_EntOfVars and DBG_AssertFunction routines
// mentioned in the SDK util.h, so we're going to unset DEBUG here so that
// we don't get "unresolved symbol" errors.
#ifdef DEBUG
#undef DEBUG
#endif /* DEBUG */
#include <util.h>
// Also, create some additional macros for engine callback functions, which
// weren't in SDK dlls/enginecallbacks.h but probably should have been.
#define GET_INFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer)
#define INFOKEY_VALUE (*g_engfuncs.pfnInfoKeyValue)
#define SET_CLIENT_KEYVALUE (*g_engfuncs.pfnSetClientKeyValue)
#define REG_SVR_COMMAND (*g_engfuncs.pfnAddServerCommand)
#define SERVER_PRINT (*g_engfuncs.pfnServerPrint)
#define SET_SERVER_KEYVALUE (*g_engfuncs.pfnSetKeyValue)
// Also, create some nice inlines for engine callback combos.
// Get a setinfo value from a player entity.
inline char* ENTITY_KEYVALUE(edict_t* entity, char* key)
{
char* ifbuf = GET_INFOKEYBUFFER(entity);
return (INFOKEY_VALUE(ifbuf, key));
}
// Set a setinfo value for a player entity.
inline void ENTITY_SET_KEYVALUE(edict_t* entity, char* key, char* value)
{
char* ifbuf = GET_INFOKEYBUFFER(entity);
SET_CLIENT_KEYVALUE(ENTINDEX(entity), ifbuf, key, value);
}
// Get a "serverinfo" value.
inline char* SERVERINFO(char* key)
{
edict_t* server = INDEXENT(0);
return (ENTITY_KEYVALUE(server, key));
}
// Set a "serverinfo" value.
inline void SET_SERVERINFO(char* key, char* value)
{
edict_t* server = INDEXENT(0);
char* ifbuf = GET_INFOKEYBUFFER(server);
SET_SERVER_KEYVALUE(ifbuf, key, value);
}
// Get a "localinfo" value.
inline char* LOCALINFO(char* key)
{
edict_t* server = NULL;
return (ENTITY_KEYVALUE(server, key));
}
// Set a "localinfo" value.
inline void SET_LOCALINFO(char* key, char* value)
{
edict_t* server = NULL;
char* ifbuf = GET_INFOKEYBUFFER(server);
SET_SERVER_KEYVALUE(ifbuf, key, value);
}
short FixedSigned16(float value, float scale);
unsigned short FixedUnsigned16(float value, float scale);
#endif /* SDK_UTIL_H */