split progs.h into multiple files

master
an 2019-12-06 20:01:10 -05:00
parent 3b85dd08f9
commit c5a4c2424a
9 changed files with 554 additions and 446 deletions

View File

@ -88,10 +88,13 @@ set(srcs
source/net_sys.h
source/platform.h
source/pr_cmds.c
source/pr_comp.h
source/pr_defs.h
source/pr_edict.c
source/pr_edict.h
source/pr_exec.c
source/pr_global.h
source/pr_load.c
source/pr_ops.h
source/pr_string.c
source/progs.h
source/protocol.h

View File

@ -1,329 +0,0 @@
/*
Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2010-2014 QuakeSpasm developers
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.
*/
#ifndef spingle__pr_comp_h
#define spingle__pr_comp_h
enum
{
GBL_NULL,
GBL_RETURN,
GBL_PARM0 = GBL_RETURN + 3,
GBL_PARM1 = GBL_PARM0 + 3,
GBL_PARM2 = GBL_PARM1 + 3,
GBL_PARM3 = GBL_PARM2 + 3,
GBL_PARM4 = GBL_PARM3 + 3,
GBL_PARM5 = GBL_PARM4 + 3,
GBL_PARM6 = GBL_PARM5 + 3,
GBL_PARM7 = GBL_PARM6 + 3,
GBL_self = 28,
GBL_other,
GBL_world,
GBL_time,
GBL_frametime,
GBL_force_retouch,
GBL_mapname,
GBL_deathmatch,
GBL_coop,
GBL_teamplay,
GBL_serverflags,
GBL_total_secrets,
GBL_total_monsters,
GBL_found_secrets,
GBL_killed_monsters,
GBL_parm1,
GBL_parm2,
GBL_parm3,
GBL_parm4,
GBL_parm5,
GBL_parm6,
GBL_parm7,
GBL_parm8,
GBL_parm9,
GBL_parm10,
GBL_parm11,
GBL_parm12,
GBL_parm13,
GBL_parm14,
GBL_parm15,
GBL_parm16,
GBL_v_forward,
GBL_v_up = GBL_v_forward + 3,
GBL_v_right = GBL_v_up + 3,
GBL_trace_allsolid = GBL_v_right + 3,
GBL_trace_startsolid,
GBL_trace_fraction,
GBL_trace_endpos,
GBL_trace_plane_normal = GBL_trace_endpos + 3,
GBL_trace_plane_dist = GBL_trace_plane_normal + 3,
GBL_trace_ent,
GBL_trace_inopen,
GBL_trace_inwater,
GBL_msg_entity,
GBL_main,
GBL_StartFrame,
GBL_PlayerPreThink,
GBL_PlayerPostThink,
GBL_ClientKill,
GBL_ClientConnect,
GBL_PutClientInServer,
GBL_ClientDisconnect,
GBL_SetNewParms,
GBL_SetChangeParms,
GBL_SYSTEM_END,
};
enum
{
ED_modelindex,
ED_absmin,
ED_absmax = ED_absmin + 3,
ED_ltime = ED_absmax + 3,
ED_movetype,
ED_solid,
ED_origin,
ED_oldorigin = ED_origin + 3,
ED_velocity = ED_oldorigin + 3,
ED_angles = ED_velocity + 3,
ED_avelocity = ED_angles + 3,
ED_punchangle = ED_avelocity + 3,
ED_classname = ED_punchangle + 3,
ED_model,
ED_frame,
ED_skin,
ED_effects,
ED_mins,
ED_maxs = ED_mins + 3,
ED_size = ED_maxs + 3,
ED_touch = ED_size + 3,
ED_use,
ED_think,
ED_blocked,
ED_nextthink,
ED_groundentity,
ED_health,
ED_frags,
ED_weapon,
ED_weaponmodel,
ED_weaponframe,
ED_currentammo,
ED_ammo_shells,
ED_ammo_nails,
ED_ammo_rockets,
ED_ammo_cells,
ED_items,
ED_takedamage,
ED_chain,
ED_deadflag,
ED_view_ofs,
ED_button0 = ED_view_ofs + 3,
ED_button1,
ED_button2,
ED_impulse,
ED_fixangle,
ED_v_angle,
ED_idealpitch = ED_v_angle + 3,
ED_netname,
ED_enemy,
ED_flags,
ED_colormap,
ED_team,
ED_max_health,
ED_teleport_time,
ED_armortype,
ED_armorvalue,
ED_waterlevel,
ED_watertype,
ED_ideal_yaw,
ED_yaw_speed,
ED_aiment,
ED_goalentity,
ED_spawnflags,
ED_target,
ED_targetname,
ED_dmg_take,
ED_dmg_save,
ED_dmg_inflictor,
ED_owner,
ED_movedir,
ED_message = ED_movedir + 3,
ED_sounds,
ED_noise,
ED_noise1,
ED_noise2,
ED_noise3,
ED_SYSTEM_END,
};
#define DEF_SAVEGLOBAL (1 << 15)
#define PROG_VERSION 6
typedef int32_t func_t;
typedef int32_t string_t;
typedef enum
{
ev_bad = -1,
ev_void = 0,
ev_string,
ev_float,
ev_vector,
ev_entity,
ev_field,
ev_function,
ev_pointer
} etype_t;
enum
{
OP_DONE,
OP_MUL_F,
OP_MUL_V,
OP_MUL_FV,
OP_MUL_VF,
OP_DIV_F,
OP_ADD_F,
OP_ADD_V,
OP_SUB_F,
OP_SUB_V,
OP_EQ_F,
OP_EQ_V,
OP_EQ_S,
OP_EQ_E,
OP_EQ_FNC,
OP_NE_F,
OP_NE_V,
OP_NE_S,
OP_NE_E,
OP_NE_FNC,
OP_LE,
OP_GE,
OP_LT,
OP_GT,
OP_LOAD_F,
OP_LOAD_V,
OP_LOAD_S,
OP_LOAD_ENT,
OP_LOAD_FLD,
OP_LOAD_FNC,
OP_ADDRESS,
OP_STORE_F,
OP_STORE_V,
OP_STORE_S,
OP_STORE_ENT,
OP_STORE_FLD,
OP_STORE_FNC,
OP_STOREP_F,
OP_STOREP_V,
OP_STOREP_S,
OP_STOREP_ENT,
OP_STOREP_FLD,
OP_STOREP_FNC,
OP_RETURN,
OP_NOT_F,
OP_NOT_V,
OP_NOT_S,
OP_NOT_ENT,
OP_NOT_FNC,
OP_IF,
OP_IFNOT,
OP_CALL0,
OP_CALL1,
OP_CALL2,
OP_CALL3,
OP_CALL4,
OP_CALL5,
OP_CALL6,
OP_CALL7,
OP_CALL8,
OP_STATE,
OP_GOTO,
OP_AND,
OP_OR,
OP_BITAND,
OP_BITOR
};
typedef struct
{
uint16_t op;
int16_t a, b, c;
} dstatement_t;
typedef struct
{
uint16_t type; /* if DEF_SAVEGLOBAL bit is set the variable needs to be saved in savegames */
uint16_t ofs;
int32_t s_name;
} ddef_t;
typedef struct
{
int32_t first_statement; // negative numbers are builtins
int32_t parm_start;
int32_t locals; // total ints of parms + locals
int32_t profile; // runtime
int32_t s_name;
int32_t s_file; // source file defined in
int32_t numparms;
byte parm_size[8];
} dfunction_t;
typedef struct
{
int32_t version;
int32_t crc; // check of header file
int32_t ofs_statements;
int32_t numstatements; // statement 0 is an error
int32_t ofs_globaldefs;
int32_t numglobaldefs;
int32_t ofs_fielddefs;
int32_t numfielddefs;
int32_t ofs_functions;
int32_t numfunctions; // function 0 is an empty
int32_t ofs_strings;
int32_t numstrings; // first string is a null string
int32_t ofs_globals;
int32_t numglobals;
int32_t entityfields;
} dprograms_t;
#endif

71
source/pr_defs.h Normal file
View File

@ -0,0 +1,71 @@
/*
Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2002-2009 John Fitzgibbons and others
Copyright (C) 2010-2014 QuakeSpasm developers
Copyright (C) 2019 Alison G. Watson
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.
*/
#ifndef spingle__pr_defs_h
#define spingle__pr_defs_h
enum
{
DEF_SAVEGLOBAL = 1 << 15
};
typedef enum
{
ev_bad = -1,
ev_void = 0,
ev_string,
ev_float,
ev_vector,
ev_entity,
ev_field,
ev_function,
ev_pointer
} etype_t;
typedef int32_t func_t;
typedef int32_t string_t;
typedef uint32_t pedict_t;
typedef uint32_t pfield_t;
typedef uint32_t prptr_t;
typedef void (*builtin_t)(void);
typedef struct
{
uint16_t type; /* if DEF_SAVEGLOBAL bit is set the variable needs to be saved in savegames */
uint16_t ofs;
int32_t s_name;
} ddef_t;
typedef union eval_s
{
float _float;
vec3_t vec;
func_t func;
int32_t _int;
pedict_t edict;
pfield_t field;
string_t string;
prptr_t ptr;
} eval_t;
#endif

View File

@ -878,12 +878,12 @@ edict_t *EDICT_NUM(int32_t n)
{
if(n < 0 || n >= sv.max_edicts)
Host_Error("EDICT_NUM: bad number %" PRIi32 "", n);
return (edict_t *)PROG_TO_EDICT(n * pr_edict_size);
return PROG_TO_EDICT(n * pr_edict_size);
}
int32_t NUM_FOR_EDICT(edict_t *e)
{
int32_t b;
int32_t b;
b = EDICT_TO_PROG(e);
b = b / pr_edict_size;
@ -892,3 +892,14 @@ int32_t NUM_FOR_EDICT(edict_t *e)
Host_Error("NUM_FOR_EDICT: bad pointer");
return b;
}
pedict_t EDICT_TO_PROG(void *e)
{
return (byte *)e - (byte *)sv.edicts;
}
void *PROG_TO_EDICT(pedict_t e)
{
return (byte *)sv.edicts + e;
}

183
source/pr_edict.h Normal file
View File

@ -0,0 +1,183 @@
/*
Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2002-2009 John Fitzgibbons and others
Copyright (C) 2010-2014 QuakeSpasm developers
Copyright (C) 2019 Alison G. Watson
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.
*/
#ifndef spingle__pr_edict_h
#define spingle__pr_edict_h
#define EDICT_FROM_AREA(l) (edict_t *)((byte *)(l) - offsetof(edict_t, area))
#define ED_FLOAT(e, o) (((float *)((edict_t *)e)->fields)[o])
#define ED_INT(e, o) (((int32_t *)((edict_t *)e)->fields)[o])
#define ED_EDICT(e, o) PROG_TO_EDICT(ED_INT(e, o))
#define ED_EDICTNUM(e, o) NUM_FOR_EDICT(ED_EDICT(e, o))
#define ED_VECTOR(e, o) (&ED_FLOAT(e, o))
#define ED_STRING(e, o) PR_GetString(ED_RSTRING(e, o))
#define ED_RSTRING(e, o) (*(string_t *)&ED_INT(e, o))
#define ED_FUNC(e, o) (*(func_t *)&ED_INT(e, o))
#define ED_PEDICT(e, o) (*(pedict_t *)&ED_INT(e, o))
#define ED_PFIELD(e, o) (*(pfield_t *)&ED_INT(e, o))
#define ED_EVAL(e, o) ((eval_t *)&ED_INT(e, o))
#define ED_VOID(e, o) ((void *)&ED_INT(o))
enum
{
MAX_ENT_LEAFS = 32
};
enum
{
ED_modelindex,
ED_absmin,
ED_absmax = ED_absmin + 3,
ED_ltime = ED_absmax + 3,
ED_movetype,
ED_solid,
ED_origin,
ED_oldorigin = ED_origin + 3,
ED_velocity = ED_oldorigin + 3,
ED_angles = ED_velocity + 3,
ED_avelocity = ED_angles + 3,
ED_punchangle = ED_avelocity + 3,
ED_classname = ED_punchangle + 3,
ED_model,
ED_frame,
ED_skin,
ED_effects,
ED_mins,
ED_maxs = ED_mins + 3,
ED_size = ED_maxs + 3,
ED_touch = ED_size + 3,
ED_use,
ED_think,
ED_blocked,
ED_nextthink,
ED_groundentity,
ED_health,
ED_frags,
ED_weapon,
ED_weaponmodel,
ED_weaponframe,
ED_currentammo,
ED_ammo_shells,
ED_ammo_nails,
ED_ammo_rockets,
ED_ammo_cells,
ED_items,
ED_takedamage,
ED_chain,
ED_deadflag,
ED_view_ofs,
ED_button0 = ED_view_ofs + 3,
ED_button1,
ED_button2,
ED_impulse,
ED_fixangle,
ED_v_angle,
ED_idealpitch = ED_v_angle + 3,
ED_netname,
ED_enemy,
ED_flags,
ED_colormap,
ED_team,
ED_max_health,
ED_teleport_time,
ED_armortype,
ED_armorvalue,
ED_waterlevel,
ED_watertype,
ED_ideal_yaw,
ED_yaw_speed,
ED_aiment,
ED_goalentity,
ED_spawnflags,
ED_target,
ED_targetname,
ED_dmg_take,
ED_dmg_save,
ED_dmg_inflictor,
ED_owner,
ED_movedir,
ED_message = ED_movedir + 3,
ED_sounds,
ED_noise,
ED_noise1,
ED_noise2,
ED_noise3,
ED_SYSTEM_END,
};
typedef struct edict_s
{
bool free;
link_t area; /* linked to a division node or leaf */
int32_t num_leafs;
int32_t leafnums[MAX_ENT_LEAFS];
entity_state_t baseline;
uint8_t alpha;
bool sendinterval; /* johnfitz -- send time until nextthink to client for better lerp timing */
float freetime; /* sv.time when the object was freed */
byte fields[];
} edict_t;
extern ddef_t *pr_fielddefs;
extern int32_t pr_edict_size;
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);
const char *ED_ParseEdict(const char *data, edict_t *ent);
void ED_WriteGlobals(FILE *f);
const char *ED_ParseGlobals(const char *data);
void ED_LoadFromFile(const char *data);
ddef_t *ED_GlobalAtOfs(int32_t ofs);
ddef_t *ED_FieldAtOfs(int32_t ofs);
bool ED_ParseEpair(void *base, ddef_t *key, const char *s);
void ED_Init(void);
void ED_Load(void);
void ED_PrintEdicts(void);
void ED_PrintNum(int32_t ent);
eval_t *GetEdictFieldValue(edict_t *ed, const char *field);
static inline edict_t *NEXT_EDICT(edict_t *e)
{
return (edict_t *)((byte *)e + pr_edict_size);
}
pedict_t EDICT_TO_PROG(void *e);
void *PROG_TO_EDICT(pedict_t e);
edict_t *EDICT_NUM(int32_t n);
int32_t NUM_FOR_EDICT(edict_t *e);
#endif

112
source/pr_global.h Normal file
View File

@ -0,0 +1,112 @@
/*
Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2002-2009 John Fitzgibbons and others
Copyright (C) 2010-2014 QuakeSpasm developers
Copyright (C) 2019 Alison G. Watson
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.
*/
#ifndef spingle__pr_global_h
#define spingle__pr_global_h
#define G_FLOAT(o) (((float *)pr_global_data)[o])
#define G_INT(o) (((int32_t *)pr_global_data)[o])
#define G_EDICT(o) PROG_TO_EDICT(G_INT(o))
#define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
#define G_VECTOR(o) (&G_FLOAT(o))
#define G_STRING(o) PR_GetString(G_RSTRING(o))
#define G_RSTRING(o) (*(string_t *)&G_INT(o))
#define G_FUNC(o) (*(func_t *)&G_INT(o))
#define G_PEDICT(o) (*(pedict_t *)&G_INT(o))
#define G_PFIELD(o) (*(pfield_t *)&G_INT(o))
#define G_EVAL(o) ((eval_t *)&G_INT(o))
#define G_VOID(o) ((void *)&G_INT(o))
enum
{
GBL_NULL,
GBL_RETURN,
GBL_PARM0 = GBL_RETURN + 3,
GBL_PARM1 = GBL_PARM0 + 3,
GBL_PARM2 = GBL_PARM1 + 3,
GBL_PARM3 = GBL_PARM2 + 3,
GBL_PARM4 = GBL_PARM3 + 3,
GBL_PARM5 = GBL_PARM4 + 3,
GBL_PARM6 = GBL_PARM5 + 3,
GBL_PARM7 = GBL_PARM6 + 3,
GBL_self = 28,
GBL_other,
GBL_world,
GBL_time,
GBL_frametime,
GBL_force_retouch,
GBL_mapname,
GBL_deathmatch,
GBL_coop,
GBL_teamplay,
GBL_serverflags,
GBL_total_secrets,
GBL_total_monsters,
GBL_found_secrets,
GBL_killed_monsters,
GBL_parm1,
GBL_parm2,
GBL_parm3,
GBL_parm4,
GBL_parm5,
GBL_parm6,
GBL_parm7,
GBL_parm8,
GBL_parm9,
GBL_parm10,
GBL_parm11,
GBL_parm12,
GBL_parm13,
GBL_parm14,
GBL_parm15,
GBL_parm16,
GBL_v_forward,
GBL_v_up = GBL_v_forward + 3,
GBL_v_right = GBL_v_up + 3,
GBL_trace_allsolid = GBL_v_right + 3,
GBL_trace_startsolid,
GBL_trace_fraction,
GBL_trace_endpos,
GBL_trace_plane_normal = GBL_trace_endpos + 3,
GBL_trace_plane_dist = GBL_trace_plane_normal + 3,
GBL_trace_ent,
GBL_trace_inopen,
GBL_trace_inwater,
GBL_msg_entity,
GBL_main,
GBL_StartFrame,
GBL_PlayerPreThink,
GBL_PlayerPostThink,
GBL_ClientKill,
GBL_ClientConnect,
GBL_PutClientInServer,
GBL_ClientDisconnect,
GBL_SetNewParms,
GBL_SetChangeParms,
GBL_SYSTEM_END,
};
extern byte *pr_global_data;
extern ddef_t *pr_globaldefs;
#endif

133
source/pr_ops.h Normal file
View File

@ -0,0 +1,133 @@
/*
Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2002-2009 John Fitzgibbons and others
Copyright (C) 2010-2014 QuakeSpasm developers
Copyright (C) 2019 Alison G. Watson
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.
*/
#ifndef spingle__pr_ops_h
#define spingle__pr_ops_h
enum
{
OP_DONE,
OP_MUL_F,
OP_MUL_V,
OP_MUL_FV,
OP_MUL_VF,
OP_DIV_F,
OP_ADD_F,
OP_ADD_V,
OP_SUB_F,
OP_SUB_V,
OP_EQ_F,
OP_EQ_V,
OP_EQ_S,
OP_EQ_E,
OP_EQ_FNC,
OP_NE_F,
OP_NE_V,
OP_NE_S,
OP_NE_E,
OP_NE_FNC,
OP_LE,
OP_GE,
OP_LT,
OP_GT,
OP_LOAD_F,
OP_LOAD_V,
OP_LOAD_S,
OP_LOAD_ENT,
OP_LOAD_FLD,
OP_LOAD_FNC,
OP_ADDRESS,
OP_STORE_F,
OP_STORE_V,
OP_STORE_S,
OP_STORE_ENT,
OP_STORE_FLD,
OP_STORE_FNC,
OP_STOREP_F,
OP_STOREP_V,
OP_STOREP_S,
OP_STOREP_ENT,
OP_STOREP_FLD,
OP_STOREP_FNC,
OP_RETURN,
OP_NOT_F,
OP_NOT_V,
OP_NOT_S,
OP_NOT_ENT,
OP_NOT_FNC,
OP_IF,
OP_IFNOT,
OP_CALL0,
OP_CALL1,
OP_CALL2,
OP_CALL3,
OP_CALL4,
OP_CALL5,
OP_CALL6,
OP_CALL7,
OP_CALL8,
OP_STATE,
OP_GOTO,
OP_AND,
OP_OR,
OP_BITAND,
OP_BITOR
};
typedef struct
{
uint16_t op;
int16_t a, b, c;
} dstatement_t;
typedef struct
{
int32_t first_statement; // negative numbers are builtins
int32_t parm_start;
int32_t locals; // total ints of parms + locals
int32_t profile; // runtime
int32_t s_name;
int32_t s_file; // source file defined in
int32_t numparms;
byte parm_size[8];
} dfunction_t;
extern dfunction_t *pr_functions;
extern dstatement_t *pr_statements;
void PR_ExecuteProgram(func_t fnum);
void PR_LoadProgs(void);
#endif

View File

@ -23,132 +23,50 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef spingle__progs_h
#define spingle__progs_h
#include "pr_comp.h" /* defs shared with qcc */
#include "pr_defs.h"
#include "pr_edict.h"
#include "pr_global.h"
#include "pr_ops.h"
#define PROGHEADER_CRC 5927
typedef uint32_t pedict_t;
typedef uint32_t pfield_t;
typedef uint32_t prptr_t;
typedef union eval_s
enum
{
float _float;
vec3_t vec;
func_t func;
int32_t _int;
pedict_t edict;
pfield_t field;
string_t string;
prptr_t ptr;
} eval_t;
PROGHEADER_CRC = 5927,
PROG_VERSION = 6
};
#define MAX_ENT_LEAFS 32
typedef struct edict_s
typedef struct
{
bool free;
link_t area; /* linked to a division node or leaf */
int32_t version;
int32_t crc; // check of header file
int32_t num_leafs;
int32_t leafnums[MAX_ENT_LEAFS];
int32_t ofs_statements;
int32_t numstatements; // statement 0 is an error
entity_state_t baseline;
uint8_t alpha;
bool sendinterval; /* johnfitz -- send time until nextthink to client for better lerp timing */
int32_t ofs_globaldefs;
int32_t numglobaldefs;
float freetime; /* sv.time when the object was freed */
int32_t ofs_fielddefs;
int32_t numfielddefs;
byte fields[];
} edict_t;
int32_t ofs_functions;
int32_t numfunctions; // function 0 is an empty
#define EDICT_FROM_AREA(l) (edict_t *)((byte *)(l) - offsetof(edict_t, area))
int32_t ofs_strings;
int32_t numstrings; // first string is a null string
#define ED_FLOAT(e, o) (((float *)e->fields)[o])
#define ED_INT(e, o) (((int32_t *)e->fields)[o])
#define ED_EDICT(e, o) PROG_TO_EDICT(ED_INT(e, o))
#define ED_EDICTNUM(e, o) NUM_FOR_EDICT(ED_EDICT(e, o))
#define ED_VECTOR(e, o) (&ED_FLOAT(e, o))
#define ED_STRING(e, o) PR_GetString(ED_RSTRING(e, o))
#define ED_RSTRING(e, o) (*(string_t *)&ED_INT(e, o))
#define ED_FUNC(e, o) (*(func_t *)&ED_INT(e, o))
#define ED_PEDICT(e, o) (*(pedict_t *)&ED_INT(e, o))
#define ED_PFIELD(e, o) (*(pfield_t *)&ED_INT(e, o))
#define ED_EVAL(e, o) ((eval_t *)&ED_INT(e, o))
#define ED_VOID(e, o) ((void *)&ED_INT(o))
int32_t ofs_globals;
int32_t numglobals;
//============================================================================
int32_t entityfields;
} dprograms_t;
extern dprograms_t progs;
extern dfunction_t *pr_functions;
extern dstatement_t *pr_statements;
extern byte *pr_global_data;
extern ddef_t *pr_fielddefs;
extern int32_t pr_edict_size;
extern dprograms_t progs;
extern char const *pr_strings;
extern char const **pr_knownstrings;
extern int32_t pr_maxknownstrings;
extern int32_t pr_numknownstrings;
extern ddef_t *pr_globaldefs;
const char *PR_ValueString(int32_t type, eval_t *val);
const char *PR_UglyValueString(int32_t type, eval_t *val);
void PR_Init(void);
void PR_ExecuteProgram(func_t fnum);
void PR_LoadProgs(void);
const char *PR_GetString(int32_t num);
int32_t PR_SetEngineString(const char *s);
int32_t PR_AllocString(int32_t bufferlength, char **ptr);
void PR_Profile_f(void);
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);
const char *ED_ParseEdict(const char *data, edict_t *ent);
void ED_WriteGlobals(FILE *f);
const char *ED_ParseGlobals(const char *data);
void ED_LoadFromFile(const char *data);
ddef_t *ED_GlobalAtOfs(int32_t ofs);
ddef_t *ED_FieldAtOfs(int32_t ofs);
bool ED_ParseEpair(void *base, ddef_t *key, const char *s);
void ED_Init(void);
void ED_Load(void);
edict_t *EDICT_NUM(int32_t n);
int32_t NUM_FOR_EDICT(edict_t *e);
#define NEXT_EDICT(e) ((edict_t *)((byte *)(e) + pr_edict_size))
#define EDICT_TO_PROG(e) ((byte *)(e) - (byte *)sv.edicts)
#define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + (e)))
#define G_FLOAT(o) (((float *)pr_global_data)[o])
#define G_INT(o) (((int32_t *)pr_global_data)[o])
#define G_EDICT(o) PROG_TO_EDICT(G_INT(o))
#define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
#define G_VECTOR(o) (&G_FLOAT(o))
#define G_STRING(o) PR_GetString(G_RSTRING(o))
#define G_RSTRING(o) (*(string_t *)&G_INT(o))
#define G_FUNC(o) (*(func_t *)&G_INT(o))
#define G_PEDICT(o) (*(pedict_t *)&G_INT(o))
#define G_PFIELD(o) (*(pfield_t *)&G_INT(o))
#define G_EVAL(o) ((eval_t *)&G_INT(o))
#define G_VOID(o) ((void *)&G_INT(o))
typedef void (*builtin_t)(void);
extern builtin_t pr_builtins[];
extern int32_t pr_numbuiltins;
@ -162,11 +80,17 @@ extern uint16_t pr_crc;
extern bool pr_alpha_supported; //johnfitz
const char *PR_ValueString(int32_t type, eval_t *val);
const char *PR_UglyValueString(int32_t type, eval_t *val);
void PR_Init(void);
const char *PR_GetString(int32_t num);
int32_t PR_SetEngineString(const char *s);
int32_t PR_AllocString(int32_t bufferlength, char **ptr);
void PR_Profile_f(void);
noreturn void PR_RunError(const char *error, ...) FUNC_PRINTF(1, 2);
void ED_PrintEdicts(void);
void ED_PrintNum(int32_t ent);
eval_t *GetEdictFieldValue(edict_t *ed, const char *field);
#endif

View File

@ -103,7 +103,7 @@ int32_t main(int32_t argc, char *argv[])
Sys_Printf(ENGINE_NAME " " VERSION " (c) id Software, John Fitzgibbons, "
"SleepwalkR, Baker, Ozkan Sezer, Eric Wasylishen, "
"Alison Watson, et al.\n");
"Alison G. Watson, et al.\n");
Host_Init();