2001-03-01 08:34:30 +00:00
|
|
|
/*
|
|
|
|
sv_progs.h
|
|
|
|
|
|
|
|
server specific progs definitions
|
|
|
|
|
|
|
|
Copyright (C) 2000 Bill Currie
|
|
|
|
|
|
|
|
Author: Bill Currie
|
|
|
|
Date: 28 Feb 2001
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __sv_progs_h
|
|
|
|
#define __sv_progs_h
|
|
|
|
|
2010-12-09 05:27:36 +00:00
|
|
|
#include "QF/link.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/progs.h"
|
2010-12-09 05:27:36 +00:00
|
|
|
|
|
|
|
#include "qw/protocol.h"
|
2002-02-20 20:53:41 +00:00
|
|
|
#include "sv_pr_cmds.h"
|
2001-03-01 08:34:30 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2022-01-16 13:15:18 +00:00
|
|
|
pr_uint_t *self;
|
|
|
|
pr_uint_t *other;
|
|
|
|
pr_uint_t *world;
|
2010-12-09 09:32:21 +00:00
|
|
|
float *time;
|
|
|
|
float *frametime;
|
2022-01-16 13:15:18 +00:00
|
|
|
pr_uint_t *newmis;
|
2010-12-09 09:32:21 +00:00
|
|
|
float *force_retouch;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_string_t *mapname;
|
2010-12-09 09:32:21 +00:00
|
|
|
float *serverflags;
|
|
|
|
float *total_secrets;
|
|
|
|
float *total_monsters;
|
|
|
|
float *found_secrets;
|
|
|
|
float *killed_monsters;
|
|
|
|
float *parms; // an actual array
|
|
|
|
vec3_t *v_forward;
|
|
|
|
vec3_t *v_up;
|
|
|
|
vec3_t *v_right;
|
|
|
|
float *trace_allsolid;
|
|
|
|
float *trace_startsolid;
|
|
|
|
float *trace_fraction;
|
|
|
|
vec3_t *trace_endpos;
|
|
|
|
vec3_t *trace_plane_normal;
|
|
|
|
float *trace_plane_dist;
|
2022-01-16 13:15:18 +00:00
|
|
|
pr_uint_t *trace_ent;
|
2010-12-09 09:32:21 +00:00
|
|
|
float *trace_inopen;
|
|
|
|
float *trace_inwater;
|
2022-01-16 13:15:18 +00:00
|
|
|
pr_uint_t *msg_entity;
|
2010-12-09 09:32:21 +00:00
|
|
|
float *skill;
|
2001-03-01 08:34:30 +00:00
|
|
|
} sv_globals_t;
|
|
|
|
|
|
|
|
extern sv_globals_t sv_globals;
|
|
|
|
|
|
|
|
typedef struct {
|
2022-01-18 06:32:43 +00:00
|
|
|
pr_func_t main;
|
|
|
|
pr_func_t StartFrame;
|
|
|
|
pr_func_t PlayerPreThink;
|
|
|
|
pr_func_t PlayerPostThink;
|
|
|
|
pr_func_t ClientKill;
|
|
|
|
pr_func_t ClientConnect;
|
|
|
|
pr_func_t PutClientInServer;
|
|
|
|
pr_func_t ClientDisconnect;
|
|
|
|
pr_func_t SetNewParms;
|
|
|
|
pr_func_t SetChangeParms;
|
|
|
|
|
|
|
|
pr_func_t EndFrame;
|
|
|
|
pr_func_t SpectatorConnect;
|
|
|
|
pr_func_t SpectatorThink;
|
|
|
|
pr_func_t SpectatorDisconnect;
|
|
|
|
pr_func_t UserInfoCallback;
|
|
|
|
pr_func_t UserInfoChanged;
|
|
|
|
pr_func_t ChatMessage;
|
|
|
|
pr_func_t LocalinfoChanged;
|
2001-03-01 08:34:30 +00:00
|
|
|
} sv_funcs_t;
|
|
|
|
|
|
|
|
extern sv_funcs_t sv_funcs;
|
|
|
|
|
2001-03-01 18:44:19 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-12-09 09:32:21 +00:00
|
|
|
pr_int_t modelindex; //float
|
|
|
|
pr_int_t absmin; //vec3_t
|
|
|
|
pr_int_t absmax; //vec3_t
|
|
|
|
pr_int_t ltime; //float
|
|
|
|
pr_int_t lastruntime; //float
|
|
|
|
pr_int_t movetype; //float
|
|
|
|
pr_int_t solid; //float
|
|
|
|
pr_int_t origin; //vec3_t
|
|
|
|
pr_int_t oldorigin; //vec3_t
|
|
|
|
pr_int_t velocity; //vec3_t
|
|
|
|
pr_int_t angles; //vec3_t
|
|
|
|
pr_int_t avelocity; //vec3_t
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_int_t classname; //pr_string_t
|
|
|
|
pr_int_t model; //pr_string_t
|
2010-12-09 09:32:21 +00:00
|
|
|
pr_int_t frame; //float
|
|
|
|
pr_int_t skin; //float
|
|
|
|
pr_int_t effects; //float
|
|
|
|
pr_int_t mins; //vec3_t
|
|
|
|
pr_int_t maxs; //vec3_t
|
|
|
|
pr_int_t size; //vec3_t
|
2022-01-18 06:32:43 +00:00
|
|
|
pr_int_t touch; //pr_func_t
|
|
|
|
pr_int_t think; //pr_func_t
|
|
|
|
pr_int_t blocked; //pr_func_t
|
2010-12-09 09:32:21 +00:00
|
|
|
pr_int_t nextthink; //float
|
|
|
|
pr_int_t groundentity; //int
|
|
|
|
pr_int_t health; //float
|
|
|
|
pr_int_t frags; //float
|
|
|
|
pr_int_t weapon; //float
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_int_t weaponmodel; //pr_string_t
|
2010-12-09 09:32:21 +00:00
|
|
|
pr_int_t weaponframe; //float
|
|
|
|
pr_int_t currentammo; //float
|
|
|
|
pr_int_t ammo_shells; //float
|
|
|
|
pr_int_t ammo_nails; //float
|
|
|
|
pr_int_t ammo_rockets; //float
|
|
|
|
pr_int_t ammo_cells; //float
|
|
|
|
pr_int_t items; //float
|
|
|
|
pr_int_t takedamage; //float
|
|
|
|
pr_int_t chain; //int
|
|
|
|
pr_int_t view_ofs; //vec3_t
|
|
|
|
pr_int_t button0; //float
|
|
|
|
pr_int_t button1; //float
|
|
|
|
pr_int_t button2; //float
|
|
|
|
pr_int_t impulse; //float
|
|
|
|
pr_int_t fixangle; //float
|
|
|
|
pr_int_t v_angle; //vec3_t
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_int_t netname; //pr_string_t
|
2010-12-09 09:32:21 +00:00
|
|
|
pr_int_t enemy; //int
|
|
|
|
pr_int_t flags; //float
|
|
|
|
pr_int_t colormap; //float
|
|
|
|
pr_int_t team; //float
|
|
|
|
pr_int_t teleport_time; //float
|
|
|
|
pr_int_t armorvalue; //float
|
|
|
|
pr_int_t waterlevel; //float
|
|
|
|
pr_int_t watertype; //float
|
|
|
|
pr_int_t ideal_yaw; //float
|
|
|
|
pr_int_t yaw_speed; //float
|
|
|
|
pr_int_t goalentity; //int
|
|
|
|
pr_int_t spawnflags; //float
|
|
|
|
pr_int_t dmg_take; //float
|
|
|
|
pr_int_t dmg_save; //float
|
|
|
|
pr_int_t dmg_inflictor; //int
|
|
|
|
pr_int_t owner; //int
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_int_t message; //pr_string_t
|
2010-12-09 09:32:21 +00:00
|
|
|
pr_int_t sounds; //float
|
|
|
|
pr_int_t rotated_bbox; //int
|
2007-04-06 00:47:41 +00:00
|
|
|
|
|
|
|
pr_int_t alpha;
|
|
|
|
pr_int_t scale;
|
|
|
|
pr_int_t glow_size;
|
|
|
|
pr_int_t glow_color;
|
|
|
|
pr_int_t colormod;
|
|
|
|
|
|
|
|
pr_int_t gravity;
|
|
|
|
pr_int_t maxspeed;
|
|
|
|
|
|
|
|
pr_int_t team_str; //string
|
2001-03-01 18:44:19 +00:00
|
|
|
} sv_fields_t;
|
|
|
|
|
|
|
|
extern sv_fields_t sv_fields;
|
|
|
|
|
2010-12-09 05:27:36 +00:00
|
|
|
extern progs_t sv_pr_state;
|
2003-11-21 06:09:21 +00:00
|
|
|
|
2004-01-06 07:00:39 +00:00
|
|
|
#define PR_RANGE_ID 0x0000
|
|
|
|
#define PR_RANGE_ID_MAX 82
|
|
|
|
#define PR_RANGE_QWE 0x0001
|
2007-04-06 13:59:05 +00:00
|
|
|
#define PR_RANGE_CPQW 0x0002
|
2004-01-06 07:00:39 +00:00
|
|
|
|
2001-06-08 00:11:54 +00:00
|
|
|
#if TYPECHECK_PROGS
|
2001-03-27 03:57:17 +00:00
|
|
|
#define SVFIELD(e,f,t) E_var (e, PR_AccessField (&sv_pr_state, #f, ev_##t, __FILE__, __LINE__), t)
|
2001-03-01 21:11:35 +00:00
|
|
|
#else
|
2001-03-01 18:44:19 +00:00
|
|
|
#define SVFIELD(e,f,t) E_var (e, sv_fields.f, t)
|
2001-03-01 21:11:35 +00:00
|
|
|
#endif
|
2001-03-01 18:44:19 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
#define SVfloat(e,f) SVFIELD (e, f, float)
|
|
|
|
#define SVstring(e,f) SVFIELD (e, f, string)
|
|
|
|
#define SVfunc(e,f) SVFIELD (e, f, func)
|
|
|
|
#define SVentity(e,f) SVFIELD (e, f, entity)
|
2020-12-20 17:12:51 +00:00
|
|
|
#define SVvector(e,f) (&SVFIELD (e, f, vector))
|
2022-01-18 04:21:06 +00:00
|
|
|
#define SVint(e,f) SVFIELD (e, f, int)
|
2020-02-14 07:38:37 +00:00
|
|
|
#if TYPECHECK_PROGS
|
|
|
|
#define SVdouble(e,f) E_DOUBLE (e, PR_AccessField (&sv_pr_state, #f, ev_##t, __FILE__, __LINE__))
|
|
|
|
#else
|
|
|
|
#define SVdouble(e,f) E_DOUBLE (e, sv_fields.f)
|
|
|
|
#endif
|
2001-08-08 20:28:53 +00:00
|
|
|
|
2010-12-09 05:27:36 +00:00
|
|
|
typedef struct edict_leaf_s {
|
|
|
|
struct edict_leaf_s *next;
|
2010-12-09 06:30:08 +00:00
|
|
|
unsigned leafnum;
|
2010-12-09 05:27:36 +00:00
|
|
|
} edict_leaf_t;
|
|
|
|
|
|
|
|
typedef struct sv_data_s {
|
|
|
|
edict_t *edict;
|
|
|
|
link_t area; ///< linked to a division node or leaf
|
|
|
|
edict_leaf_t *leafs;
|
|
|
|
entity_state_t state;
|
2012-04-28 05:53:15 +00:00
|
|
|
qboolean add_grav;
|
2010-12-09 05:27:36 +00:00
|
|
|
} sv_data_t;
|
|
|
|
|
|
|
|
#define SVdata(e) ((sv_data_t *) ((e)->edata))
|
|
|
|
#define EDICT_FROM_AREA(l) (STRUCT_FROM_LINK(l,sv_data_t,area)->edict)
|
2001-03-01 18:44:19 +00:00
|
|
|
|
2002-05-31 21:05:58 +00:00
|
|
|
static inline void
|
2022-02-05 01:24:02 +00:00
|
|
|
sv_pr_exec (edict_t *self, edict_t *other, pr_func_t func)
|
2002-05-31 21:05:58 +00:00
|
|
|
{
|
2007-04-06 00:47:41 +00:00
|
|
|
pr_int_t this;
|
2002-05-31 21:05:58 +00:00
|
|
|
|
|
|
|
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
|
|
|
|
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, other);
|
2011-04-08 06:01:56 +00:00
|
|
|
if ((this = sv_pr_state.fields.this) != -1) {
|
2022-02-05 01:24:02 +00:00
|
|
|
PR_PushFrame (&sv_pr_state);
|
2006-12-05 09:55:37 +00:00
|
|
|
PR_RESET_PARAMS (&sv_pr_state);
|
2003-09-12 23:12:21 +00:00
|
|
|
P_INT (&sv_pr_state, 0) = E_POINTER (self, this);
|
2011-04-08 06:01:56 +00:00
|
|
|
P_INT (&sv_pr_state, 1) = 0;
|
2003-09-12 23:12:21 +00:00
|
|
|
P_INT (&sv_pr_state, 2) = E_POINTER (other, this);
|
2002-05-31 21:05:58 +00:00
|
|
|
}
|
2022-02-05 01:24:02 +00:00
|
|
|
PR_ExecuteProgram (&sv_pr_state, func);
|
|
|
|
if ((this = sv_pr_state.fields.this) != -1) {
|
|
|
|
PR_PopFrame (&sv_pr_state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
sv_pr_touch (edict_t *self, edict_t *other)
|
|
|
|
{
|
|
|
|
sv_pr_exec (self, other, SVfunc (self, touch));
|
2002-05-31 21:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
sv_pr_use (edict_t *self, edict_t *other)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
sv_pr_think (edict_t *self)
|
|
|
|
{
|
2022-02-05 01:24:02 +00:00
|
|
|
sv_pr_exec (self, 0, SVfunc (self, think));
|
2002-05-31 21:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
sv_pr_blocked (edict_t *self, edict_t *other)
|
|
|
|
{
|
2022-02-05 01:24:02 +00:00
|
|
|
sv_pr_exec (self, other, SVfunc (self, blocked));
|
2002-05-31 21:05:58 +00:00
|
|
|
}
|
|
|
|
|
2001-03-01 08:34:30 +00:00
|
|
|
#endif // __sv_progs_h
|