diff --git a/source/common.h b/source/common.h index 93878f1..f24d008 100644 --- a/source/common.h +++ b/source/common.h @@ -25,20 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // comndef.h -- general definitions -#if defined(_WIN32) -#ifdef _MSC_VER -# pragma warning(disable:4244) -/* 'argument' : conversion from 'type1' to 'type2', - possible loss of data */ -# pragma warning(disable:4305) -/* 'identifier' : truncation from 'type1' to 'type2' */ -/* in our case, truncation from 'double' to 'float' */ -# pragma warning(disable:4267) -/* 'var' : conversion from 'size_t' to 'type', - possible loss of data (/Wp64 warning) */ -#endif /* _MSC_VER */ -#endif /* _WIN32 */ - #undef min #undef max #define q_min(a, b) (((a) < (b)) ? (a) : (b)) diff --git a/source/pr_comp.h b/source/pr_comp.h index 2a2fe3b..be77e57 100644 --- a/source/pr_comp.h +++ b/source/pr_comp.h @@ -40,17 +40,16 @@ typedef enum ev_pointer } etype_t; -#define OFS_NULL 0 -#define OFS_RETURN 1 -#define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors -#define OFS_PARM1 7 -#define OFS_PARM2 10 -#define OFS_PARM3 13 -#define OFS_PARM4 16 -#define OFS_PARM5 19 -#define OFS_PARM6 22 -#define OFS_PARM7 25 -#define RESERVED_OFS 28 +#define OFS_NULL 0 +#define OFS_RETURN 1 +#define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors +#define OFS_PARM1 7 +#define OFS_PARM2 10 +#define OFS_PARM3 13 +#define OFS_PARM4 16 +#define OFS_PARM5 19 +#define OFS_PARM6 22 +#define OFS_PARM7 25 enum diff --git a/source/pr_edict.c b/source/pr_edict.c index a946fbb..f1cff7f 100644 --- a/source/pr_edict.c +++ b/source/pr_edict.c @@ -775,13 +775,13 @@ returns false if error */ static bool ED_ParseEpair(void *base, ddef_t *key, const char *s) { - int32_t i; - char string[128]; - ddef_t *def; - char *v, *w; - char *end; - void *d; - dfunction_t *func; + int32_t i; + char string[128]; + ddef_t *def; + char *v, *w; + char *end; + void *d; + dfunction_t *func; d = (void *)((int32_t *)base + key->ofs); diff --git a/source/pr_exec.c b/source/pr_exec.c index 449ed69..a512ffb 100644 --- a/source/pr_exec.c +++ b/source/pr_exec.c @@ -356,12 +356,12 @@ The interpretation main loop void PR_ExecuteProgram(func_t fnum) { - eval_t *ptr; - dstatement_t *st; - dfunction_t *f, *newf; - int32_t profile, startprofile; - edict_t *ed; - int32_t exitdepth; + eval_t *ptr; + dstatement_t *st; + dfunction_t *f, *newf; + int32_t profile, startprofile; + edict_t *ed; + int32_t exitdepth; if(!fnum || fnum >= progs->numfunctions) { @@ -374,7 +374,7 @@ void PR_ExecuteProgram(func_t fnum) pr_trace = false; -// make a stack frame + // make a stack frame exitdepth = pr_depth; st = &pr_statements[PR_EnterFunction(f)]; @@ -382,7 +382,8 @@ void PR_ExecuteProgram(func_t fnum) while(1) { - st++; /* next statement */ + /* next statement */ + st++; if(++profile > 100000) { @@ -444,24 +445,12 @@ void PR_ExecuteProgram(func_t fnum) OPC->_float = (int32_t)OPA->_float | (int32_t)OPB->_float; break; - case OP_GE: - OPC->_float = OPA->_float >= OPB->_float; - break; - case OP_LE: - OPC->_float = OPA->_float <= OPB->_float; - break; - case OP_GT: - OPC->_float = OPA->_float > OPB->_float; - break; - case OP_LT: - OPC->_float = OPA->_float < OPB->_float; - break; - case OP_AND: - OPC->_float = OPA->_float && OPB->_float; - break; - case OP_OR: - OPC->_float = OPA->_float || OPB->_float; - break; + case OP_GE: OPC->_float = OPA->_float >= OPB->_float; break; + case OP_LE: OPC->_float = OPA->_float <= OPB->_float; break; + case OP_GT: OPC->_float = OPA->_float > OPB->_float; break; + case OP_LT: OPC->_float = OPA->_float < OPB->_float; break; + case OP_AND: OPC->_float = OPA->_float && OPB->_float; break; + case OP_OR: OPC->_float = OPA->_float || OPB->_float; break; case OP_NOT_F: OPC->_float = !OPA->_float; @@ -517,9 +506,9 @@ void PR_ExecuteProgram(func_t fnum) case OP_STORE_F: case OP_STORE_ENT: - case OP_STORE_FLD: // integers + case OP_STORE_FLD: case OP_STORE_S: - case OP_STORE_FNC: // pointers + case OP_STORE_FNC: OPB->_int = OPA->_int; break; case OP_STORE_V: @@ -579,19 +568,9 @@ void PR_ExecuteProgram(func_t fnum) OPC->vector[2] = ptr->vector[2]; break; - case OP_IFNOT: - if(!OPA->_int) - st += st->b - 1; /* -1 to offset the st++ */ - break; - - case OP_IF: - if(OPA->_int) - st += st->b - 1; /* -1 to offset the st++ */ - break; - - case OP_GOTO: - st += st->a - 1; /* -1 to offset the st++ */ - break; + case OP_IFNOT: if(!OPA->_int) st += st->b - 1; break; + case OP_IF: if(OPA->_int) st += st->b - 1; break; + case OP_GOTO: st += st->a - 1; break; case OP_CALL0: case OP_CALL1: @@ -649,7 +628,7 @@ void PR_ExecuteProgram(func_t fnum) pr_xstatement = st - pr_statements; PR_RunError("Bad opcode %" PRIi32 "", st->op); } - } /* end of while(1) loop */ + } } #undef OPA #undef OPB diff --git a/source/progdefs.h b/source/progdefs.h index d2364dc..29fb50f 100644 --- a/source/progdefs.h +++ b/source/progdefs.h @@ -22,7 +22,146 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __PROGDEFS_H #define __PROGDEFS_H -#include "progdefs.q1" +typedef struct +{ + int32_t pad[28]; + int32_t self; + int32_t other; + int32_t world; + float time; + float frametime; + float force_retouch; + string_t mapname; + float deathmatch; + float coop; + float teamplay; + float serverflags; + float total_secrets; + float total_monsters; + float found_secrets; + float killed_monsters; + float parm1; + float parm2; + float parm3; + float parm4; + float parm5; + float parm6; + float parm7; + float parm8; + float parm9; + float parm10; + float parm11; + float parm12; + float parm13; + float parm14; + float parm15; + float parm16; + 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; + int32_t trace_ent; + float trace_inopen; + float trace_inwater; + int32_t msg_entity; + func_t main; + func_t StartFrame; + func_t PlayerPreThink; + func_t PlayerPostThink; + func_t ClientKill; + func_t ClientConnect; + func_t PutClientInServer; + func_t ClientDisconnect; + func_t SetNewParms; + func_t SetChangeParms; +} globalvars_t; + +typedef struct +{ + float modelindex; + vec3_t absmin; + vec3_t absmax; + float ltime; + float movetype; + float solid; + vec3_t origin; + vec3_t oldorigin; + vec3_t velocity; + vec3_t angles; + vec3_t avelocity; + vec3_t punchangle; + string_t classname; + string_t model; + float frame; + float skin; + float effects; + vec3_t mins; + vec3_t maxs; + vec3_t size; + func_t touch; + func_t use; + func_t think; + func_t blocked; + float nextthink; + int32_t groundentity; + float health; + float frags; + float weapon; + string_t weaponmodel; + float weaponframe; + float currentammo; + float ammo_shells; + float ammo_nails; + float ammo_rockets; + float ammo_cells; + float items; + float takedamage; + int32_t chain; + float deadflag; + vec3_t view_ofs; + float button0; + float button1; + float button2; + float impulse; + float fixangle; + vec3_t v_angle; + float idealpitch; + string_t netname; + int32_t enemy; + float flags; + float colormap; + float team; + float max_health; + float teleport_time; + float armortype; + float armorvalue; + float waterlevel; + float watertype; + float ideal_yaw; + float yaw_speed; + int32_t aiment; + int32_t goalentity; + float spawnflags; + string_t target; + string_t targetname; + float dmg_take; + float dmg_save; + int32_t dmg_inflictor; + int32_t owner; + vec3_t movedir; + string_t message; + float sounds; + string_t noise; + string_t noise1; + string_t noise2; + string_t noise3; +} entvars_t; + +#define PROGHEADER_CRC 5927 #endif /* __PROGDEFS_H */ - diff --git a/source/progdefs.q1 b/source/progdefs.q1 deleted file mode 100644 index 68295b4..0000000 --- a/source/progdefs.q1 +++ /dev/null @@ -1,143 +0,0 @@ - -/* file generated by qcc, do not modify */ - -typedef struct -{ int32_t pad[28]; - int32_t self; - int32_t other; - int32_t world; - float time; - float frametime; - float force_retouch; - string_t mapname; - float deathmatch; - float coop; - float teamplay; - float serverflags; - float total_secrets; - float total_monsters; - float found_secrets; - float killed_monsters; - float parm1; - float parm2; - float parm3; - float parm4; - float parm5; - float parm6; - float parm7; - float parm8; - float parm9; - float parm10; - float parm11; - float parm12; - float parm13; - float parm14; - float parm15; - float parm16; - 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; - int32_t trace_ent; - float trace_inopen; - float trace_inwater; - int32_t msg_entity; - func_t main; - func_t StartFrame; - func_t PlayerPreThink; - func_t PlayerPostThink; - func_t ClientKill; - func_t ClientConnect; - func_t PutClientInServer; - func_t ClientDisconnect; - func_t SetNewParms; - func_t SetChangeParms; -} globalvars_t; - -typedef struct -{ - float modelindex; - vec3_t absmin; - vec3_t absmax; - float ltime; - float movetype; - float solid; - vec3_t origin; - vec3_t oldorigin; - vec3_t velocity; - vec3_t angles; - vec3_t avelocity; - vec3_t punchangle; - string_t classname; - string_t model; - float frame; - float skin; - float effects; - vec3_t mins; - vec3_t maxs; - vec3_t size; - func_t touch; - func_t use; - func_t think; - func_t blocked; - float nextthink; - int32_t groundentity; - float health; - float frags; - float weapon; - string_t weaponmodel; - float weaponframe; - float currentammo; - float ammo_shells; - float ammo_nails; - float ammo_rockets; - float ammo_cells; - float items; - float takedamage; - int32_t chain; - float deadflag; - vec3_t view_ofs; - float button0; - float button1; - float button2; - float impulse; - float fixangle; - vec3_t v_angle; - float idealpitch; - string_t netname; - int32_t enemy; - float flags; - float colormap; - float team; - float max_health; - float teleport_time; - float armortype; - float armorvalue; - float waterlevel; - float watertype; - float ideal_yaw; - float yaw_speed; - int32_t aiment; - int32_t goalentity; - float spawnflags; - string_t target; - string_t targetname; - float dmg_take; - float dmg_save; - int32_t dmg_inflictor; - int32_t owner; - vec3_t movedir; - string_t message; - float sounds; - string_t noise; - string_t noise1; - string_t noise2; - string_t noise3; -} entvars_t; - -#define PROGHEADER_CRC 5927 diff --git a/source/progs.h b/source/progs.h index 35c6e0e..7f5003e 100644 --- a/source/progs.h +++ b/source/progs.h @@ -28,12 +28,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef union eval_s { - string_t string; - float _float; - float vector[3]; - func_t function; - int32_t _int; - int32_t edict; + string_t string; + float _float; + float vector[3]; + func_t function; + int32_t _int; + int32_t edict; } eval_t; #define MAX_ENT_LEAFS 32 @@ -59,13 +59,13 @@ typedef struct edict_s //============================================================================ -extern dprograms_t *progs; -extern dfunction_t *pr_functions; -extern dstatement_t *pr_statements; -extern globalvars_t *pr_global_struct; -extern float *pr_globals; /* same as pr_global_struct */ +extern dprograms_t *progs; +extern dfunction_t *pr_functions; +extern dstatement_t *pr_statements; +extern globalvars_t *pr_global_struct; +extern float *pr_globals; -extern int32_t pr_edict_size; /* in bytes */ +extern int32_t pr_edict_size; void PR_Init(void);