2010-02-15 23:26:55 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 1996-2001 Id Software, Inc.
|
|
|
|
Copyright (C) 2002-2009 John Fitzgibbons and others
|
2014-09-22 08:55:46 +00:00
|
|
|
Copyright (C) 2010-2014 QuakeSpasm developers
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
bspfile.h, cdaudio.h, client.h, cmd.h, common.h, console.h, crc.h, cvar.h,
d_ifacea.h, draw.h, gl_texmgr.h, glquake.h, image.h, input.h, keys.h, mathlib.h,
menu.h, modelgen.h, net.h, net_dgrm.h, net_loop.h, net_sdlnet.h, net_udp.h,
net_wins.h, platform.h, pr_comp.h, progdefs.h, progs.h, protocol.h, quakedef.h,
render.h, resource.h, sbar.h, screen.h, server.h, sound.h, spritegn.h, sys.h,
vid.h, view.h, wad.h, world.h, zone.h: added include guards to the headers.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@84 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-21 00:01:08 +00:00
|
|
|
#ifndef _QUAKE_PROGS_H
|
|
|
|
#define _QUAKE_PROGS_H
|
|
|
|
|
2011-12-12 08:56:25 +00:00
|
|
|
#include "pr_comp.h" /* defs shared with qcc */
|
|
|
|
#include "progdefs.h" /* generated by program cdefs */
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
typedef union eval_s
|
|
|
|
{
|
2011-12-12 08:56:25 +00:00
|
|
|
string_t string;
|
|
|
|
float _float;
|
|
|
|
float vector[3];
|
|
|
|
func_t function;
|
|
|
|
int _int;
|
|
|
|
int edict;
|
2010-02-15 23:26:55 +00:00
|
|
|
} eval_t;
|
|
|
|
|
2014-08-13 06:40:07 +00:00
|
|
|
#define MAX_ENT_LEAFS 32
|
2010-02-15 23:26:55 +00:00
|
|
|
typedef struct edict_s
|
|
|
|
{
|
2011-12-12 08:56:25 +00:00
|
|
|
qboolean free;
|
|
|
|
link_t area; /* linked to a division node or leaf */
|
|
|
|
|
|
|
|
int num_leafs;
|
2014-04-13 09:03:48 +00:00
|
|
|
int leafnums[MAX_ENT_LEAFS];
|
2011-12-12 08:56:25 +00:00
|
|
|
|
2010-02-15 23:26:55 +00:00
|
|
|
entity_state_t baseline;
|
2011-12-12 08:56:25 +00:00
|
|
|
unsigned char alpha; /* johnfitz -- hack to support alpha since it's not part of entvars_t */
|
|
|
|
qboolean sendinterval; /* johnfitz -- send time until nextthink to client for better lerp timing */
|
|
|
|
|
|
|
|
float freetime; /* sv.time when the object was freed */
|
|
|
|
entvars_t v; /* C exported fields from progs */
|
|
|
|
|
|
|
|
/* other fields from progs come immediately after */
|
2010-02-15 23:26:55 +00:00
|
|
|
} edict_t;
|
2011-12-12 08:56:25 +00:00
|
|
|
|
|
|
|
#define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area)
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
2011-12-12 08:56:25 +00:00
|
|
|
extern dprograms_t *progs;
|
|
|
|
extern dfunction_t *pr_functions;
|
2010-02-15 23:26:55 +00:00
|
|
|
extern dstatement_t *pr_statements;
|
|
|
|
extern globalvars_t *pr_global_struct;
|
2011-12-12 08:56:25 +00:00
|
|
|
extern float *pr_globals; /* same as pr_global_struct */
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-12 08:56:25 +00:00
|
|
|
extern int pr_edict_size; /* in bytes */
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PR_Init (void);
|
|
|
|
|
|
|
|
void PR_ExecuteProgram (func_t fnum);
|
|
|
|
void PR_LoadProgs (void);
|
|
|
|
|
2010-08-29 02:22:55 +00:00
|
|
|
const char *PR_GetString (int num);
|
|
|
|
int PR_SetEngineString (const char *s);
|
64 bit compatibility effort, 4/nn: x86_64 works just fine now, yey!
the QuakeC interpreter used to use string pointer offsets from pr_strings
even when the pointers lead to engine data which is often well out of
32bit range on a 64bit architecture and they lead to crashes. they now
go through the new PR_SetEngineString and PR_GetString functions which
turn any address outside the pr_strings area into an index into a table
of engine string addresses, adding new string addresses to the table as
needed. the engine strings table is allocated with 256 entries at first
(see the PR_STRING_ALLOCSLOTS definition in pr_edict.c) and its size is
incremented by 256 as needed and re-allocated on the zone. managing that
allocation and reallocation is accomplished by the recently added Z_Realloc
function. implementation based on the uhexen2 (hexen2: hammer of thyrion)
engine which, in turn, is loosely based on twilight and quakeforge engines.
pr_strings range check is from tyrquake.
pr_edict.c: added the new PR_SetEngineString, PR_GetString, PR_AllocString
public functions and the new private PR_AllocStringSlots function. made
ED_NewString private to pr_edict.c and reworked it to return an index to a
newly allocated string.
progs.h: added prototypes for the new public PR_SetEngineString, PR_GetString
and PR_AllocString functions.
host_cmd.c, pr_cmds.c, pr_edict.c, pr_exec.c, progs.h, sv_main.c, sv_phys.c:
modifed to use the new PR_SetEngineString and PR_GetString functions.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@38 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-17 15:04:50 +00:00
|
|
|
int PR_AllocString (int bufferlength, char **ptr);
|
|
|
|
|
2011-12-12 08:56:25 +00:00
|
|
|
void PR_Profile_f (void);
|
|
|
|
|
2010-02-15 23:26:55 +00:00
|
|
|
edict_t *ED_Alloc (void);
|
|
|
|
void ED_Free (edict_t *ed);
|
|
|
|
|
|
|
|
void ED_Print (edict_t *ed);
|
|
|
|
void ED_Write (FILE *f, edict_t *ed);
|
2010-08-29 02:22:55 +00:00
|
|
|
const char *ED_ParseEdict (const char *data, edict_t *ent);
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
void ED_WriteGlobals (FILE *f);
|
2010-08-29 02:22:55 +00:00
|
|
|
void ED_ParseGlobals (const char *data);
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2010-08-29 02:22:55 +00:00
|
|
|
void ED_LoadFromFile (const char *data);
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-12 08:56:25 +00:00
|
|
|
/*
|
|
|
|
#define EDICT_NUM(n) ((edict_t *)(sv.edicts+ (n)*pr_edict_size))
|
|
|
|
#define NUM_FOR_EDICT(e) (((byte *)(e) - sv.edicts) / pr_edict_size)
|
|
|
|
*/
|
2010-02-15 23:26:55 +00:00
|
|
|
edict_t *EDICT_NUM(int n);
|
|
|
|
int NUM_FOR_EDICT(edict_t *e);
|
|
|
|
|
2011-12-12 08:56:25 +00:00
|
|
|
#define NEXT_EDICT(e) ((edict_t *)( (byte *)e + pr_edict_size))
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-12 08:56:25 +00:00
|
|
|
#define EDICT_TO_PROG(e) ((byte *)e - (byte *)sv.edicts)
|
|
|
|
#define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e))
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-12 08:56:25 +00:00
|
|
|
#define G_FLOAT(o) (pr_globals[o])
|
|
|
|
#define G_INT(o) (*(int *)&pr_globals[o])
|
|
|
|
#define G_EDICT(o) ((edict_t *)((byte *)sv.edicts+ *(int *)&pr_globals[o]))
|
|
|
|
#define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
|
|
|
|
#define G_VECTOR(o) (&pr_globals[o])
|
|
|
|
#define G_STRING(o) (PR_GetString(*(string_t *)&pr_globals[o]))
|
|
|
|
#define G_FUNCTION(o) (*(func_t *)&pr_globals[o])
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-12 08:56:25 +00:00
|
|
|
#define E_FLOAT(e,o) (((float*)&e->v)[o])
|
|
|
|
#define E_INT(e,o) (*(int *)&((float*)&e->v)[o])
|
|
|
|
#define E_VECTOR(e,o) (&((float*)&e->v)[o])
|
|
|
|
#define E_STRING(e,o) (PR_GetString(*(string_t *)&((float*)&e->v)[o]))
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
extern int type_size[8];
|
|
|
|
|
|
|
|
typedef void (*builtin_t) (void);
|
2011-12-12 08:56:25 +00:00
|
|
|
extern builtin_t *pr_builtins;
|
|
|
|
extern int pr_numbuiltins;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-12 08:56:25 +00:00
|
|
|
extern int pr_argc;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
extern qboolean pr_trace;
|
|
|
|
extern dfunction_t *pr_xfunction;
|
2011-12-12 08:56:25 +00:00
|
|
|
extern int pr_xstatement;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-12-12 08:56:25 +00:00
|
|
|
extern unsigned short pr_crc;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2011-07-08 17:27:44 +00:00
|
|
|
void PR_RunError (const char *error, ...) __attribute__((__format__(__printf__,1,2), __noreturn__));
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
void ED_PrintEdicts (void);
|
|
|
|
void ED_PrintNum (int ent);
|
|
|
|
|
2010-08-29 02:22:55 +00:00
|
|
|
eval_t *GetEdictFieldValue(edict_t *ed, const char *field);
|
2010-02-15 23:26:55 +00:00
|
|
|
|
bspfile.h, cdaudio.h, client.h, cmd.h, common.h, console.h, crc.h, cvar.h,
d_ifacea.h, draw.h, gl_texmgr.h, glquake.h, image.h, input.h, keys.h, mathlib.h,
menu.h, modelgen.h, net.h, net_dgrm.h, net_loop.h, net_sdlnet.h, net_udp.h,
net_wins.h, platform.h, pr_comp.h, progdefs.h, progs.h, protocol.h, quakedef.h,
render.h, resource.h, sbar.h, screen.h, server.h, sound.h, spritegn.h, sys.h,
vid.h, view.h, wad.h, world.h, zone.h: added include guards to the headers.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@84 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-21 00:01:08 +00:00
|
|
|
#endif /* _QUAKE_PROGS_H */
|
|
|
|
|