forked from Avatarchik/cs16-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enginecallback.h
213 lines (178 loc) · 7.34 KB
/
enginecallback.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*
enginecallback.h - actual engine callbacks
Copyright (C) 2010 Uncle Mike
This program 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 3 of the License, or
(at your option) any later version.
This program 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.
*/
#ifndef ENGINECALLBACKS_H
#define ENGINECALLBACKS_H
// built-in memory manager
#define MALLOC( x ) (*g_engfuncs.pfnMemAlloc)( x, __FILE__, __LINE__ )
#define CALLOC( x, y ) (*g_engfuncs.pfnMemAlloc)((x) * (y), __FILE__, __LINE__ )
#define FREE( x ) (*g_engfuncs.pfnMemFree)( x, __FILE__, __LINE__ )
// screen handlers
#define PIC_Width (*g_engfuncs.pfnPIC_Width)
#define PIC_Height (*g_engfuncs.pfnPIC_Height)
#define PIC_EnableScissor (*g_engfuncs.pfnPIC_EnableScissor)
#define PIC_DisableScissor (*g_engfuncs.pfnPIC_DisableScissor)
#define FillRGBA (*g_engfuncs.pfnFillRGBA)
#define GetScreenInfo (*g_engfuncs.pfnGetScreenInfo)
#define GetGameInfo (*g_engfuncs.pfnGetGameInfo)
#define CheckGameDll (*g_engfuncs.pfnCheckGameDll)
#define PIC_SetGamma( x, y ) (*g_engfuncs.pfnProcessImage)( x, y, -1, -1 )
#define PIC_Remap( x, y, z ) (*g_engfuncs.pfnProcessImage)( x, -1.0f, y, z )
#define DRAW_LOGO (*g_engfuncs.pfnDrawLogo)
#define PRECACHE_LOGO( x ) (*g_engfuncs.pfnDrawLogo)( x, 0, 0, 0, 0 )
#define GetLogoWidth (*g_engfuncs.pfnGetLogoWidth)
#define GetLogoHeight (*g_engfuncs.pfnGetLogoHeight)
#define GetLogoLength (*g_engfuncs.pfnGetLogoLength)
inline HIMAGE PIC_Load( const char *szPicName, long flags = 0 )
{
return g_engfuncs.pfnPIC_Load( szPicName, NULL, 0, flags );
}
inline HIMAGE PIC_Load( const char *szPicName, const byte *ucRawImage, long ulRawImageSize, long flags = 0 )
{
return g_engfuncs.pfnPIC_Load( szPicName, ucRawImage, ulRawImageSize, flags );
}
#define PIC_Free (*g_engfuncs.pfnPIC_Free)
#define PLAY_SOUND (*g_engfuncs.pfnPlayLocalSound)
#define CVAR_REGISTER (*g_engfuncs.pfnRegisterVariable)
#define CVAR_SET_FLOAT (*g_engfuncs.pfnCvarSetValue)
#define CVAR_GET_FLOAT (*g_engfuncs.pfnGetCvarFloat)
#define CVAR_GET_STRING (*g_engfuncs.pfnGetCvarString)
#define CVAR_SET_STRING (*g_engfuncs.pfnCvarSetString)
#define CLIENT_COMMAND (*g_engfuncs.pfnClientCmd)
#define CLIENT_JOIN (*g_engfuncs.pfnClientJoin)
#define GET_MENU_EDICT (*g_engfuncs.pfnGetPlayerModel)
#define ENGINE_SET_MODEL (*g_engfuncs.pfnSetModel)
#define R_ClearScene (*g_engfuncs.pfnClearScene)
#define R_AddEntity (*g_engfuncs.CL_CreateVisibleEntity)
#define R_RenderFrame (*g_engfuncs.pfnRenderScene)
#define LOAD_FILE (*g_engfuncs.COM_LoadFile)
#define FILE_EXISTS( file ) (*g_engfuncs.pfnFileExists)( file, FALSE )
#define FREE_FILE (*g_engfuncs.COM_FreeFile)
#define GET_GAME_DIR (*g_engfuncs.pfnGetGameDir)
#define HOST_ERROR (*g_engfuncs.pfnHostError)
#define COM_ParseFile (*g_engfuncs.COM_ParseFile)
#define KEY_SetDest (*g_engfuncs.pfnSetKeyDest)
#define KEY_ClearStates (*g_engfuncs.pfnKeyClearStates)
#define KEY_KeynumToString (*g_engfuncs.pfnKeynumToString)
#define KEY_GetBinding (*g_engfuncs.pfnKeyGetBinding)
#define KEY_SetBinding (*g_engfuncs.pfnKeySetBinding)
#define KEY_IsDown (*g_engfuncs.pfnKeyIsDown)
#define KEY_GetOverstrike (*g_engfuncs.pfnKeyGetOverstrikeMode)
#define KEY_SetOverstrike (*g_engfuncs.pfnKeySetOverstrikeMode)
#define Key_GetState (*g_engfuncs.pfnKeyGetState)
#define SET_CURSOR (*g_engfuncs.pfnSetCursor)
#define Cmd_AddCommand (*g_engfuncs.pfnAddCommand)
#define Cmd_RemoveCommand (*g_engfuncs.pfnDelCommand)
#define CMD_ARGC (*g_engfuncs.pfnCmdArgc)
#define CMD_ARGV (*g_engfuncs.pfnCmdArgv)
#define Con_Printf (*g_engfuncs.Con_Printf)
#define Con_NPrintf (*g_engfuncs.Con_NPrintf)
#define GET_GAMES_LIST (*g_engfuncs.pfnGetGamesList)
#define BACKGROUND_TRACK (*g_engfuncs.pfnPlayBackgroundTrack)
#define SHELL_EXECUTE (*g_engfuncs.pfnShellExecute)
#define HOST_WRITECONFIG (*g_engfuncs.pfnWriteServerConfig)
#define HOST_CHANGEGAME (*g_engfuncs.pfnChangeInstance)
#define CHECK_MAP_LIST (*g_engfuncs.pfnCreateMapsList)
#define HOST_ENDGAME (*g_engfuncs.pfnHostEndGame)
#define GET_CLIPBOARD (*g_engfuncs.pfnGetClipboardData)
#define FS_SEARCH (*g_engfuncs.pfnGetFilesList)
#define MAP_IS_VALID (*g_engfuncs.pfnIsMapValid)
#define GET_SAVE_COMMENT (*g_engfuncs.pfnGetSaveComment)
#define GET_DEMO_COMMENT (*g_engfuncs.pfnGetDemoComment)
#define CL_IsActive() (g_engfuncs.pfnClientInGame() && !CVAR_GET_FLOAT( "cl_background" ))
inline void PIC_Set( HIMAGE hPic, int r, int g, int b )
{
g_engfuncs.pfnPIC_Set( hPic, r, g, b, 255 );
}
inline void PIC_Set( HIMAGE hPic, int r, int g, int b, int a )
{
g_engfuncs.pfnPIC_Set( hPic, r, g, b, a );
}
inline void PIC_Draw( int x, int y, const wrect_t *prc )
{
g_engfuncs.pfnPIC_Draw( x, y, -1, -1, prc );
}
inline void PIC_Draw( int x, int y, int width, int height )
{
g_engfuncs.pfnPIC_Draw( x, y, width, height, NULL );
}
inline void PIC_Draw( int x, int y, int width, int height, const wrect_t *prc )
{
g_engfuncs.pfnPIC_Draw( x, y, width, height, prc );
}
inline void PIC_DrawTrans( int x, int y, const wrect_t *prc )
{
g_engfuncs.pfnPIC_DrawTrans( x, y, -1, -1, prc );
}
inline void PIC_DrawTrans( int x, int y, int width, int height )
{
g_engfuncs.pfnPIC_DrawTrans( x, y, width, height, NULL );
}
inline void PIC_DrawHoles( int x, int y, const wrect_t *prc )
{
g_engfuncs.pfnPIC_DrawHoles( x, y, -1, -1, prc );
}
inline void SPR_DrawHoles( int x, int y, int width, int height )
{
g_engfuncs.pfnPIC_DrawHoles( x, y, width, height, NULL );
}
inline void PIC_DrawAdditive( int x, int y, int width, int height )
{
g_engfuncs.pfnPIC_DrawAdditive( x, y, width, height, NULL );
}
inline void PIC_DrawAdditive( int x, int y, const wrect_t *prc )
{
g_engfuncs.pfnPIC_DrawAdditive( x, y, -1, -1, prc );
}
inline void PIC_DrawAdditive( int x, int y, int w, int h, const wrect_t *prc )
{
g_engfuncs.pfnPIC_DrawAdditive( x, y, w, h, prc );
}
inline void TextMessageSetColor( int r, int g, int b, int alpha = 255 )
{
g_engfuncs.pfnDrawSetTextColor( r, g, b, alpha );
}
#define TextMessageDrawChar (*g_engfuncs.pfnDrawCharacter)
#define DrawConsoleString (*g_engfuncs.pfnDrawConsoleString)
#define GetConsoleStringSize (*g_engfuncs.pfnDrawConsoleStringLen)
#define ConsoleSetColor (*g_engfuncs.pfnSetConsoleDefaultColor)
#define RANDOM_LONG (*g_engfuncs.pfnRandomLong)
#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat)
#define COMPARE_FILE_TIME (*g_engfuncs.pfnCompareFileTime)
//#define UtfProcessChar (*g_textfuncs.pfnUtfProcessChar)
//#define UtfMoveLeft (*g_textfuncs.pfnUtfMoveLeft)
//#define UtfMoveRight (*g_textfuncs.pfnUtfMoveRight)
//#define EnableTextInput (*g_textfuncs.pfnEnableTextInput)
inline void EnableTextInput( int enable )
{
if( g_textfuncs.pfnEnableTextInput )
g_textfuncs.pfnEnableTextInput( enable );
}
inline int UtfMoveRight( char *str, int pos, int length )
{
if( g_textfuncs.pfnUtfMoveRight )
return g_textfuncs.pfnUtfMoveRight( str, pos, length );
return pos + 1;
}
inline int UtfMoveLeft( char *str, int pos )
{
if( g_textfuncs.pfnUtfMoveLeft )
return g_textfuncs.pfnUtfMoveLeft( str, pos );
return pos - 1;
}
inline int UtfProcessChar( int in )
{
if( g_textfuncs.pfnUtfProcessChar )
return g_textfuncs.pfnUtfProcessChar( in );
return in;
}
#endif//ENGINECALLBACKS_H