2004-02-21 19:52:02 +00:00
|
|
|
/* AMX Mod X
|
|
|
|
* Engine Module
|
|
|
|
*
|
|
|
|
* by the AMX Mod X Development Team
|
2004-02-21 20:30:53 +00:00
|
|
|
* thanks to Vexd
|
2004-02-21 19:52:02 +00:00
|
|
|
*
|
|
|
|
* This file is part of AMX Mod X.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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 2 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define VERSION "0.1"
|
2004-02-07 08:31:44 +00:00
|
|
|
|
2004-02-12 06:37:42 +00:00
|
|
|
using namespace std;
|
|
|
|
|
2004-02-07 08:31:44 +00:00
|
|
|
plugin_info_t Plugin_info = {
|
|
|
|
|
|
|
|
META_INTERFACE_VERSION, // ifvers
|
2004-02-21 19:52:02 +00:00
|
|
|
"Engine", // name
|
2004-02-07 08:31:44 +00:00
|
|
|
VERSION, // version
|
|
|
|
__DATE__, // date
|
2004-02-21 19:52:02 +00:00
|
|
|
"AMX Mod X Dev Team", // author
|
|
|
|
"http://www.amxmodx.org", // url
|
|
|
|
"ENGINE", // logtag
|
2004-02-07 08:31:44 +00:00
|
|
|
PT_ANYTIME,// (when) loadable
|
|
|
|
PT_ANYTIME,// (when) unloadable
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module_info_s module_info = {
|
2004-02-21 19:52:02 +00:00
|
|
|
"Engine", // name
|
|
|
|
"AMX Mod X Dev Team", // author
|
2004-02-07 08:31:44 +00:00
|
|
|
VERSION, // version
|
|
|
|
AMX_INTERFACE_VERSION,
|
|
|
|
STATIC_MODULE,
|
|
|
|
};
|
|
|
|
|
|
|
|
class AmxCallList {
|
|
|
|
public:
|
|
|
|
struct AmxCall {
|
|
|
|
AMX *amx;
|
|
|
|
int iFunctionIdx;
|
|
|
|
AmxCall* next;
|
|
|
|
AmxCall( AMX *a , int i, AmxCall* n ) : amx(a), iFunctionIdx(i), next(n) {}
|
|
|
|
} *head;
|
|
|
|
|
|
|
|
AmxCallList() { head = 0; }
|
|
|
|
|
|
|
|
~AmxCallList() { clear(); }
|
|
|
|
|
|
|
|
void clear() {
|
|
|
|
while ( head ) {
|
|
|
|
AmxCall* a = head->next;
|
|
|
|
delete head;
|
|
|
|
head = a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void put( AMX *a , int i )
|
|
|
|
{
|
|
|
|
head = new AmxCall( a, i , head );
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
AmxCallList pfnTouch;
|
|
|
|
AmxCallList serverFrame;
|
|
|
|
AmxCallList preThink;
|
|
|
|
AmxCallList postThink;
|
|
|
|
AmxCallList clientKill;
|
2004-03-04 08:27:51 +00:00
|
|
|
AmxCallList Msgs;
|
2004-02-07 08:31:44 +00:00
|
|
|
|
|
|
|
meta_globals_t *gpMetaGlobals;
|
|
|
|
gamedll_funcs_t *gpGamedllFuncs;
|
|
|
|
mutil_funcs_t *gpMetaUtilFuncs;
|
|
|
|
enginefuncs_t g_engfuncs;
|
|
|
|
globalvars_t *gpGlobals;
|
|
|
|
pfnamx_engine_g* g_engAmxFunc;
|
|
|
|
pfnmodule_engine_g* g_engModuleFunc;
|
|
|
|
|
|
|
|
extern AMX_NATIVE_INFO Engine_Natives[];
|
|
|
|
|
|
|
|
void (*function)(void*);
|
|
|
|
|
|
|
|
void (*endfunction)(void*);
|
|
|
|
|
2004-02-07 21:23:24 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
int thread_fork(void *arg);
|
|
|
|
#endif
|
|
|
|
|
2004-02-07 08:31:44 +00:00
|
|
|
#define AMS_OFFSET 0.01
|
|
|
|
|
|
|
|
#define SPEAK_NORMAL 0
|
|
|
|
#define SPEAK_MUTED 1
|
|
|
|
#define SPEAK_ALL 2
|
|
|
|
#define SPEAK_LISTENALL 4
|
|
|
|
|
|
|
|
#define CAMERA_NONE 0
|
|
|
|
#define CAMERA_3RDPERSON 1
|
|
|
|
#define CAMERA_UPLEFT 2
|
|
|
|
#define CAMERA_TOPDOWN 3
|
|
|
|
|
|
|
|
#define MAX_MESSAGES 255
|
|
|
|
|
|
|
|
#define BLOCK_NOT 0
|
|
|
|
#define BLOCK_ONCE 1
|
|
|
|
#define BLOCK_SET 2
|
|
|
|
|
|
|
|
enum {
|
|
|
|
gamestate,
|
|
|
|
oldbuttons,
|
|
|
|
groupinfo,
|
|
|
|
iuser1,
|
|
|
|
iuser2,
|
|
|
|
iuser3,
|
|
|
|
iuser4,
|
|
|
|
weaponanim,
|
|
|
|
pushmsec,
|
|
|
|
bInDuck,
|
|
|
|
flTimeStepSound,
|
|
|
|
flSwimTime,
|
|
|
|
flDuckTime,
|
|
|
|
iStepLeft,
|
|
|
|
movetype,
|
|
|
|
solid,
|
|
|
|
skin,
|
|
|
|
body,
|
|
|
|
effects,
|
|
|
|
light_level,
|
|
|
|
sequence,
|
|
|
|
gaitsequence,
|
|
|
|
modelindex,
|
|
|
|
playerclass,
|
|
|
|
waterlevel,
|
|
|
|
watertype,
|
|
|
|
spawnflags,
|
|
|
|
flags,
|
|
|
|
colormap,
|
|
|
|
team,
|
|
|
|
fixangle,
|
|
|
|
weapons,
|
|
|
|
rendermode,
|
|
|
|
renderfx,
|
|
|
|
button,
|
|
|
|
impulse,
|
|
|
|
deadflag,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
impacttime,
|
|
|
|
starttime,
|
|
|
|
idealpitch,
|
|
|
|
pitch_speed,
|
|
|
|
ideal_yaw,
|
|
|
|
yaw_speed,
|
|
|
|
ltime,
|
|
|
|
nextthink,
|
|
|
|
gravity,
|
|
|
|
friction,
|
|
|
|
frame,
|
|
|
|
animtime,
|
|
|
|
framerate,
|
|
|
|
health,
|
|
|
|
frags,
|
|
|
|
takedamage,
|
|
|
|
max_health,
|
|
|
|
teleport_time,
|
|
|
|
armortype,
|
|
|
|
armorvalue,
|
|
|
|
dmg_take,
|
|
|
|
dmg_save,
|
|
|
|
dmg,
|
|
|
|
dmgtime,
|
|
|
|
speed,
|
|
|
|
air_finished,
|
|
|
|
pain_finished,
|
|
|
|
radsuit_finished,
|
|
|
|
scale,
|
|
|
|
renderamt,
|
|
|
|
maxspeed,
|
|
|
|
fov,
|
|
|
|
flFallVelocity,
|
|
|
|
fuser1,
|
|
|
|
fuser2,
|
|
|
|
fuser3,
|
|
|
|
fuser4,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
origin,
|
|
|
|
oldorigin,
|
|
|
|
velocity,
|
|
|
|
basevelocity,
|
|
|
|
clbasevelocity,
|
|
|
|
movedir,
|
|
|
|
angles,
|
|
|
|
avelocity,
|
|
|
|
punchangle,
|
|
|
|
v_angle,
|
|
|
|
endpos,
|
|
|
|
startpos,
|
|
|
|
absmin,
|
|
|
|
absmax,
|
|
|
|
mins,
|
|
|
|
maxs,
|
|
|
|
size,
|
|
|
|
rendercolor,
|
|
|
|
view_ofs,
|
|
|
|
vuser1,
|
|
|
|
vuser2,
|
|
|
|
vuser3,
|
|
|
|
vuser4,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
chain,
|
|
|
|
dmg_inflictor,
|
|
|
|
enemy,
|
|
|
|
aiment,
|
|
|
|
owner,
|
|
|
|
groundentity,
|
|
|
|
pContainingEntity,
|
|
|
|
euser1,
|
|
|
|
euser2,
|
|
|
|
euser3,
|
|
|
|
euser4,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
classname,
|
|
|
|
globalname,
|
|
|
|
model,
|
|
|
|
target,
|
|
|
|
targetname,
|
|
|
|
netname,
|
|
|
|
message,
|
|
|
|
noise,
|
|
|
|
noise1,
|
|
|
|
noise2,
|
|
|
|
noise3,
|
|
|
|
viewmodel,
|
|
|
|
weaponmodel,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
controller1,
|
|
|
|
controller2,
|
|
|
|
controller3,
|
|
|
|
controller4,
|
|
|
|
blending1,
|
|
|
|
blending2,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PlayerInfo {
|
|
|
|
bool bModeled;
|
|
|
|
char szModel[32];
|
|
|
|
float fModelSet;
|
|
|
|
|
|
|
|
int iSpeakFlags;
|
|
|
|
|
|
|
|
edict_t *pViewEnt;
|
|
|
|
int iViewType;
|
|
|
|
int iRenderMode;
|
|
|
|
float fRenderAmt;
|
|
|
|
};
|
|
|
|
|
|
|
|
PlayerInfo PlInfo[33];
|
|
|
|
|
|
|
|
struct GlobalInfo {
|
|
|
|
bool bLights;
|
|
|
|
float fNextLights;
|
|
|
|
char *szLastLights[128];
|
|
|
|
char *szRealLights[128];
|
|
|
|
|
|
|
|
int iMessageBlock[MAX_MESSAGES];
|
|
|
|
bool bBlocking;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
arg_byte = 1,
|
|
|
|
arg_char,
|
|
|
|
arg_short,
|
|
|
|
arg_long,
|
|
|
|
arg_angle,
|
|
|
|
arg_coord,
|
|
|
|
arg_string,
|
|
|
|
arg_entity,
|
|
|
|
};
|
|
|
|
|
|
|
|
class argStack {
|
|
|
|
public:
|
|
|
|
argStack(argStack *p=NULL) //initialize with link to previous
|
|
|
|
{
|
|
|
|
next = p;
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void init()
|
|
|
|
{
|
|
|
|
writebyte = 0;
|
|
|
|
writechar = '\0';
|
|
|
|
writeshort = 0;
|
|
|
|
writelong = (long)0;
|
|
|
|
writeangle = 0.0;
|
|
|
|
writecoord = 0.0;
|
|
|
|
writeentity = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
argStack* arg()
|
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
p = new argStack(); //get the new pointer
|
|
|
|
next = p; //link this to the next pointer
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
argStack* link() //return link
|
|
|
|
{
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
|
|
|
void put(int arg_type, int i)
|
|
|
|
{
|
|
|
|
argtype = arg_type;
|
|
|
|
switch (argtype)
|
|
|
|
{
|
|
|
|
case arg_byte:
|
|
|
|
writebyte = i;
|
|
|
|
break;
|
|
|
|
case arg_char:
|
|
|
|
writechar = i;
|
|
|
|
break;
|
|
|
|
case arg_entity:
|
|
|
|
writeentity = i;
|
|
|
|
break;
|
|
|
|
case arg_short:
|
|
|
|
writeshort = i;
|
|
|
|
break;
|
|
|
|
case arg_long:
|
|
|
|
writelong = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void put(int arg_type, float f)
|
|
|
|
{
|
|
|
|
argtype = arg_type;
|
|
|
|
switch (argtype)
|
|
|
|
{
|
|
|
|
case arg_angle:
|
|
|
|
writeangle = f;
|
|
|
|
break;
|
|
|
|
case arg_coord:
|
|
|
|
writecoord = f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-11 19:28:10 +00:00
|
|
|
void put_string(int arg_type, const char *sz)
|
2004-02-07 08:31:44 +00:00
|
|
|
{
|
|
|
|
argtype = arg_type;
|
|
|
|
switch (argtype)
|
|
|
|
{
|
|
|
|
case arg_string:
|
2004-02-12 06:37:42 +00:00
|
|
|
writestring.append((char *)sz);
|
2004-02-07 08:31:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void write_arg()
|
|
|
|
{
|
|
|
|
switch (argtype)
|
|
|
|
{
|
|
|
|
case arg_byte:
|
|
|
|
WRITE_BYTE(writebyte);
|
|
|
|
break;
|
|
|
|
case arg_char:
|
|
|
|
WRITE_CHAR(writechar);
|
|
|
|
break;
|
|
|
|
case arg_short:
|
|
|
|
WRITE_SHORT(writeshort);
|
|
|
|
break;
|
|
|
|
case arg_long:
|
|
|
|
WRITE_LONG(writelong);
|
|
|
|
break;
|
|
|
|
case arg_angle:
|
|
|
|
WRITE_ANGLE(writeangle);
|
|
|
|
break;
|
|
|
|
case arg_coord:
|
|
|
|
WRITE_COORD(writecoord);
|
|
|
|
break;
|
|
|
|
case arg_string:
|
2004-02-12 06:37:42 +00:00
|
|
|
WRITE_STRING(writestring.c_str());
|
2004-02-07 08:31:44 +00:00
|
|
|
break;
|
|
|
|
case arg_entity:
|
|
|
|
WRITE_ENTITY(writeentity);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int getarg_int(int arg_type)
|
|
|
|
{
|
|
|
|
switch (argtype)
|
|
|
|
{
|
|
|
|
case arg_byte:
|
|
|
|
return writebyte;
|
|
|
|
break;
|
|
|
|
case arg_char:
|
|
|
|
return writechar;
|
|
|
|
break;
|
|
|
|
case arg_short:
|
|
|
|
return writeshort;
|
|
|
|
break;
|
|
|
|
case arg_long:
|
|
|
|
return writelong;
|
|
|
|
break;
|
|
|
|
case arg_entity:
|
|
|
|
return writeentity;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
float getarg_float(int arg_type)
|
|
|
|
{
|
|
|
|
switch (argtype)
|
|
|
|
{
|
|
|
|
case arg_angle:
|
|
|
|
return writeangle;
|
|
|
|
break;
|
|
|
|
case arg_coord:
|
|
|
|
return writecoord;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2004-02-11 19:28:10 +00:00
|
|
|
int getarg_strlen(int arg_type)
|
|
|
|
{
|
|
|
|
switch (argtype)
|
|
|
|
{
|
|
|
|
case arg_string:
|
2004-02-12 06:37:42 +00:00
|
|
|
return (writestring.length());
|
2004-02-11 19:28:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-02-12 06:37:42 +00:00
|
|
|
const char *getarg_string(int arg_type)
|
2004-02-07 08:31:44 +00:00
|
|
|
{
|
|
|
|
switch (argtype)
|
|
|
|
{
|
|
|
|
case arg_string:
|
2004-02-12 06:37:42 +00:00
|
|
|
return writestring.c_str();
|
2004-02-07 08:31:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-02-11 19:28:10 +00:00
|
|
|
return '\0';
|
2004-02-07 08:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int get_argtype()
|
|
|
|
{
|
|
|
|
return argtype;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_arg(int arg_type)
|
|
|
|
{
|
|
|
|
switch (argtype)
|
|
|
|
{
|
|
|
|
case arg_byte:
|
|
|
|
{
|
|
|
|
switch (arg_type)
|
|
|
|
{
|
|
|
|
case arg_byte:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_char:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_short:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_long:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_entity:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case arg_char:
|
|
|
|
{
|
|
|
|
switch (arg_type)
|
|
|
|
{
|
|
|
|
case arg_byte:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_char:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_short:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_long:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_entity:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case arg_short:
|
|
|
|
{
|
|
|
|
switch (arg_type)
|
|
|
|
{
|
|
|
|
case arg_byte:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_char:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_short:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_long:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_entity:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case arg_long:
|
|
|
|
{
|
|
|
|
switch (arg_type)
|
|
|
|
{
|
|
|
|
case arg_byte:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_char:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_short:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_long:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_entity:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case arg_entity:
|
|
|
|
{
|
|
|
|
switch (arg_type)
|
|
|
|
{
|
|
|
|
case arg_byte:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_char:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_short:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_long:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_entity:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case arg_angle:
|
|
|
|
{
|
|
|
|
switch (arg_type)
|
|
|
|
{
|
|
|
|
case arg_angle:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_coord:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case arg_coord:
|
|
|
|
{
|
|
|
|
switch (arg_type)
|
|
|
|
{
|
|
|
|
case arg_angle:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case arg_coord:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case arg_string:
|
|
|
|
{
|
|
|
|
switch (arg_type)
|
|
|
|
{
|
|
|
|
case arg_string:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int argtype;
|
|
|
|
int writebyte;
|
|
|
|
int writechar;
|
|
|
|
int writeshort;
|
|
|
|
int writelong;
|
|
|
|
float writeangle;
|
|
|
|
float writecoord;
|
2004-02-12 06:37:42 +00:00
|
|
|
string writestring;
|
2004-02-07 08:31:44 +00:00
|
|
|
int writeentity;
|
|
|
|
argStack *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
class MessageInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MessageInfo(int msgdest, int msg_id, const float *Origin, edict_t* ed)
|
|
|
|
{
|
|
|
|
msgID = msg_id;
|
|
|
|
msg_dest = msgdest;
|
|
|
|
pOrigin = Origin;
|
|
|
|
v = ed;
|
|
|
|
CHeadArg = new argStack();
|
|
|
|
CTailArg = NULL;
|
|
|
|
argcount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
~MessageInfo()
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SendMsg()
|
|
|
|
{
|
|
|
|
//we are going to build a message =D yay! gather 'round and watch.
|
|
|
|
argStack *p;
|
|
|
|
MESSAGE_BEGIN(msg_dest, msgID, pOrigin, v);
|
|
|
|
for (p=CHeadArg->link(); p!=NULL; p=p->link()) {
|
|
|
|
p->write_arg();
|
|
|
|
}
|
|
|
|
MESSAGE_END();
|
|
|
|
Destroy(); //clean up old arguments
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddArg(int i, int j)
|
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
if (CTailArg == NULL) {
|
|
|
|
p = CHeadArg->arg();
|
|
|
|
CTailArg = p;
|
|
|
|
} else {
|
|
|
|
p = CTailArg->arg();
|
|
|
|
CTailArg = p;
|
|
|
|
}
|
|
|
|
CTailArg->put(i,j);
|
|
|
|
argcount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddArg(int i, float f)
|
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
if (CTailArg == NULL) {
|
|
|
|
p = CHeadArg->arg();
|
|
|
|
CTailArg = p;
|
|
|
|
} else {
|
|
|
|
p = CTailArg->arg();
|
|
|
|
CTailArg = p;
|
|
|
|
}
|
|
|
|
CTailArg->put(i,f);
|
|
|
|
argcount++;
|
|
|
|
}
|
|
|
|
|
2004-02-11 19:28:10 +00:00
|
|
|
void AddArgString(int i, const char *sz)
|
2004-02-07 08:31:44 +00:00
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
if (CTailArg == NULL) {
|
|
|
|
p = CHeadArg->arg();
|
|
|
|
CTailArg = p;
|
|
|
|
} else {
|
|
|
|
p = CTailArg->arg();
|
|
|
|
CTailArg = p;
|
|
|
|
}
|
2004-02-11 19:28:10 +00:00
|
|
|
CTailArg->put_string(i,sz);
|
2004-02-07 08:31:44 +00:00
|
|
|
argcount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Destroy()
|
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
|
|
|
|
p = CHeadArg->link();
|
|
|
|
|
|
|
|
while (p) {
|
|
|
|
argStack *n = p->link();
|
|
|
|
delete p;
|
|
|
|
p = n;
|
|
|
|
}
|
|
|
|
argcount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Set(int n, int arg_type, int data)
|
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
int i=0;
|
|
|
|
if (n>argcount) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
for (p=CHeadArg->link(); p!=NULL; p=p->link()) {
|
|
|
|
i++;
|
|
|
|
if (i==n) {
|
|
|
|
p->put(arg_type, data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Set(int n, int arg_type, float data)
|
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
int i=0;
|
|
|
|
if (n>argcount) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
for (p=CHeadArg->link(); p!=NULL; p=p->link()) {
|
|
|
|
i++;
|
|
|
|
if (i==n) {
|
|
|
|
p->put(arg_type, data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Set(int n, int arg_type, char* data)
|
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
int i=0;
|
|
|
|
if (n>argcount) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
for (p=CHeadArg->link(); p!=NULL; p=p->link()) {
|
|
|
|
i++;
|
|
|
|
if (i==n) {
|
2004-02-11 19:28:10 +00:00
|
|
|
p->put_string(arg_type, (const char*)data);
|
2004-02-07 08:31:44 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RetArg_Int(int n)
|
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
int i=0;
|
|
|
|
if (n>argcount) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
for (p=CHeadArg->link(); p!=NULL; p=p->link()) {
|
|
|
|
i++;
|
|
|
|
if (i==n) {
|
|
|
|
return p->getarg_int(arg_short);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
float RetArg_Float(int n)
|
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
int i=0;
|
|
|
|
if (n>argcount) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
for (p=CHeadArg->link(); p!=NULL; p=p->link()) {
|
|
|
|
i++;
|
|
|
|
if (i==n) {
|
|
|
|
return p->getarg_float(arg_coord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2004-02-11 19:28:10 +00:00
|
|
|
int RetArg_Strlen(int n)
|
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
int i=0;
|
|
|
|
if (n>argcount) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
for (p=CHeadArg->link(); p!=NULL; p=p->link()) {
|
|
|
|
i++;
|
|
|
|
if (i==n) {
|
|
|
|
return p->getarg_strlen(arg_string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-02-12 06:37:42 +00:00
|
|
|
const char* RetArg_String(int n)
|
2004-02-07 08:31:44 +00:00
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
int i=0;
|
|
|
|
if (n>argcount) {
|
2004-02-11 19:28:10 +00:00
|
|
|
return '\0';
|
2004-02-07 08:31:44 +00:00
|
|
|
} else {
|
|
|
|
for (p=CHeadArg->link(); p!=NULL; p=p->link()) {
|
|
|
|
i++;
|
|
|
|
if (i==n) {
|
|
|
|
return p->getarg_string(arg_string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-11 19:28:10 +00:00
|
|
|
return '\0';
|
2004-02-07 08:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ArgType(int n)
|
|
|
|
{
|
|
|
|
argStack *p;
|
|
|
|
int i=0;
|
|
|
|
if (n>argcount) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
for (p=CHeadArg->link(); p!=NULL; p=p->link()) {
|
|
|
|
i++;
|
|
|
|
if (i==n) {
|
|
|
|
return p->get_argtype();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int args()
|
|
|
|
{
|
|
|
|
return argcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int argcount;
|
|
|
|
int msgID;
|
|
|
|
int msg_dest;
|
|
|
|
const float *pOrigin;
|
|
|
|
edict_t *v;
|
|
|
|
argStack *CHeadArg;
|
|
|
|
argStack *CTailArg;
|
|
|
|
};
|