From e660b4c0147da9f4b5db110a05cfbadcea6b1b64 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 9 May 2011 17:56:56 +0000 Subject: [PATCH] reworked PRVM_EDICTFIELD* and PRVM_GLOBALFIELD* usage to have more specific naming of the macros, and allow code analysis to audit the used fields/globals for better maintenance git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11144 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_collision.c | 2 +- clvm_cmds.c | 114 +++++----- csprogs.c | 359 +++++++++++++++-------------- gl_rmain.c | 4 +- host_cmd.c | 29 ++- menu.c | 19 +- netconn.c | 46 ++-- progsvm.h | 85 +++++++ protocol.c | 34 +-- prvm_cmds.c | 154 ++++++------- prvm_edict.c | 46 +++- prvm_exec.c | 12 +- prvm_execprogram.h | 8 +- sv_demo.c | 4 +- sv_main.c | 552 ++++++++++++++++++++------------------------- sv_phys.c | 38 ++-- sv_user.c | 56 ++--- svvm_cmds.c | 32 +-- world.c | 88 ++++---- 19 files changed, 851 insertions(+), 831 deletions(-) diff --git a/cl_collision.c b/cl_collision.c index 79989532..0f8ab408 100644 --- a/cl_collision.c +++ b/cl_collision.c @@ -199,7 +199,7 @@ int CL_GenericHitSuperContentsMask(const prvm_edict_t *passedict) { if (passedict) { - int dphitcontentsmask = (int)PRVM_EDICTFIELDFLOAT(passedict, prog->fieldoffsets.dphitcontentsmask); + int dphitcontentsmask = (int)PRVM_clientedictfloat(passedict, dphitcontentsmask); if (dphitcontentsmask) return dphitcontentsmask; else if (passedict->fields.client->solid == SOLID_SLIDEBOX) diff --git a/clvm_cmds.c b/clvm_cmds.c index 87ee706a..ea5ea170 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -235,7 +235,7 @@ static void VM_CL_spawn (void) void CL_VM_SetTraceGlobals(const trace_t *trace, int svent) { VM_SetTraceGlobals(trace); - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_networkentity) = svent; + PRVM_clientglobalfloat(trace_networkentity) = svent; } #define CL_HitNetworkBrushModels(move) !((move) == MOVE_WORLDONLY) @@ -325,7 +325,7 @@ trace_t CL_Trace_Toss (prvm_edict_t *tossent, prvm_edict_t *ignore, int *svent) VectorCopy(tossent->fields.client->angles , original_angles ); VectorCopy(tossent->fields.client->avelocity, original_avelocity); - gravity = PRVM_EDICTFIELDFLOAT(tossent, prog->fieldoffsets.gravity); + gravity = PRVM_clientedictfloat(tossent, gravity); if (!gravity) gravity = 1.0f; gravity *= cl.movevars_gravity * 0.05; @@ -529,7 +529,7 @@ static void VM_CL_droptofloor (void) { VectorCopy (trace.endpos, ent->fields.client->origin); ent->fields.client->flags = (int)ent->fields.client->flags | FL_ONGROUND; - PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.groundentity) = PRVM_EDICT_TO_PROG(trace.ent); + PRVM_clientedictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent); PRVM_G_FLOAT(OFS_RETURN) = 1; // if support is destroyed, keep suspended (gross hack for floating items in various maps) // ent->priv.server->suspendedinairflag = true; @@ -1276,13 +1276,13 @@ static void VM_CL_boxparticles (void) Vector4Set(tintmaxs, 1, 1, 1, 1); if(flags & 1) // read alpha { - tintmins[3] = PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.particles_alphamin); - tintmaxs[3] = PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.particles_alphamax); + tintmins[3] = PRVM_clientglobalfloat(particles_alphamin); + tintmaxs[3] = PRVM_clientglobalfloat(particles_alphamax); } if(flags & 2) // read color { - VectorCopy(PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.particles_colormin), tintmins); - VectorCopy(PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.particles_colormax), tintmaxs); + VectorCopy(PRVM_clientglobalvector(particles_colormin), tintmins); + VectorCopy(PRVM_clientglobalvector(particles_colormax), tintmaxs); } if (effectnum < 0) return; @@ -1585,10 +1585,10 @@ static void VM_CL_makestatic (void) staticent->render.framegroupblend[0].start = lhrandom(-10, -1); staticent->render.skinnum = (int)ent->fields.client->skin; staticent->render.effects = (int)ent->fields.client->effects; - staticent->render.alpha = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.alpha); - staticent->render.scale = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.scale); - VectorCopy(PRVM_EDICTFIELDVECTOR(ent, prog->fieldoffsets.colormod), staticent->render.colormod); - VectorCopy(PRVM_EDICTFIELDVECTOR(ent, prog->fieldoffsets.glowmod), staticent->render.glowmod); + staticent->render.alpha = PRVM_clientedictfloat(ent, alpha); + staticent->render.scale = PRVM_clientedictfloat(ent, scale); + VectorCopy(PRVM_clientedictvector(ent, colormod), staticent->render.colormod); + VectorCopy(PRVM_clientedictvector(ent, glowmod), staticent->render.glowmod); // sanitize values if (!staticent->render.alpha) @@ -1600,7 +1600,7 @@ static void VM_CL_makestatic (void) if (!VectorLength2(staticent->render.glowmod)) VectorSet(staticent->render.glowmod, 1, 1, 1); - renderflags = (int)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.renderflags); + renderflags = (int)PRVM_clientedictfloat(ent, renderflags); if (renderflags & RF_USEAXIS) { vec3_t left; @@ -2128,8 +2128,8 @@ void VM_CL_setattachment (void) Con_DPrintf("setattachment(edict %i, edict %i, string \"%s\"): tried to find tag named \"%s\" on entity %i but it has no model\n", PRVM_NUM_FOR_EDICT(e), PRVM_NUM_FOR_EDICT(tagentity), tagname, tagname, PRVM_NUM_FOR_EDICT(tagentity)); } - PRVM_EDICTFIELDEDICT(e, prog->fieldoffsets.tag_entity) = PRVM_EDICT_TO_PROG(tagentity); - PRVM_EDICTFIELDFLOAT(e, prog->fieldoffsets.tag_index) = tagindex; + PRVM_clientedictedict(e, tag_entity) = PRVM_EDICT_TO_PROG(tagentity); + PRVM_clientedictfloat(e, tag_index) = tagindex; } ///////////////////////////////////////// @@ -2181,13 +2181,13 @@ void CL_GetEntityMatrix (prvm_edict_t *ent, matrix4x4_t *out, qboolean viewmatri float scale; float pitchsign = 1; - scale = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.scale); + scale = PRVM_clientedictfloat(ent, scale); if (!scale) scale = 1.0f; if(viewmatrix) *out = r_refdef.view.matrix; - else if ((int)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.renderflags) & RF_USEAXIS) + else if ((int)PRVM_clientedictfloat(ent, renderflags) & RF_USEAXIS) { vec3_t forward; vec3_t left; @@ -2265,10 +2265,10 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex) Matrix4x4_Concat(&tagmatrix, &attachmatrix, out); Matrix4x4_Concat(out, &entitymatrix, &tagmatrix); // next iteration we process the parent entity - if (PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.tag_entity)) + if (PRVM_clientedictedict(ent, tag_entity)) { - tagindex = (int)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.tag_index); - ent = PRVM_EDICT_NUM(PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.tag_entity)); + tagindex = (int)PRVM_clientedictfloat(ent, tag_index); + ent = PRVM_EDICT_NUM(PRVM_clientedictedict(ent, tag_entity)); } else break; @@ -2276,7 +2276,7 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex) } // RENDER_VIEWMODEL magic - if ((int)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.renderflags) & RF_VIEWMODEL) + if ((int)PRVM_clientedictfloat(ent, renderflags) & RF_VIEWMODEL) { Matrix4x4_Copy(&tagmatrix, out); @@ -2370,12 +2370,12 @@ void VM_CL_gettaginfo (void) CL_GetExtendedTagInfo(e, tagindex, &parentindex, &tagname, &tag_localmatrix); Matrix4x4_ToVectors(&tag_localmatrix, fo, le, up, trans); - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.gettaginfo_parent) = parentindex; - PRVM_GLOBALFIELDSTRING(prog->globaloffsets.gettaginfo_name) = tagname ? PRVM_SetTempString(tagname) : 0; - VectorCopy(trans, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.gettaginfo_offset)); - VectorCopy(fo, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.gettaginfo_forward)); - VectorScale(le, -1, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.gettaginfo_right)); - VectorCopy(up, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.gettaginfo_up)); + PRVM_clientglobalfloat(gettaginfo_parent) = parentindex; + PRVM_clientglobalstring(gettaginfo_name) = tagname ? PRVM_SetTempString(tagname) : 0; + VectorCopy(trans, PRVM_clientglobalvector(gettaginfo_offset)); + VectorCopy(fo, PRVM_clientglobalvector(gettaginfo_forward)); + VectorScale(le, -1, PRVM_clientglobalvector(gettaginfo_right)); + VectorCopy(up, PRVM_clientglobalvector(gettaginfo_up)); switch(returncode) { @@ -2499,37 +2499,35 @@ static void VM_InitParticleSpawner (int maxthemes) vmpartspawner.initialized = true; vmpartspawner.verified = true; // get field addresses for fast querying (we can do 1000 calls of spawnparticle in a frame) - #define getglobal(v,s) vmpartspawner.v = &PRVM_GLOBALFIELDFLOAT(PRVM_ED_FindGlobalOffset(s)) - #define getglobalvector(v,s) vmpartspawner.v = PRVM_GLOBALFIELDVECTOR(PRVM_ED_FindGlobalOffset(s)) - getglobal(particle_type, "particle_type"); - getglobal(particle_blendmode, "particle_blendmode"); - getglobal(particle_orientation, "particle_orientation"); - getglobalvector(particle_color1, "particle_color1"); - getglobalvector(particle_color2, "particle_color2"); - getglobal(particle_tex, "particle_tex"); - getglobal(particle_size, "particle_size"); - getglobal(particle_sizeincrease, "particle_sizeincrease"); - getglobal(particle_alpha, "particle_alpha"); - getglobal(particle_alphafade, "particle_alphafade"); - getglobal(particle_time, "particle_time"); - getglobal(particle_gravity, "particle_gravity"); - getglobal(particle_bounce, "particle_bounce"); - getglobal(particle_airfriction, "particle_airfriction"); - getglobal(particle_liquidfriction, "particle_liquidfriction"); - getglobal(particle_originjitter, "particle_originjitter"); - getglobal(particle_velocityjitter, "particle_velocityjitter"); - getglobal(particle_qualityreduction, "particle_qualityreduction"); - getglobal(particle_stretch, "particle_stretch"); - getglobalvector(particle_staincolor1, "particle_staincolor1"); - getglobalvector(particle_staincolor2, "particle_staincolor2"); - getglobal(particle_stainalpha, "particle_stainalpha"); - getglobal(particle_stainsize, "particle_stainsize"); - getglobal(particle_staintex, "particle_staintex"); - getglobal(particle_staintex, "particle_staintex"); - getglobal(particle_delayspawn, "particle_delayspawn"); - getglobal(particle_delaycollision, "particle_delaycollision"); - getglobal(particle_angle, "particle_angle"); - getglobal(particle_spin, "particle_spin"); + vmpartspawner.particle_type = &PRVM_clientglobalfloat(particle_type); + vmpartspawner.particle_blendmode = &PRVM_clientglobalfloat(particle_blendmode); + vmpartspawner.particle_orientation = &PRVM_clientglobalfloat(particle_orientation); + vmpartspawner.particle_color1 = PRVM_clientglobalvector(particle_color1); + vmpartspawner.particle_color2 = PRVM_clientglobalvector(particle_color2); + vmpartspawner.particle_tex = &PRVM_clientglobalfloat(particle_tex); + vmpartspawner.particle_size = &PRVM_clientglobalfloat(particle_size); + vmpartspawner.particle_sizeincrease = &PRVM_clientglobalfloat(particle_sizeincrease); + vmpartspawner.particle_alpha = &PRVM_clientglobalfloat(particle_alpha); + vmpartspawner.particle_alphafade = &PRVM_clientglobalfloat(particle_alphafade); + vmpartspawner.particle_time = &PRVM_clientglobalfloat(particle_time); + vmpartspawner.particle_gravity = &PRVM_clientglobalfloat(particle_gravity); + vmpartspawner.particle_bounce = &PRVM_clientglobalfloat(particle_bounce); + vmpartspawner.particle_airfriction = &PRVM_clientglobalfloat(particle_airfriction); + vmpartspawner.particle_liquidfriction = &PRVM_clientglobalfloat(particle_liquidfriction); + vmpartspawner.particle_originjitter = &PRVM_clientglobalfloat(particle_originjitter); + vmpartspawner.particle_velocityjitter = &PRVM_clientglobalfloat(particle_velocityjitter); + vmpartspawner.particle_qualityreduction = &PRVM_clientglobalfloat(particle_qualityreduction); + vmpartspawner.particle_stretch = &PRVM_clientglobalfloat(particle_stretch); + vmpartspawner.particle_staincolor1 = PRVM_clientglobalvector(particle_staincolor1); + vmpartspawner.particle_staincolor2 = PRVM_clientglobalvector(particle_staincolor2); + vmpartspawner.particle_stainalpha = &PRVM_clientglobalfloat(particle_stainalpha); + vmpartspawner.particle_stainsize = &PRVM_clientglobalfloat(particle_stainsize); + vmpartspawner.particle_staintex = &PRVM_clientglobalfloat(particle_staintex); + vmpartspawner.particle_staintex = &PRVM_clientglobalfloat(particle_staintex); + vmpartspawner.particle_delayspawn = &PRVM_clientglobalfloat(particle_delayspawn); + vmpartspawner.particle_delaycollision = &PRVM_clientglobalfloat(particle_delaycollision); + vmpartspawner.particle_angle = &PRVM_clientglobalfloat(particle_angle); + vmpartspawner.particle_spin = &PRVM_clientglobalfloat(particle_spin); #undef getglobal #undef getglobalvector } @@ -3516,7 +3514,7 @@ qboolean CL_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean if ( (int)ent->fields.client->flags & FL_PARTIALGROUND ) ent->fields.client->flags = (int)ent->fields.client->flags & ~FL_PARTIALGROUND; - PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.groundentity) = PRVM_EDICT_TO_PROG(trace.ent); + PRVM_clientedictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent); // the move is ok if (relink) diff --git a/csprogs.c b/csprogs.c index ea2471e4..7dd08c49 100644 --- a/csprogs.c +++ b/csprogs.c @@ -23,7 +23,7 @@ void CL_VM_PreventInformationLeaks(void) return; CSQC_BEGIN VM_ClearTraceGlobals(); - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_networkentity) = 0; + PRVM_clientglobalfloat(trace_networkentity) = 0; CSQC_END } @@ -38,6 +38,146 @@ static const char *cl_required_func[] = static int cl_numrequiredfunc = sizeof(cl_required_func) / sizeof(char*); +#define CL_REQFIELDS (sizeof(cl_reqfields) / sizeof(prvm_required_field_t)) + +prvm_required_field_t cl_reqfields[] = +{ + {ev_entity, "aiment"}, // client field + {ev_entity, "enemy"}, // client field + {ev_entity, "groundentity"}, // client field + {ev_entity, "tag_entity"}, // client field + {ev_float, "alpha"}, // client field + {ev_float, "bouncefactor"}, // client field + {ev_float, "bouncestop"}, // client field + {ev_float, "dphitcontentsmask"}, // client field + {ev_float, "frame1time"}, // client field + {ev_float, "frame2time"}, // client field + {ev_float, "frame2"}, // client field + {ev_float, "frame3time"}, // client field + {ev_float, "frame3"}, // client field + {ev_float, "frame4time"}, // client field + {ev_float, "frame4"}, // client field + {ev_float, "frame"}, // client field + {ev_float, "gravity"}, // client field + {ev_float, "gravity"}, // client field + {ev_float, "ideal_yaw"}, // client field + {ev_float, "idealpitch"}, // client field + {ev_float, "jointtype"}, // client field + {ev_float, "lerpfrac3"}, // client field + {ev_float, "lerpfrac4"}, // client field + {ev_float, "lerpfrac"}, // client field + {ev_float, "mass"}, // client field + {ev_float, "modelindex"}, // client field + {ev_float, "movetype"}, // client field + {ev_float, "pitch_speed"}, // client field + {ev_float, "renderflags"}, // client field + {ev_float, "scale"}, // client field + {ev_float, "scale"}, // client field + {ev_float, "shadertime"}, // client field + {ev_float, "skeletonindex"}, // client field + {ev_float, "solid"}, // client field + {ev_float, "tag_index"}, // client field + {ev_float, "userwavefunc_param0"}, // client field + {ev_float, "userwavefunc_param1"}, // client field + {ev_float, "userwavefunc_param2"}, // client field + {ev_float, "userwavefunc_param3"}, // client field + {ev_float, "yaw_speed"}, // client field + {ev_function, "camera_transform"}, // client field + {ev_string, "classname"}, // client field + {ev_string, "message"}, // client field + {ev_vector, "angles"}, // client field + {ev_vector, "avelocity"}, // client field + {ev_vector, "colormod"}, // client field + {ev_vector, "glowmod"}, // client field + {ev_vector, "maxs"}, // client field + {ev_vector, "mins"}, // client field + {ev_vector, "movedir"}, // client field + {ev_vector, "origin"}, // client field + {ev_vector, "velocity"}, // client field +}; + +#define CL_REQGLOBALS (sizeof(cl_reqglobals) / sizeof(prvm_required_field_t)) + +prvm_required_field_t cl_reqglobals[] = +{ + {ev_entity, "self"}, // client global + {ev_entity, "trace_ent"}, // client global + {ev_float, "coop"}, // client global + {ev_float, "deathmatch"}, // client global + {ev_float, "dmg_save"}, // client global + {ev_float, "dmg_take"}, // client global + {ev_float, "drawfont"}, // client global + {ev_float, "gettaginfo_parent"}, // client global + {ev_float, "intermission"}, // client global + {ev_float, "particle_airfriction"}, // client global + {ev_float, "particle_alpha"}, // client global + {ev_float, "particle_alphafade"}, // client global + {ev_float, "particle_angle"}, // client global + {ev_float, "particle_blendmode"}, // client global + {ev_float, "particle_bounce"}, // client global + {ev_float, "particle_delaycollision"}, // client global + {ev_float, "particle_delayspawn"}, // client global + {ev_float, "particle_gravity"}, // client global + {ev_float, "particle_liquidfriction"}, // client global + {ev_float, "particle_orientation"}, // client global + {ev_float, "particle_originjitter"}, // client global + {ev_float, "particle_qualityreduction"}, // client global + {ev_float, "particle_size"}, // client global + {ev_float, "particle_sizeincrease"}, // client global + {ev_float, "particle_spin"}, // client global + {ev_float, "particle_stainalpha"}, // client global + {ev_float, "particle_stainsize"}, // client global + {ev_float, "particle_staintex"}, // client global + {ev_float, "particle_staintex"}, // client global + {ev_float, "particle_stretch"}, // client global + {ev_float, "particle_tex"}, // client global + {ev_float, "particle_time"}, // client global + {ev_float, "particle_type"}, // client global + {ev_float, "particle_velocityjitter"}, // client global + {ev_float, "particles_alphamax"}, // client global + {ev_float, "particles_alphamin"}, // client global + {ev_float, "require_spawnfunc_prefix"}, // client global + {ev_float, "sb_showscores"}, // client global + {ev_float, "serverdeltatime"}, // client global + {ev_float, "serverprevtime"}, // client global + {ev_float, "servertime"}, // client global + {ev_float, "trace_allsolid"}, // client global + {ev_float, "trace_dphitcontents"}, // client global + {ev_float, "trace_dphitq3surfaceflags"}, // client global + {ev_float, "trace_dpstartcontents"}, // client global + {ev_float, "trace_fraction"}, // client global + {ev_float, "trace_inopen"}, // client global + {ev_float, "trace_inwater"}, // client global + {ev_float, "trace_networkentity"}, // client global + {ev_float, "trace_plane_dist"}, // client global + {ev_float, "trace_startsolid"}, // client global + {ev_float, "transparent_offset"}, // client global + {ev_string, "gettaginfo_name"}, // client global + {ev_string, "trace_dphittexturename"}, // client global + {ev_vector, "dmg_origin"}, // client global + {ev_vector, "drawfontscale"}, // client global + {ev_vector, "gettaginfo_forward"}, // client global + {ev_vector, "gettaginfo_offset"}, // client global + {ev_vector, "gettaginfo_right"}, // client global + {ev_vector, "gettaginfo_up"}, // client global + {ev_vector, "particle_color1"}, // client global + {ev_vector, "particle_color2"}, // client global + {ev_vector, "particle_staincolor1"}, // client global + {ev_vector, "particle_staincolor2"}, // client global + {ev_vector, "particles_colormax"}, // client global + {ev_vector, "particles_colormin"}, // client global + {ev_vector, "pmove_inwater"}, // client global + {ev_vector, "pmove_onground"}, // client global + {ev_vector, "trace_endpos"}, // client global + {ev_vector, "trace_plane_normal"}, // client global + {ev_vector, "v_forward"}, // client global + {ev_vector, "v_right"}, // client global + {ev_vector, "v_up"}, // client global + {ev_vector, "view_angles"}, // client global + {ev_vector, "view_punchangle"}, // client global + {ev_vector, "view_punchvector"}, // client global +}; + void CL_VM_Error (const char *format, ...) DP_FUNC_PRINTF(1); void CL_VM_Error (const char *format, ...) //[515]: hope it will be never executed =) { @@ -63,9 +203,9 @@ void CL_VM_UpdateDmgGlobals (int dmg_take, int dmg_save, vec3_t dmg_origin) if(cl.csqc_loaded) { CSQC_BEGIN - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.dmg_take) = dmg_take; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.dmg_save) = dmg_save; - VectorCopy(dmg_origin, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.dmg_origin)); + PRVM_clientglobalfloat(dmg_take) = dmg_take; + PRVM_clientglobalfloat(dmg_save) = dmg_save; + VectorCopy(dmg_origin, PRVM_clientglobalvector(dmg_origin)); CSQC_END } } @@ -75,9 +215,9 @@ void CSQC_UpdateNetworkTimes(double newtime, double oldtime) if(!cl.csqc_loaded) return; CSQC_BEGIN - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.servertime) = newtime; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.serverprevtime) = oldtime; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.serverdeltatime) = newtime - oldtime; + PRVM_clientglobalfloat(servertime) = newtime; + PRVM_clientglobalfloat(serverprevtime) = oldtime; + PRVM_clientglobalfloat(serverdeltatime) = newtime - oldtime; CSQC_END } @@ -101,12 +241,12 @@ static void CSQC_SetGlobals (void) // completely replacing it Matrix4x4_OriginFromMatrix(&cl.entities[cl.viewentity].render.matrix, prog->globals.client->pmove_org); VectorCopy(cl.movement_velocity, prog->globals.client->pmove_vel); - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.pmove_onground) = cl.onground; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.pmove_inwater) = cl.inwater; + PRVM_clientglobalfloat(pmove_onground) = cl.onground; + PRVM_clientglobalfloat(pmove_inwater) = cl.inwater; - VectorCopy(cl.viewangles, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.view_angles)); - VectorCopy(cl.punchangle, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.view_punchangle)); - VectorCopy(cl.punchvector, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.view_punchvector)); + VectorCopy(cl.viewangles, PRVM_clientglobalvector(view_angles)); + VectorCopy(cl.punchangle, PRVM_clientglobalvector(view_punchangle)); + VectorCopy(cl.punchvector, PRVM_clientglobalvector(view_punchvector)); prog->globals.client->maxclients = cl.maxclients; CSQC_END } @@ -172,19 +312,19 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum) return false; } - entrender->userwavefunc_param[0] = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.userwavefunc_param0); - entrender->userwavefunc_param[1] = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.userwavefunc_param1); - entrender->userwavefunc_param[2] = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.userwavefunc_param2); - entrender->userwavefunc_param[3] = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.userwavefunc_param3); + entrender->userwavefunc_param[0] = PRVM_clientedictfloat(ed, userwavefunc_param0); + entrender->userwavefunc_param[1] = PRVM_clientedictfloat(ed, userwavefunc_param1); + entrender->userwavefunc_param[2] = PRVM_clientedictfloat(ed, userwavefunc_param2); + entrender->userwavefunc_param[3] = PRVM_clientedictfloat(ed, userwavefunc_param3); entrender->model = model; entrender->skinnum = (int)ed->fields.client->skin; entrender->effects |= entrender->model->effects; - renderflags = (int)PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.renderflags); - entrender->alpha = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.alpha); - entrender->scale = scale = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.scale); - VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.colormod), entrender->colormod); - VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.glowmod), entrender->glowmod); + renderflags = (int)PRVM_clientedictfloat(ed, renderflags); + entrender->alpha = PRVM_clientedictfloat(ed, alpha); + entrender->scale = scale = PRVM_clientedictfloat(ed, scale); + VectorCopy(PRVM_clientedictvector(ed, colormod), entrender->colormod); + VectorCopy(PRVM_clientedictvector(ed, glowmod), entrender->glowmod); if(ed->fields.client->effects) entrender->effects |= (int)ed->fields.client->effects; if (!entrender->alpha) entrender->alpha = 1.0f; @@ -202,11 +342,11 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum) VM_GenerateFrameGroupBlend(ed->priv.server->framegroupblend, ed); VM_FrameBlendFromFrameGroupBlend(ed->priv.server->frameblend, ed->priv.server->framegroupblend, model); VM_UpdateEdictSkeleton(ed, model, ed->priv.server->frameblend); - entrender->shadertime = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.shadertime); + entrender->shadertime = PRVM_clientedictfloat(ed, shadertime); // transparent offset if (renderflags & RF_USETRANSPARENTOFFSET) - entrender->transparent_offset = PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.transparent_offset); + entrender->transparent_offset = PRVM_clientglobalfloat(transparent_offset); if(renderflags) { @@ -518,7 +658,7 @@ void CL_VM_UpdateIntermissionState (int intermission) if(cl.csqc_loaded) { CSQC_BEGIN - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.intermission) = intermission; + PRVM_clientglobalfloat(intermission) = intermission; CSQC_END } } @@ -527,7 +667,7 @@ void CL_VM_UpdateShowingScoresState (int showingscores) if(cl.csqc_loaded) { CSQC_BEGIN - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.sb_showscores) = showingscores; + PRVM_clientglobalfloat(sb_showscores) = showingscores; CSQC_END } } @@ -582,8 +722,8 @@ void CL_VM_UpdateCoopDeathmatchGlobals (int gametype) localdeathmatch = 0; } CSQC_BEGIN - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.coop) = localcoop; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.deathmatch) = localdeathmatch; + PRVM_clientglobalfloat(coop) = localcoop; + PRVM_clientglobalfloat(deathmatch) = localdeathmatch; CSQC_END } } @@ -787,149 +927,6 @@ qboolean MakeDownloadPacket(const char *filename, unsigned char *data, size_t le return false; } -#define CL_REQFIELDS (sizeof(cl_reqfields) / sizeof(prvm_required_field_t)) - -prvm_required_field_t cl_reqfields[] = -{ - {ev_entity, "groundentity"}, - {ev_entity, "tag_entity"}, - {ev_float, "alpha"}, - {ev_float, "dimension_hit"}, - {ev_float, "dimension_solid"}, - {ev_float, "dphitcontentsmask"}, - {ev_float, "frame"}, - {ev_float, "frame1time"}, - {ev_float, "frame2"}, - {ev_float, "frame2time"}, - {ev_float, "frame3"}, - {ev_float, "frame3time"}, - {ev_float, "frame4"}, - {ev_float, "frame4time"}, - {ev_float, "gravity"}, - {ev_float, "idealpitch"}, - {ev_float, "lerpfrac"}, - {ev_float, "lerpfrac3"}, - {ev_float, "lerpfrac4"}, - {ev_float, "movetype"}, // used by ODE code - {ev_float, "nextthink"}, - {ev_float, "pitch_speed"}, - {ev_float, "renderflags"}, - {ev_float, "scale"}, - {ev_float, "shadertime"}, - {ev_float, "skeletonindex"}, - {ev_float, "solid"}, // used by ODE code - {ev_float, "tag_index"}, - {ev_float, "userwavefunc_param0"}, - {ev_float, "userwavefunc_param1"}, - {ev_float, "userwavefunc_param2"}, - {ev_float, "userwavefunc_param3"}, - {ev_function, "camera_transform"}, - {ev_function, "think"}, - {ev_string, "classname"}, - {ev_vector, "colormod"}, - {ev_vector, "glowmod"}, - - // physics - //{ev_float, "solid"}, - //{ev_float, "movetype"}, - //{ev_float, "modelindex"}, - {ev_vector, "mass"}, - //{ev_vector, "origin"}, - //{ev_vector, "velocity"}, - //{ev_vector, "axis_forward"}, - //{ev_vector, "axis_left"}, - //{ev_vector, "axis_up"}, - //{ev_vector, "spinvelocity"}, - //{ev_vector, "angles"}, - //{ev_vector, "avelocity"}, -}; - -#define CL_REQGLOBALS (sizeof(cl_reqglobals) / sizeof(prvm_required_field_t)) - -prvm_required_field_t cl_reqglobals[] = -{ - {ev_entity, "self"}, - {ev_entity, "trace_ent"}, - {ev_entity, "trace_networkentity"}, - {ev_float, "coop"}, - {ev_float, "deathmatch"}, - {ev_float, "dmg_save"}, - {ev_float, "dmg_take"}, - {ev_float, "drawfont"}, - {ev_float, "drawfontscale"}, - {ev_float, "gettaginfo_parent"}, - {ev_float, "intermission"}, - {ev_float, "particle_airfriction"}, - {ev_float, "particle_alpha"}, - {ev_float, "particle_alphafade"}, - {ev_float, "particle_angle"}, - {ev_float, "particle_blendmode"}, - {ev_float, "particle_bounce"}, - {ev_float, "particle_delaycollision"}, - {ev_float, "particle_delayspawn"}, - {ev_float, "particle_gravity"}, - {ev_float, "particle_liquidfriction"}, - {ev_float, "particle_orientation"}, - {ev_float, "particle_originjitter"}, - {ev_float, "particle_qualityreduction"}, - {ev_float, "particle_size"}, - {ev_float, "particle_sizeincrease"}, - {ev_float, "particle_spin"}, - {ev_float, "particle_stainalpha"}, - {ev_float, "particle_stainsize"}, - {ev_float, "particle_staintex"}, - {ev_float, "particle_staintex"}, - {ev_float, "particle_stretch"}, - {ev_float, "particle_tex"}, - {ev_float, "particle_time"}, - {ev_float, "particle_type"}, - {ev_float, "particle_velocityjitter"}, - {ev_float, "particles_alphamax"}, - {ev_float, "particles_alphamin"}, - {ev_float, "pmove_onground"}, - {ev_float, "pmove_inwater"}, - {ev_float, "require_spawnfunc_prefix"}, - {ev_float, "sb_showscores"}, - {ev_float, "serverdeltatime"}, - {ev_float, "serverprevtime"}, - {ev_float, "servertime"}, - {ev_float, "time"}, - {ev_float, "trace_allsolid"}, - {ev_float, "trace_dphitcontents"}, - {ev_float, "trace_dphitq3surfaceflags"}, - {ev_float, "trace_dpstartcontents"}, - {ev_float, "trace_fraction"}, - {ev_float, "trace_inopen"}, - {ev_float, "trace_inwater"}, - {ev_float, "trace_plane_dist"}, - {ev_float, "trace_startsolid"}, - {ev_float, "transparent_offset"}, - {ev_string, "SV_InitCmd"}, - {ev_string, "gettaginfo_name"}, - {ev_string, "trace_dphittexturename"}, - {ev_string, "worldstatus"}, - {ev_string, "message"}, - {ev_vector, "dmg_origin"}, - {ev_vector, "gettaginfo_forward"}, - {ev_vector, "gettaginfo_offset"}, - {ev_vector, "gettaginfo_right"}, - {ev_vector, "gettaginfo_up"}, - {ev_vector, "particle_color1"}, - {ev_vector, "particle_color2"}, - {ev_vector, "particle_staincolor1"}, - {ev_vector, "particle_staincolor2"}, - {ev_vector, "particles_colormax"}, - {ev_vector, "particles_colormin"}, - {ev_vector, "trace_endpos"}, - {ev_vector, "trace_plane_normal"}, - {ev_vector, "v_forward"}, - {ev_vector, "v_right"}, - {ev_vector, "v_up"}, - {ev_vector, "view_angles"}, - {ev_vector, "view_punchangle"}, - {ev_vector, "view_punchvector"}, -}; - void CL_VM_Init (void) { const char* csprogsfn; @@ -1070,7 +1067,7 @@ void CL_VM_Init (void) prog->globals.client->player_localentnum = cl.playerentity; // set map description (use world entity 0) - PRVM_EDICTFIELDSTRING(prog->edicts, prog->fieldoffsets.message) = PRVM_SetEngineString(cl.worldmessage); + PRVM_clientedictstring(prog->edicts, message) = PRVM_SetEngineString(cl.worldmessage); VectorCopy(cl.world.mins, prog->edicts->fields.client->mins); VectorCopy(cl.world.maxs, prog->edicts->fields.client->maxs); @@ -1145,7 +1142,7 @@ qboolean CL_VM_TransformView(int entnum, matrix4x4_t *viewmatrix, mplane_t *clip ed = PRVM_EDICT_NUM(entnum); // camera: // camera_transform - if(PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.camera_transform)) + if(PRVM_clientedictfunction(ed, camera_transform)) { ret = true; if(viewmatrix || clipplane || visorigin) @@ -1156,16 +1153,16 @@ qboolean CL_VM_TransformView(int entnum, matrix4x4_t *viewmatrix, mplane_t *clip prog->globals.client->self = entnum; VectorCopy(origin, PRVM_G_VECTOR(OFS_PARM0)); VectorCopy(ang, PRVM_G_VECTOR(OFS_PARM1)); - VectorCopy(forward, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_forward)); - VectorScale(left, -1, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_right)); - VectorCopy(up, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_up)); - VectorCopy(origin, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.trace_endpos)); - PRVM_ExecuteProgram(PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.camera_transform), "QC function e.camera_transform is missing"); + VectorCopy(forward, PRVM_clientglobalvector(v_forward)); + VectorScale(left, -1, PRVM_clientglobalvector(v_right)); + VectorCopy(up, PRVM_clientglobalvector(v_up)); + VectorCopy(origin, PRVM_clientglobalvector(trace_endpos)); + PRVM_ExecuteProgram(PRVM_clientedictfunction(ed, camera_transform), "QC function e.camera_transform is missing"); VectorCopy(PRVM_G_VECTOR(OFS_RETURN), origin); - VectorCopy(PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_forward), forward); - VectorScale(PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_right), -1, left); - VectorCopy(PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_up), up); - VectorCopy(PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.trace_endpos), visorigin); + VectorCopy(PRVM_clientglobalvector(v_forward), forward); + VectorScale(PRVM_clientglobalvector(v_right), -1, left); + VectorCopy(PRVM_clientglobalvector(v_up), up); + VectorCopy(PRVM_clientglobalvector(trace_endpos), visorigin); Matrix4x4_Invert_Full(&mat, viewmatrix); Matrix4x4_FromVectors(viewmatrix, forward, left, up, origin); Matrix4x4_Concat(&matq, viewmatrix, &mat); diff --git a/gl_rmain.c b/gl_rmain.c index eee8a48f..020fa1e8 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -7038,9 +7038,9 @@ static void R_DrawEntityBBoxes(void) if (edict->priv.server->free) continue; // exclude the following for now, as they don't live in world coordinate space and can't be solid: - if(PRVM_EDICTFIELDEDICT(edict, prog->fieldoffsets.tag_entity) != 0) + if(PRVM_serveredictedict(edict, tag_entity) != 0) continue; - if(PRVM_EDICTFIELDEDICT(edict, prog->fieldoffsets.viewmodelforclient) != 0) + if(PRVM_serveredictedict(edict, viewmodelforclient) != 0) continue; VectorLerp(edict->priv.server->areamins, 0.5f, edict->priv.server->areamaxs, center); R_MeshQueue_AddTransparent(center, R_DrawEntityBBoxes_Callback, (entity_render_t *)NULL, i, (rtlight_t *)NULL); diff --git a/host_cmd.c b/host_cmd.c index bf003e5f..9278b7aa 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -155,9 +155,10 @@ void Host_Status_f (void) frags = client->frags; - if(sv_status_show_qcstatus.integer && prog->fieldoffsets.clientstatus >= 0) + if(sv_status_show_qcstatus.integer) { - const char *str = PRVM_E_STRING(PRVM_EDICT_NUM(i + 1), prog->fieldoffsets.clientstatus); + prvm_edict_t *ed = PRVM_EDICT_NUM(i + 1); + const char *str = PRVM_GetString(PRVM_serveredictstring(ed, clientstatus)); if(str && *str) { char *p; @@ -1254,8 +1255,7 @@ void Host_Playermodel_f (void) // point the string back at updateclient->name to keep it safe strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel)); - if (prog->fieldoffsets.playermodel >= 0) - PRVM_EDICTFIELDSTRING(host_client->edict, prog->fieldoffsets.playermodel) = PRVM_SetEngineString(host_client->playermodel); + PRVM_serveredictstring(host_client->edict, playermodel) = PRVM_SetEngineString(host_client->playermodel); if (strcmp(host_client->old_model, host_client->playermodel)) { strlcpy(host_client->old_model, host_client->playermodel, sizeof(host_client->old_model)); @@ -1311,8 +1311,7 @@ void Host_Playerskin_f (void) // point the string back at updateclient->name to keep it safe strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin)); - if (prog->fieldoffsets.playerskin >= 0) - PRVM_EDICTFIELDSTRING(host_client->edict, prog->fieldoffsets.playerskin) = PRVM_SetEngineString(host_client->playerskin); + PRVM_serveredictstring(host_client->edict, playerskin) = PRVM_SetEngineString(host_client->playerskin); if (strcmp(host_client->old_skin, host_client->playerskin)) { //if (host_client->spawned) @@ -1585,7 +1584,7 @@ void Host_Color(int changetop, int changebottom) { if (host_client->edict) { - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.clientcolors) = playercolor; + PRVM_serveredictfloat(host_client->edict, clientcolors) = playercolor; host_client->edict->fields.server->team = bottom + 1; } host_client->colors = playercolor; @@ -1735,7 +1734,7 @@ static void Host_PModel_f (void) return; } - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.pmodel) = i; + PRVM_serveredictfloat(host_client->edict, pmodel) = i; } //=========================================================================== @@ -2073,14 +2072,14 @@ void Host_Give_f (void) case 's': if (gamemode == GAME_ROGUE) - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.ammo_shells1) = v; + PRVM_serveredictfloat(host_client->edict, ammo_shells1) = v; host_client->edict->fields.server->ammo_shells = v; break; case 'n': if (gamemode == GAME_ROGUE) { - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.ammo_nails1) = v; + PRVM_serveredictfloat(host_client->edict, ammo_nails1) = v; if (host_client->edict->fields.server->weapon <= IT_LIGHTNING) host_client->edict->fields.server->ammo_nails = v; } @@ -2092,7 +2091,7 @@ void Host_Give_f (void) case 'l': if (gamemode == GAME_ROGUE) { - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.ammo_lava_nails) = v; + PRVM_serveredictfloat(host_client->edict, ammo_lava_nails) = v; if (host_client->edict->fields.server->weapon > IT_LIGHTNING) host_client->edict->fields.server->ammo_nails = v; } @@ -2100,7 +2099,7 @@ void Host_Give_f (void) case 'r': if (gamemode == GAME_ROGUE) { - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.ammo_rockets1) = v; + PRVM_serveredictfloat(host_client->edict, ammo_rockets1) = v; if (host_client->edict->fields.server->weapon <= IT_LIGHTNING) host_client->edict->fields.server->ammo_rockets = v; } @@ -2112,7 +2111,7 @@ void Host_Give_f (void) case 'm': if (gamemode == GAME_ROGUE) { - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.ammo_multi_rockets) = v; + PRVM_serveredictfloat(host_client->edict, ammo_multi_rockets) = v; if (host_client->edict->fields.server->weapon > IT_LIGHTNING) host_client->edict->fields.server->ammo_rockets = v; } @@ -2123,7 +2122,7 @@ void Host_Give_f (void) case 'c': if (gamemode == GAME_ROGUE) { - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.ammo_cells1) = v; + PRVM_serveredictfloat(host_client->edict, ammo_cells1) = v; if (host_client->edict->fields.server->weapon <= IT_LIGHTNING) host_client->edict->fields.server->ammo_cells = v; } @@ -2135,7 +2134,7 @@ void Host_Give_f (void) case 'p': if (gamemode == GAME_ROGUE) { - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.ammo_plasma) = v; + PRVM_serveredictfloat(host_client->edict, ammo_plasma) = v; if (host_client->edict->fields.server->weapon > IT_LIGHTNING) host_client->edict->fields.server->ammo_cells = v; } diff --git a/menu.c b/menu.c index bb82b8d4..5d726dfc 100644 --- a/menu.c +++ b/menu.c @@ -5015,6 +5015,23 @@ static const char *m_required_func[] = { static int m_numrequiredfunc = sizeof(m_required_func) / sizeof(char*); +static prvm_required_field_t m_required_fields[] = +{ + {ev_string, "classname"}, // menu field +}; + +static int m_numrequiredfields = sizeof(m_required_fields) / sizeof(m_required_fields[0]); + +static prvm_required_field_t m_required_globals[] = +{ + {ev_entity, "self"}, // menu global + {ev_float, "drawfont"}, // menu global + {ev_float, "require_spawnfunc_prefix"}, // menu global + {ev_vector, "drawfontscale"}, // menu global +}; + +static int m_numrequiredglobals = sizeof(m_required_globals) / sizeof(m_required_globals[0]); + void MR_SetRouting (qboolean forceold); void MP_Error(const char *format, ...) DP_FUNC_PRINTF(1); @@ -5158,7 +5175,7 @@ void MP_Init (void) // allocate the mempools prog->progs_mempool = Mem_AllocPool(M_PROG_FILENAME, 0, NULL); - PRVM_LoadProgs(M_PROG_FILENAME, m_numrequiredfunc, m_required_func, 0, NULL, 0, NULL); + PRVM_LoadProgs(M_PROG_FILENAME, m_numrequiredfunc, m_required_func, m_numrequiredfields, m_required_fields, m_numrequiredglobals, m_required_globals); // note: OP_STATE is not supported by menu qc, we don't even try to detect // it here diff --git a/netconn.c b/netconn.c index e2095d91..65b64830 100755 --- a/netconn.c +++ b/netconn.c @@ -2287,6 +2287,7 @@ static qboolean NetConn_BuildStatusResponse(const char* challenge, char* out_msg int length; char teambuf[3]; const char *crypto_idstring; + const char *str; SV_VM_Begin(); @@ -2302,19 +2303,16 @@ static qboolean NetConn_BuildStatusResponse(const char* challenge, char* out_msg } *qcstatus = 0; - if(prog->globaloffsets.worldstatus >= 0) + str = PRVM_GetString(PRVM_serverglobalstring(worldstatus)); + if(str && *str) { - const char *str = PRVM_G_STRING(prog->globaloffsets.worldstatus); - if(str && *str) - { - char *p; - const char *q; - p = qcstatus; - for(q = str; *q && p - qcstatus < (ptrdiff_t)(sizeof(qcstatus)) - 1; ++q) - if(*q != '\\' && *q != '\n') - *p++ = *q; - *p = 0; - } + char *p; + const char *q; + p = qcstatus; + for(q = str; *q && p - qcstatus < (ptrdiff_t)(sizeof(qcstatus)) - 1; ++q) + if(*q != '\\' && *q != '\n') + *p++ = *q; + *p = 0; } /// \TODO: we should add more information for the full status string @@ -2358,6 +2356,8 @@ static qboolean NetConn_BuildStatusResponse(const char* challenge, char* out_msg int nameind, cleanind, pingvalue; char curchar; char cleanname [sizeof(cl->name)]; + const char *str; + prvm_edict_t *ed; // Remove all characters '"' and '\' in the player name nameind = 0; @@ -2381,19 +2381,17 @@ static qboolean NetConn_BuildStatusResponse(const char* challenge, char* out_msg pingvalue = 0; *qcstatus = 0; - if(prog->fieldoffsets.clientstatus >= 0) + ed = PRVM_EDICT_NUM(i + 1); + str = PRVM_GetString(PRVM_serveredictstring(ed, clientstatus)); + if(str && *str) { - const char *str = PRVM_E_STRING(PRVM_EDICT_NUM(i + 1), prog->fieldoffsets.clientstatus); - if(str && *str) - { - char *p; - const char *q; - p = qcstatus; - for(q = str; *q && p != qcstatus + sizeof(qcstatus) - 1; ++q) - if(*q != '\\' && *q != '"' && !ISWHITESPACE(*q)) - *p++ = *q; - *p = 0; - } + char *p; + const char *q; + p = qcstatus; + for(q = str; *q && p != qcstatus + sizeof(qcstatus) - 1; ++q) + if(*q != '\\' && *q != '"' && !ISWHITESPACE(*q)) + *p++ = *q; + *p = 0; } if ((gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) && (teamplay.integer > 0)) diff --git a/progsvm.h b/progsvm.h index 0f81f292..de85a66d 100644 --- a/progsvm.h +++ b/progsvm.h @@ -117,6 +117,62 @@ typedef struct prvm_edict_s extern prvm_eval_t prvm_badvalue; +#define PRVM_alledictfloat(ed, fieldname) (PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.fieldname)) +#define PRVM_alledictvector(ed, fieldname) (PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.fieldname)) +#define PRVM_alledictstring(ed, fieldname) (PRVM_EDICTFIELDSTRING(ed, prog->fieldoffsets.fieldname)) +#define PRVM_alledictedict(ed, fieldname) (PRVM_EDICTFIELDEDICT(ed, prog->fieldoffsets.fieldname)) +#define PRVM_alledictfunction(ed, fieldname) (PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.fieldname)) +#define PRVM_allglobalfloat(fieldname) (PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.fieldname)) +#define PRVM_allglobalvector(fieldname) (PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.fieldname)) +#define PRVM_allglobalstring(fieldname) (PRVM_GLOBALFIELDSTRING(prog->globaloffsets.fieldname)) +#define PRVM_allglobaledict(fieldname) (PRVM_GLOBALFIELDEDICT(prog->globaloffsets.fieldname)) +#define PRVM_allglobalfunction(fieldname) (PRVM_GLOBALFIELDFUNCTION(prog->globaloffsets.fieldname)) + +#define PRVM_drawedictfloat(ed, fieldname) (PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.fieldname)) +#define PRVM_drawedictvector(ed, fieldname) (PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.fieldname)) +#define PRVM_drawedictstring(ed, fieldname) (PRVM_EDICTFIELDSTRING(ed, prog->fieldoffsets.fieldname)) +#define PRVM_drawedictedict(ed, fieldname) (PRVM_EDICTFIELDEDICT(ed, prog->fieldoffsets.fieldname)) +#define PRVM_drawedictfunction(ed, fieldname) (PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.fieldname)) +#define PRVM_drawglobalfloat(fieldname) (PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.fieldname)) +#define PRVM_drawglobalvector(fieldname) (PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.fieldname)) +#define PRVM_drawglobalstring(fieldname) (PRVM_GLOBALFIELDSTRING(prog->globaloffsets.fieldname)) +#define PRVM_drawglobaledict(fieldname) (PRVM_GLOBALFIELDEDICT(prog->globaloffsets.fieldname)) +#define PRVM_drawglobalfunction(fieldname) (PRVM_GLOBALFIELDFUNCTION(prog->globaloffsets.fieldname)) + +#define PRVM_gameedictfloat(ed, fieldname) (PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.fieldname)) +#define PRVM_gameedictvector(ed, fieldname) (PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.fieldname)) +#define PRVM_gameedictstring(ed, fieldname) (PRVM_EDICTFIELDSTRING(ed, prog->fieldoffsets.fieldname)) +#define PRVM_gameedictedict(ed, fieldname) (PRVM_EDICTFIELDEDICT(ed, prog->fieldoffsets.fieldname)) +#define PRVM_gameedictfunction(ed, fieldname) (PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.fieldname)) +#define PRVM_gameglobalfloat(fieldname) (PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.fieldname)) +#define PRVM_gameglobalvector(fieldname) (PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.fieldname)) +#define PRVM_gameglobalstring(fieldname) (PRVM_GLOBALFIELDSTRING(prog->globaloffsets.fieldname)) +#define PRVM_gameglobaledict(fieldname) (PRVM_GLOBALFIELDEDICT(prog->globaloffsets.fieldname)) +#define PRVM_gameglobalfunction(fieldname) (PRVM_GLOBALFIELDFUNCTION(prog->globaloffsets.fieldname)) + +#define PRVM_serveredictfloat(ed, fieldname) (PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.fieldname)) +#define PRVM_serveredictvector(ed, fieldname) (PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.fieldname)) +#define PRVM_serveredictstring(ed, fieldname) (PRVM_EDICTFIELDSTRING(ed, prog->fieldoffsets.fieldname)) +#define PRVM_serveredictedict(ed, fieldname) (PRVM_EDICTFIELDEDICT(ed, prog->fieldoffsets.fieldname)) +#define PRVM_serveredictfunction(ed, fieldname) (PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.fieldname)) +#define PRVM_serverglobalfloat(fieldname) (PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.fieldname)) +#define PRVM_serverglobalvector(fieldname) (PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.fieldname)) +#define PRVM_serverglobalstring(fieldname) (PRVM_GLOBALFIELDSTRING(prog->globaloffsets.fieldname)) +#define PRVM_serverglobaledict(fieldname) (PRVM_GLOBALFIELDEDICT(prog->globaloffsets.fieldname)) +#define PRVM_serverglobalfunction(fieldname) (PRVM_GLOBALFIELDFUNCTION(prog->globaloffsets.fieldname)) + +#define PRVM_clientedictfloat(ed, fieldname) (PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.fieldname)) +#define PRVM_clientedictvector(ed, fieldname) (PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.fieldname)) +#define PRVM_clientedictstring(ed, fieldname) (PRVM_EDICTFIELDSTRING(ed, prog->fieldoffsets.fieldname)) +#define PRVM_clientedictedict(ed, fieldname) (PRVM_EDICTFIELDEDICT(ed, prog->fieldoffsets.fieldname)) +#define PRVM_clientedictfunction(ed, fieldname) (PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.fieldname)) +#define PRVM_clientglobalfloat(fieldname) (PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.fieldname)) +#define PRVM_clientglobalvector(fieldname) (PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.fieldname)) +#define PRVM_clientglobalstring(fieldname) (PRVM_GLOBALFIELDSTRING(prog->globaloffsets.fieldname)) +#define PRVM_clientglobaledict(fieldname) (PRVM_GLOBALFIELDEDICT(prog->globaloffsets.fieldname)) +#define PRVM_clientglobalfunction(fieldname) (PRVM_GLOBALFIELDFUNCTION(prog->globaloffsets.fieldname)) + + #if 1 #define PRVM_EDICTFIELDVALUE(ed, fieldoffset) (fieldoffset < 0 ? Con_Printf("Invalid fieldoffset at %s:%i\n", __FILE__, __LINE__), &prvm_badvalue : (prvm_eval_t *)((int *)ed->fields.vp + fieldoffset)) #define PRVM_EDICTFIELDFLOAT(ed, fieldoffset) (PRVM_EDICTFIELDVALUE(ed, fieldoffset)->_float) @@ -366,6 +422,35 @@ typedef struct prvm_prog_globaloffsets_s int particles_alphamax; // csqc int particles_colormin; // csqc int particles_colormax; // csqc + + int particle_type; // csqc + int particle_blendmode; // csqc + int particle_orientation; // csqc + int particle_color1; // csqc + int particle_color2; // csqc + int particle_tex; // csqc + int particle_size; // csqc + int particle_sizeincrease; // csqc + int particle_alpha; // csqc + int particle_alphafade; // csqc + int particle_time; // csqc + int particle_gravity; // csqc + int particle_bounce; // csqc + int particle_airfriction; // csqc + int particle_liquidfriction; // csqc + int particle_originjitter; // csqc + int particle_velocityjitter; // csqc + int particle_qualityreduction; // csqc + int particle_stretch; // csqc + int particle_staincolor1; // csqc + int particle_staincolor2; // csqc + int particle_stainalpha; // csqc + int particle_stainsize; // csqc + int particle_staintex; // csqc + int particle_delayspawn; // csqc + int particle_delaycollision; // csqc + int particle_angle; // csqc + int particle_spin; // csqc } prvm_prog_globaloffsets_t; diff --git a/protocol.c b/protocol.c index 3a5d5400..3ae47c56 100644 --- a/protocol.c +++ b/protocol.c @@ -7,14 +7,7 @@ if(developer_networkentities.integer >= 2) \ { \ prvm_edict_t *ed = prog->edicts + num; \ - const char *cname = "(no classname)"; \ - if(prog->fieldoffsets.classname >= 0) \ - { \ - string_t handle = PRVM_EDICTFIELDSTRING(ed, prog->fieldoffsets.classname); \ - if (handle) \ - cname = PRVM_GetString(handle); \ - } \ - Con_Printf("sent entity update of size %d for a %s\n", (msg->cursize - entityprofiling_startsize), cname); \ + Con_Printf("sent entity update of size %d for a %s\n", (msg->cursize - entityprofiling_startsize), PRVM_serveredictstring(ed, classname) ? PRVM_GetString(PRVM_serveredictstring(ed, classname)) : "(no classname)"); \ } // this is 88 bytes (must match entity_state_t in protocol.h) @@ -281,16 +274,13 @@ static void EntityFrameCSQC_LostAllFrames(client_t *client) int i, n; prvm_edict_t *ed; - if(prog->fieldoffsets.SendEntity < 0 || prog->fieldoffsets.Version < 0) - return; - n = client->csqcnumedicts; for(i = 0; i < n; ++i) { if(client->csqcentityglobalhistory[i]) { ed = prog->edicts + i; - if (PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.SendEntity)) + if (PRVM_serveredictfunction(ed, SendEntity)) client->csqcentitysendflags[i] |= 0xFFFFFF; // FULL RESEND else // if it was ever sent to that client as a CSQC entity { @@ -454,10 +444,6 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers maxsize -= 24; // always fit in an empty svc_entities message (for packet loss detection!) - // if this server progs is not CSQC-aware, return early - if(prog->fieldoffsets.SendEntity < 0 || prog->fieldoffsets.Version < 0) - return false; - // make sure there is enough room to store the svc_csqcentities byte, // the terminator (0x0000) and at least one entity update if (msg->cursize + 32 >= maxsize) @@ -479,7 +465,7 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers } } ed = prog->edicts + number; - if (PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.SendEntity)) + if (PRVM_serveredictfunction(ed, SendEntity)) client->csqcentityscope[number] = 2; else if (client->csqcentityscope[number]) { @@ -508,7 +494,7 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers { number = *n; ed = prog->edicts + number; - if (PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.SendEntity)) + if (PRVM_serveredictfunction(ed, SendEntity)) client->csqcentityscope[number] = 2; } */ @@ -557,7 +543,7 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers // save the cursize value in case we overflow and have to rollback int oldcursize = msg->cursize; client->csqcentityscope[number] = 1; - if (PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.SendEntity)) + if (PRVM_serveredictfunction(ed, SendEntity)) { if(!sectionstarted) MSG_WriteByte(msg, svc_csqcentities); @@ -568,7 +554,7 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers PRVM_G_INT(OFS_PARM0) = sv.writeentitiestoclient_cliententitynumber; PRVM_G_FLOAT(OFS_PARM1) = sendflags; prog->globals.server->self = number; - PRVM_ExecuteProgram(PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.SendEntity), "Null SendEntity\n"); + PRVM_ExecuteProgram(PRVM_serveredictfunction(ed, SendEntity), "Null SendEntity\n"); msg->allowoverflow = false; if(PRVM_G_FLOAT(OFS_RETURN) && msg->cursize + 2 <= maxsize) { @@ -706,7 +692,7 @@ qboolean EntityFrameQuake_WriteFrame(sizebuf_t *msg, int maxsize, int numstates, { ENTITYSIZEPROFILING_START(msg, states[i]->number); s = states[i]; - if(PRVM_EDICTFIELDFUNCTION((&prog->edicts[s->number]), prog->fieldoffsets.SendEntity)) + if(PRVM_serveredictfunction((&prog->edicts[s->number]), SendEntity)) continue; // prepare the buffer @@ -1432,7 +1418,7 @@ qboolean EntityFrame_WriteFrame(sizebuf_t *msg, int maxsize, entityframe_databas ent = states[i]; number = ent->number; - if (PRVM_EDICTFIELDFUNCTION((&prog->edicts[number]), prog->fieldoffsets.SendEntity)) + if (PRVM_serveredictfunction((&prog->edicts[number]), SendEntity)) continue; for (;onum < o->numentities && o->entitydata[onum].number < number;onum++) { @@ -1921,7 +1907,7 @@ qboolean EntityFrame4_WriteFrame(sizebuf_t *msg, int maxsize, entityframe4_datab d->currententitynumber = 1; for (i = 0, n = startnumber;n < prog->max_edicts;n++) { - if (PRVM_EDICTFIELDFUNCTION((&prog->edicts[n]), prog->fieldoffsets.SendEntity)) + if (PRVM_serveredictfunction((&prog->edicts[n]), SendEntity)) continue; // find the old state to delta from e = EntityFrame4_GetReferenceEntity(d, n); @@ -2077,7 +2063,7 @@ void EntityState5_WriteUpdate(int number, const entity_state_t *s, int changedbi //dp_model_t *model; ENTITYSIZEPROFILING_START(msg, s->number); - if (PRVM_EDICTFIELDFUNCTION((&prog->edicts[s->number]), prog->fieldoffsets.SendEntity)) + if (PRVM_serveredictfunction((&prog->edicts[s->number]), SendEntity)) return; if (s->active != ACTIVE_NETWORK) diff --git a/prvm_cmds.c b/prvm_cmds.c index 5222146d..5acc3eb2 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -64,17 +64,17 @@ void VM_GenerateFrameGroupBlend(framegroupblend_t *framegroupblend, const prvm_e // self.lerpfrac4 is the interpolation strength for self.frame4 // pitch angle on a player model where the animator set up 5 sets of // animations and the csqc simply lerps between sets) - framegroupblend[0].frame = (int) PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.frame ); - framegroupblend[1].frame = (int) PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.frame2 ); - framegroupblend[2].frame = (int) PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.frame3 ); - framegroupblend[3].frame = (int) PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.frame4 ); - framegroupblend[0].start = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.frame1time); - framegroupblend[1].start = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.frame2time); - framegroupblend[2].start = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.frame3time); - framegroupblend[3].start = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.frame4time); - framegroupblend[1].lerp = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.lerpfrac ); - framegroupblend[2].lerp = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.lerpfrac3 ); - framegroupblend[3].lerp = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.lerpfrac4 ); + framegroupblend[0].frame = (int) PRVM_gameedictfloat(ed, frame ); + framegroupblend[1].frame = (int) PRVM_gameedictfloat(ed, frame2 ); + framegroupblend[2].frame = (int) PRVM_gameedictfloat(ed, frame3 ); + framegroupblend[3].frame = (int) PRVM_gameedictfloat(ed, frame4 ); + framegroupblend[0].start = PRVM_gameedictfloat(ed, frame1time); + framegroupblend[1].start = PRVM_gameedictfloat(ed, frame2time); + framegroupblend[2].start = PRVM_gameedictfloat(ed, frame3time); + framegroupblend[3].start = PRVM_gameedictfloat(ed, frame4time); + framegroupblend[1].lerp = PRVM_gameedictfloat(ed, lerpfrac ); + framegroupblend[2].lerp = PRVM_gameedictfloat(ed, lerpfrac3 ); + framegroupblend[3].lerp = PRVM_gameedictfloat(ed, lerpfrac4 ); // assume that the (missing) lerpfrac1 is whatever remains after lerpfrac2+lerpfrac3+lerpfrac4 are summed framegroupblend[0].lerp = 1 - framegroupblend[1].lerp - framegroupblend[2].lerp - framegroupblend[3].lerp; } @@ -197,7 +197,7 @@ void VM_UpdateEdictSkeleton(prvm_edict_t *ed, const dp_model_t *edmodel, const f { int skeletonindex = -1; skeleton_t *skeleton; - skeletonindex = (int)PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.skeletonindex) - 1; + skeletonindex = (int)PRVM_gameedictfloat(ed, skeletonindex) - 1; if (skeletonindex >= 0 && skeletonindex < MAX_EDICTS && (skeleton = prog->skeletons[skeletonindex]) && skeleton->model->num_bones == ed->priv.server->skeleton.model->num_bones) { // custom skeleton controlled by the game (FTE_CSQC_SKELETONOBJECTS) @@ -310,11 +310,8 @@ void VM_error (void) VM_VarString(0, string, sizeof(string)); Con_Printf("======%s ERROR in %s:\n%s\n", PRVM_NAME, PRVM_GetString(prog->xfunction->s_name), string); - if (prog->globaloffsets.self >= 0) - { - ed = PRVM_PROG_TO_EDICT(PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self)); - PRVM_ED_Print(ed, NULL); - } + ed = PRVM_PROG_TO_EDICT(PRVM_allglobaledict(self)); + PRVM_ED_Print(ed, NULL); PRVM_ERROR ("%s: Program error in function %s:\n%s\nTip: read above for entity information\n", PRVM_NAME, PRVM_GetString(prog->xfunction->s_name), string); } @@ -336,16 +333,9 @@ void VM_objerror (void) VM_VarString(0, string, sizeof(string)); Con_Printf("======OBJECT ERROR======\n"); // , PRVM_NAME, PRVM_GetString(prog->xfunction->s_name), string); // or include them? FIXME - if (prog->globaloffsets.self >= 0) - { - ed = PRVM_PROG_TO_EDICT(PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self)); - PRVM_ED_Print(ed, NULL); - - PRVM_ED_Free (ed); - } - else - // objerror has to display the object fields -> else call - PRVM_ERROR ("VM_objecterror: self not defined !"); + ed = PRVM_PROG_TO_EDICT(PRVM_allglobaledict(self)); + PRVM_ED_Print(ed, NULL); + PRVM_ED_Free (ed); Con_Printf("%s OBJECT ERROR in %s:\n%s\nTip: read above for entity information\n", PRVM_NAME, PRVM_GetString(prog->xfunction->s_name), string); } @@ -3294,28 +3284,20 @@ void getdrawfontscale(float *sx, float *sy) { vec3_t v; *sx = *sy = 1; - if(prog->globaloffsets.drawfontscale >= 0) + VectorCopy(PRVM_drawglobalvector(drawfontscale), v); + if(VectorLength2(v) > 0) { - VectorCopy(PRVM_G_VECTOR(prog->globaloffsets.drawfontscale), v); - if(VectorLength2(v) > 0) - { - *sx = v[0]; - *sy = v[1]; - } + *sx = v[0]; + *sy = v[1]; } } dp_font_t *getdrawfont(void) { - if(prog->globaloffsets.drawfont >= 0) - { - int f = (int) PRVM_G_FLOAT(prog->globaloffsets.drawfont); - if(f < 0 || f >= dp_fonts.maxsize) - return FONT_DEFAULT; - return &dp_fonts.f[f]; - } - else + int f = (int) PRVM_drawglobalfloat(drawfont); + if(f < 0 || f >= dp_fonts.maxsize) return FONT_DEFAULT; + return &dp_fonts.f[f]; } /* @@ -4448,7 +4430,7 @@ void makevectors(vector angle) void VM_makevectors (void) { VM_SAFEPARMCOUNT(1, VM_makevectors); - AngleVectors(PRVM_G_VECTOR(OFS_PARM0), PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_forward), PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_right), PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_up)); + AngleVectors(PRVM_G_VECTOR(OFS_PARM0), PRVM_gameglobalvector(v_forward), PRVM_gameglobalvector(v_right), PRVM_gameglobalvector(v_up)); } /* @@ -4462,8 +4444,8 @@ vectorvectors(vector) void VM_vectorvectors (void) { VM_SAFEPARMCOUNT(1, VM_vectorvectors); - VectorNormalize2(PRVM_G_VECTOR(OFS_PARM0), PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_forward)); - VectorVectors(PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_forward), PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_right), PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.v_up)); + VectorNormalize2(PRVM_G_VECTOR(OFS_PARM0), PRVM_gameglobalvector(v_forward)); + VectorVectors(PRVM_gameglobalvector(v_forward), PRVM_gameglobalvector(v_right), PRVM_gameglobalvector(v_up)); } /* @@ -5243,7 +5225,7 @@ void VM_changeyaw (void) // parameters because they are the parameters to SV_MoveToGoal, not this //VM_SAFEPARMCOUNT(0, VM_changeyaw); - ent = PRVM_PROG_TO_EDICT(PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self)); + ent = PRVM_PROG_TO_EDICT(PRVM_gameglobaledict(self)); if (ent == prog->edicts) { VM_Warning("changeyaw: can not modify world entity\n"); @@ -5254,15 +5236,10 @@ void VM_changeyaw (void) VM_Warning("changeyaw: can not modify free entity\n"); return; } - if (prog->fieldoffsets.angles < 0 || prog->fieldoffsets.ideal_yaw < 0 || prog->fieldoffsets.yaw_speed < 0) - { - VM_Warning("changeyaw: angles, ideal_yaw, or yaw_speed field(s) not found\n"); - return; - } - current = PRVM_EDICTFIELDVECTOR(ent, prog->fieldoffsets.angles)[1]; + current = PRVM_gameedictvector(ent, angles)[1]; current = ANGLEMOD(current); - ideal = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.ideal_yaw); - speed = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.yaw_speed); + ideal = PRVM_gameedictfloat(ent, ideal_yaw); + speed = PRVM_gameedictfloat(ent, yaw_speed); if (current == ideal) return; @@ -5289,7 +5266,7 @@ void VM_changeyaw (void) } current += move; - PRVM_EDICTFIELDVECTOR(ent, prog->fieldoffsets.angles)[1] = ANGLEMOD(current); + PRVM_gameedictvector(ent, angles)[1] = ANGLEMOD(current); } /* @@ -5315,15 +5292,10 @@ void VM_changepitch (void) VM_Warning("changepitch: can not modify free entity\n"); return; } - if (prog->fieldoffsets.angles < 0 || prog->fieldoffsets.idealpitch < 0 || prog->fieldoffsets.pitch_speed < 0) - { - VM_Warning("changepitch: angles, idealpitch, or pitch_speed field(s) not found\n"); - return; - } - current = PRVM_EDICTFIELDVECTOR(ent, prog->fieldoffsets.angles)[0]; + current = PRVM_gameedictvector(ent, angles)[0]; current = ANGLEMOD(current); - ideal = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.idealpitch); - speed = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.pitch_speed); + ideal = PRVM_gameedictfloat(ent, idealpitch); + speed = PRVM_gameedictfloat(ent, pitch_speed); if (current == ideal) return; @@ -5350,7 +5322,7 @@ void VM_changepitch (void) } current += move; - PRVM_EDICTFIELDVECTOR(ent, prog->fieldoffsets.angles)[0] = ANGLEMOD(current); + PRVM_gameedictvector(ent, angles)[0] = ANGLEMOD(current); } @@ -5673,37 +5645,37 @@ void VM_wasfreed (void) void VM_SetTraceGlobals(const trace_t *trace) { - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_allsolid) = trace->allsolid; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_startsolid) = trace->startsolid; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_fraction) = trace->fraction; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_inwater) = trace->inwater; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_inopen) = trace->inopen; - VectorCopy(trace->endpos, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.trace_endpos)); - VectorCopy(trace->plane.normal, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.trace_plane_normal)); - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_plane_dist) = trace->plane.dist; - PRVM_GLOBALFIELDEDICT(prog->globaloffsets.trace_ent) = PRVM_EDICT_TO_PROG(trace->ent ? trace->ent : prog->edicts); - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dpstartcontents) = trace->startsupercontents; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dphitcontents) = trace->hitsupercontents; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dphitq3surfaceflags) = trace->hitq3surfaceflags; - PRVM_GLOBALFIELDSTRING(prog->globaloffsets.trace_dphittexturename) = trace->hittexture ? PRVM_SetTempString(trace->hittexture->name) : 0; + PRVM_gameglobalfloat(trace_allsolid) = trace->allsolid; + PRVM_gameglobalfloat(trace_startsolid) = trace->startsolid; + PRVM_gameglobalfloat(trace_fraction) = trace->fraction; + PRVM_gameglobalfloat(trace_inwater) = trace->inwater; + PRVM_gameglobalfloat(trace_inopen) = trace->inopen; + VectorCopy(trace->endpos, PRVM_gameglobalvector(trace_endpos)); + VectorCopy(trace->plane.normal, PRVM_gameglobalvector(trace_plane_normal)); + PRVM_gameglobalfloat(trace_plane_dist) = trace->plane.dist; + PRVM_gameglobaledict(trace_ent) = PRVM_EDICT_TO_PROG(trace->ent ? trace->ent : prog->edicts); + PRVM_gameglobalfloat(trace_dpstartcontents) = trace->startsupercontents; + PRVM_gameglobalfloat(trace_dphitcontents) = trace->hitsupercontents; + PRVM_gameglobalfloat(trace_dphitq3surfaceflags) = trace->hitq3surfaceflags; + PRVM_gameglobalstring(trace_dphittexturename) = trace->hittexture ? PRVM_SetTempString(trace->hittexture->name) : 0; } void VM_ClearTraceGlobals(void) { // clean up all trace globals when leaving the VM (anti-triggerbot safeguard) - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_allsolid) = 0; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_startsolid) = 0; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_fraction) = 0; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_inwater) = 0; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_inopen) = 0; - VectorClear(PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.trace_endpos)); - VectorClear(PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.trace_plane_normal)); - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_plane_dist) = 0; - PRVM_GLOBALFIELDEDICT(prog->globaloffsets.trace_ent) = PRVM_EDICT_TO_PROG(prog->edicts); - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dpstartcontents) = 0; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dphitcontents) = 0; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dphitq3surfaceflags) = 0; - PRVM_GLOBALFIELDSTRING(prog->globaloffsets.trace_dphittexturename) = 0; + PRVM_gameglobalfloat(trace_allsolid) = 0; + PRVM_gameglobalfloat(trace_startsolid) = 0; + PRVM_gameglobalfloat(trace_fraction) = 0; + PRVM_gameglobalfloat(trace_inwater) = 0; + PRVM_gameglobalfloat(trace_inopen) = 0; + VectorClear(PRVM_gameglobalvector(trace_endpos)); + VectorClear(PRVM_gameglobalvector(trace_plane_normal)); + PRVM_gameglobalfloat(trace_plane_dist) = 0; + PRVM_gameglobaledict(trace_ent) = PRVM_EDICT_TO_PROG(prog->edicts); + PRVM_gameglobalfloat(trace_dpstartcontents) = 0; + PRVM_gameglobalfloat(trace_dphitcontents) = 0; + PRVM_gameglobalfloat(trace_dphitq3surfaceflags) = 0; + PRVM_gameglobalstring(trace_dphittexturename) = 0; } //============= @@ -6546,7 +6518,7 @@ void animatemodel(dp_model_t *model, prvm_edict_t *ed) VM_GenerateFrameGroupBlend(ed->priv.server->framegroupblend, ed); VM_FrameBlendFromFrameGroupBlend(ed->priv.server->frameblend, ed->priv.server->framegroupblend, model); need |= (memcmp(&animatemodel_cache.frameblend, &ed->priv.server->frameblend, sizeof(ed->priv.server->frameblend))) != 0; - skeletonindex = (int)PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.skeletonindex) - 1; + skeletonindex = (int)PRVM_gameedictfloat(ed, skeletonindex) - 1; if (!(skeletonindex >= 0 && skeletonindex < MAX_EDICTS && (skeleton = prog->skeletons[skeletonindex]) && skeleton->model->num_bones == ed->priv.server->skeleton.model->num_bones)) skeleton = NULL; need |= (animatemodel_cache.skeleton_p != skeleton); diff --git a/prvm_edict.c b/prvm_edict.c index 7aa2dae0..85f8badf 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -1448,7 +1448,7 @@ void PRVM_ED_LoadFromFile (const char *data) if (prog->funcoffsets.SV_OnEntityPreSpawnFunction) { // self = ent - PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self) = PRVM_EDICT_TO_PROG(ent); + PRVM_allglobaledict(self) = PRVM_EDICT_TO_PROG(ent); PRVM_ExecuteProgram (prog->funcoffsets.SV_OnEntityPreSpawnFunction, "QC function SV_OnEntityPreSpawnFunction is missing"); } @@ -1462,10 +1462,8 @@ void PRVM_ED_LoadFromFile (const char *data) // immediately call spawn function, but only if there is a self global and a classname // if(!ent->priv.required->free) - if(prog->globaloffsets.self >= 0 && prog->fieldoffsets.classname >= 0) { - string_t handle = PRVM_EDICTFIELDSTRING(ent, prog->fieldoffsets.classname); - if (!handle) + if (!PRVM_alledictstring(ent, classname)) { Con_Print("No classname for:\n"); PRVM_ED_Print(ent, NULL); @@ -1474,10 +1472,10 @@ void PRVM_ED_LoadFromFile (const char *data) } // look for the spawn function - funcname = PRVM_GetString(handle); + funcname = PRVM_GetString(PRVM_alledictstring(ent, classname)); func = PRVM_ED_FindFunction (va("spawnfunc_%s", funcname)); if(!func) - if(!PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.require_spawnfunc_prefix)) + if(!PRVM_allglobalfloat(require_spawnfunc_prefix)) func = PRVM_ED_FindFunction (funcname); if (!func) @@ -1486,7 +1484,7 @@ void PRVM_ED_LoadFromFile (const char *data) if (prog->funcoffsets.SV_OnEntityNoSpawnFunction) { // self = ent - PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self) = PRVM_EDICT_TO_PROG(ent); + PRVM_allglobaledict(self) = PRVM_EDICT_TO_PROG(ent); PRVM_ExecuteProgram (prog->funcoffsets.SV_OnEntityNoSpawnFunction, "QC function SV_OnEntityNoSpawnFunction is missing"); } else @@ -1503,7 +1501,7 @@ void PRVM_ED_LoadFromFile (const char *data) else { // self = ent - PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self) = PRVM_EDICT_TO_PROG(ent); + PRVM_allglobaledict(self) = PRVM_EDICT_TO_PROG(ent); PRVM_ExecuteProgram (func - prog->functions, ""); } } @@ -1512,7 +1510,7 @@ void PRVM_ED_LoadFromFile (const char *data) if (prog->funcoffsets.SV_OnEntityPostSpawnFunction) { // self = ent - PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self) = PRVM_EDICT_TO_PROG(ent); + PRVM_allglobaledict(self) = PRVM_EDICT_TO_PROG(ent); PRVM_ExecuteProgram (prog->funcoffsets.SV_OnEntityPostSpawnFunction, "QC function SV_OnEntityPostSpawnFunction is missing"); } @@ -1751,6 +1749,36 @@ void PRVM_FindOffsets(void) prog->globaloffsets.pmove_onground = PRVM_ED_FindGlobalOffset("pmove_onground"); prog->globaloffsets.pmove_inwater = PRVM_ED_FindGlobalOffset("pmove_inwater"); + prog->globaloffsets.particle_type = PRVM_ED_FindGlobalOffset("particle_type"); + prog->globaloffsets.particle_blendmode = PRVM_ED_FindGlobalOffset("particle_blendmode"); + prog->globaloffsets.particle_orientation = PRVM_ED_FindGlobalOffset("particle_orientation"); + prog->globaloffsets.particle_color1 = PRVM_ED_FindGlobalOffset("particle_color1"); + prog->globaloffsets.particle_color2 = PRVM_ED_FindGlobalOffset("particle_color2"); + prog->globaloffsets.particle_tex = PRVM_ED_FindGlobalOffset("particle_tex"); + prog->globaloffsets.particle_size = PRVM_ED_FindGlobalOffset("particle_size"); + prog->globaloffsets.particle_sizeincrease = PRVM_ED_FindGlobalOffset("particle_sizeincrease"); + prog->globaloffsets.particle_alpha = PRVM_ED_FindGlobalOffset("particle_alpha"); + prog->globaloffsets.particle_alphafade = PRVM_ED_FindGlobalOffset("particle_alphafade"); + prog->globaloffsets.particle_time = PRVM_ED_FindGlobalOffset("particle_time"); + prog->globaloffsets.particle_gravity = PRVM_ED_FindGlobalOffset("particle_gravity"); + prog->globaloffsets.particle_bounce = PRVM_ED_FindGlobalOffset("particle_bounce"); + prog->globaloffsets.particle_airfriction = PRVM_ED_FindGlobalOffset("particle_airfriction"); + prog->globaloffsets.particle_liquidfriction = PRVM_ED_FindGlobalOffset("particle_liquidfriction"); + prog->globaloffsets.particle_originjitter = PRVM_ED_FindGlobalOffset("particle_originjitter"); + prog->globaloffsets.particle_velocityjitter = PRVM_ED_FindGlobalOffset("particle_velocityjitter"); + prog->globaloffsets.particle_qualityreduction = PRVM_ED_FindGlobalOffset("particle_qualityreduction"); + prog->globaloffsets.particle_stretch = PRVM_ED_FindGlobalOffset("particle_stretch"); + prog->globaloffsets.particle_staincolor1 = PRVM_ED_FindGlobalOffset("particle_staincolor1"); + prog->globaloffsets.particle_staincolor2 = PRVM_ED_FindGlobalOffset("particle_staincolor2"); + prog->globaloffsets.particle_stainalpha = PRVM_ED_FindGlobalOffset("particle_stainalpha"); + prog->globaloffsets.particle_stainsize = PRVM_ED_FindGlobalOffset("particle_stainsize"); + prog->globaloffsets.particle_staintex = PRVM_ED_FindGlobalOffset("particle_staintex"); + prog->globaloffsets.particle_staintex = PRVM_ED_FindGlobalOffset("particle_staintex"); + prog->globaloffsets.particle_delayspawn = PRVM_ED_FindGlobalOffset("particle_delayspawn"); + prog->globaloffsets.particle_delaycollision = PRVM_ED_FindGlobalOffset("particle_delaycollision"); + prog->globaloffsets.particle_angle = PRVM_ED_FindGlobalOffset("particle_angle"); + prog->globaloffsets.particle_spin = PRVM_ED_FindGlobalOffset("particle_spin"); + // menu qc only uses some functions, nothing else prog->funcoffsets.m_draw = PRVM_ED_FindFunctionOffset("m_draw"); prog->funcoffsets.m_init = PRVM_ED_FindFunctionOffset("m_init"); diff --git a/prvm_exec.c b/prvm_exec.c index d53b2139..c958a311 100644 --- a/prvm_exec.c +++ b/prvm_exec.c @@ -694,8 +694,8 @@ void MVM_ExecuteProgram (func_t fnum, const char *errormessage) if (!fnum || fnum >= (unsigned int)prog->numfunctions) { - if (prog->globaloffsets.self >= 0 && PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self)) - PRVM_ED_Print(PRVM_PROG_TO_EDICT(PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self)), NULL); + if (PRVM_allglobaledict(self)) + PRVM_ED_Print(PRVM_PROG_TO_EDICT(PRVM_allglobaledict(self)), NULL); PRVM_ERROR ("MVM_ExecuteProgram: %s", errormessage); } @@ -783,8 +783,8 @@ void CLVM_ExecuteProgram (func_t fnum, const char *errormessage) if (!fnum || fnum >= (unsigned int)prog->numfunctions) { - if (prog->globaloffsets.self >= 0 && PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self)) - PRVM_ED_Print(PRVM_PROG_TO_EDICT(PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self)), NULL); + if (PRVM_allglobaledict(self)) + PRVM_ED_Print(PRVM_PROG_TO_EDICT(PRVM_allglobaledict(self)), NULL); PRVM_ERROR ("CLVM_ExecuteProgram: %s", errormessage); } @@ -873,8 +873,8 @@ void SVVM_ExecuteProgram (func_t fnum, const char *errormessage) if (!fnum || fnum >= (unsigned int)prog->numfunctions) { - if (prog->globaloffsets.self >= 0 && PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self)) - PRVM_ED_Print(PRVM_PROG_TO_EDICT(PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self)), NULL); + if (PRVM_allglobaledict(self)) + PRVM_ED_Print(PRVM_PROG_TO_EDICT(PRVM_allglobaledict(self)), NULL); PRVM_ERROR ("SVVM_ExecuteProgram: %s", errormessage); } diff --git a/prvm_execprogram.h b/prvm_execprogram.h index 447ee784..4d872f64 100644 --- a/prvm_execprogram.h +++ b/prvm_execprogram.h @@ -391,10 +391,10 @@ case OP_STATE: if(prog->flag & PRVM_OP_STATE) { - ed = PRVM_PROG_TO_EDICT(PRVM_GLOBALFIELDEDICT(prog->globaloffsets.self)); - PRVM_EDICTFIELDFLOAT(ed,prog->fieldoffsets.nextthink) = PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.time) + 0.1; - PRVM_EDICTFIELDFLOAT(ed,prog->fieldoffsets.frame) = OPA->_float; - PRVM_EDICTFIELDFUNCTION(ed,prog->fieldoffsets.think) = OPB->function; + ed = PRVM_PROG_TO_EDICT(PRVM_gameglobaledict(self)); + PRVM_gameedictfloat(ed,nextthink) = PRVM_gameglobalfloat(time) + 0.1; + PRVM_gameedictfloat(ed,frame) = OPA->_float; + PRVM_gameedictfunction(ed,think) = OPB->function; } else { diff --git a/sv_demo.c b/sv_demo.c index 8f299395..c237f2f4 100644 --- a/sv_demo.c +++ b/sv_demo.c @@ -16,7 +16,7 @@ void SV_StartDemoRecording(client_t *client, const char *filename, int forcetrac Con_Printf("Recording demo for # %d (%s) to %s\n", PRVM_NUM_FOR_EDICT(client->edict), client->netaddress, name); // Reset discardable flag for every new demo. - PRVM_EDICTFIELDFLOAT(client->edict, prog->fieldoffsets.discardabledemo) = 0; + PRVM_serveredictfloat(client->edict, discardabledemo) = 0; client->sv_demo_file = FS_OpenRealFile(name, "wb", false); if(!client->sv_demo_file) @@ -64,7 +64,7 @@ void SV_StopDemoRecording(client_t *client) MSG_WriteByte(&buf, svc_disconnect); SV_WriteDemoMessage(client, &buf, false); - if (sv_autodemo_perclient_discardable.integer && PRVM_EDICTFIELDFLOAT(client->edict, prog->fieldoffsets.discardabledemo)) + if (sv_autodemo_perclient_discardable.integer && PRVM_serveredictfloat(client->edict, discardabledemo)) { FS_RemoveOnClose(client->sv_demo_file); Con_Printf("Stopped recording discardable demo for # %d (%s)\n", PRVM_NUM_FOR_EDICT(client->edict), client->netaddress); diff --git a/sv_main.c b/sv_main.c index ec93e246..95b15596 100644 --- a/sv_main.c +++ b/sv_main.c @@ -249,195 +249,163 @@ static const char *standardeffectnames[EFFECT_TOTAL] = prvm_required_field_t sv_reqfields[] = { - {ev_entity, "aiment"}, - {ev_entity, "chain"}, - {ev_entity, "clientcamera"}, - {ev_entity, "cursor_trace_ent"}, - {ev_entity, "drawonlytoclient"}, - {ev_entity, "enemy"}, - {ev_entity, "exteriormodeltoclient"}, - {ev_entity, "groundentity"}, - {ev_entity, "nodrawtoclient"}, - {ev_entity, "tag_entity"}, - {ev_entity, "viewmodelforclient"}, - {ev_float, "SendFlags"}, - {ev_float, "Version"}, - {ev_float, "alpha"}, - {ev_float, "ammo_cells1"}, - {ev_float, "ammo_lava_nails"}, - {ev_float, "ammo_multi_rockets"}, - {ev_float, "ammo_nails1"}, - {ev_float, "ammo_plasma"}, - {ev_float, "ammo_rockets1"}, - {ev_float, "ammo_shells1"}, - {ev_float, "bouncefactor"}, - {ev_float, "bouncestop"}, - {ev_float, "button3"}, - {ev_float, "button4"}, - {ev_float, "button5"}, - {ev_float, "button6"}, - {ev_float, "button7"}, - {ev_float, "button8"}, - {ev_float, "button9"}, - {ev_float, "button10"}, - {ev_float, "button11"}, - {ev_float, "button12"}, - {ev_float, "button13"}, - {ev_float, "button14"}, - {ev_float, "button15"}, - {ev_float, "button16"}, - {ev_float, "buttonchat"}, - {ev_float, "buttonuse"}, - {ev_float, "clientcolors"}, - {ev_float, "color"}, - {ev_float, "colormod"}, - {ev_float, "cursor_active"}, - {ev_float, "cursor_screen"}, - {ev_float, "cursor_trace_endpos"}, - {ev_float, "cursor_trace_start"}, - {ev_float, "dimension_hit"}, - {ev_float, "dimension_solid"}, - {ev_float, "disableclientprediction"}, - {ev_float, "discardabledemo"}, - {ev_float, "dphitcontentsmask"}, - {ev_float, "fatness"}, - {ev_float, "forceshader"}, - {ev_float, "frame"}, - {ev_float, "frame1time"}, - {ev_float, "frame2"}, - {ev_float, "frame2time"}, - {ev_float, "frame3"}, - {ev_float, "frame3time"}, - {ev_float, "frame4"}, - {ev_float, "frame4time"}, - {ev_float, "fullbright"}, - {ev_float, "glow_color"}, - {ev_float, "glow_size"}, - {ev_float, "glow_trail"}, - {ev_float, "gravity"}, - {ev_float, "hull"}, - {ev_float, "ideal_yaw"}, - {ev_float, "idealpitch"}, - {ev_float, "items2"}, - {ev_float, "jointtype"}, - {ev_float, "lerpfrac"}, - {ev_float, "lerpfrac3"}, - {ev_float, "lerpfrac4"}, - {ev_float, "light_lev"}, - {ev_float, "mass"}, - {ev_float, "modelflags"}, - {ev_float, "modelindex"}, - {ev_float, "movetype"}, - {ev_float, "nextthink"}, - {ev_float, "packetloss"}, - {ev_float, "pflags"}, - {ev_float, "ping"}, - {ev_float, "ping_packetloss"}, - {ev_float, "ping_movementloss"}, - {ev_float, "pitch_speed"}, - {ev_float, "pmodel"}, - {ev_float, "renderamt"}, - {ev_float, "renderflags"}, - {ev_float, "rendermode"}, - {ev_float, "scale"}, - {ev_float, "sendcomplexanimation"}, - {ev_float, "shadertime"}, - {ev_float, "skeletonindex"}, - {ev_float, "solid"}, - {ev_float, "style"}, - {ev_float, "tag_index"}, - {ev_float, "think"}, - {ev_float, "userwavefunc_param0"}, - {ev_float, "userwavefunc_param1"}, - {ev_float, "userwavefunc_param2"}, - {ev_float, "userwavefunc_param3"}, - {ev_float, "viewzoom"}, - {ev_float, "yaw_speed"}, - {ev_function, "SendEntity"}, - {ev_function, "camera_transform"}, - {ev_function, "contentstransition"}, - {ev_function, "customizeentityforclient"}, - {ev_function, "movetypesteplandevent"}, - {ev_string, "classname"}, - {ev_string, "clientstatus"}, - {ev_string, "crypto_encryptmethod"}, - {ev_string, "crypto_idfp"}, - {ev_string, "crypto_keyfp"}, - {ev_string, "crypto_mykeyfp"}, - {ev_string, "crypto_signmethod"}, - {ev_string, "message"}, - {ev_string, "netaddress"}, - {ev_string, "playermodel"}, - {ev_string, "playerskin"}, - {ev_vector, "angles"}, - {ev_vector, "angles"}, - {ev_vector, "avelocity"}, -// {ev_vector, "axis_forward"}, -// {ev_vector, "axis_left"}, -// {ev_vector, "axis_up"}, - {ev_vector, "glowmod"}, - {ev_vector, "maxs"}, - {ev_vector, "mins"}, - {ev_vector, "movedir"}, - {ev_vector, "movement"}, - {ev_vector, "origin"}, - {ev_vector, "punchvector"}, -// {ev_vector, "spinvelocity"}, - {ev_vector, "velocity"}, + {ev_entity, "aiment"}, // server field + {ev_entity, "clientcamera"}, // server field + {ev_entity, "cursor_trace_ent"}, // server field + {ev_entity, "drawonlytoclient"}, // server field + {ev_entity, "enemy"}, // server field + {ev_entity, "exteriormodeltoclient"}, // server field + {ev_entity, "nodrawtoclient"}, // server field + {ev_entity, "tag_entity"}, // server field + {ev_entity, "viewmodelforclient"}, // server field + {ev_float, "SendFlags"}, // server field + {ev_float, "Version"}, // server field + {ev_float, "alpha"}, // server field + {ev_float, "ammo_cells1"}, // server field + {ev_float, "ammo_lava_nails"}, // server field + {ev_float, "ammo_multi_rockets"}, // server field + {ev_float, "ammo_nails1"}, // server field + {ev_float, "ammo_plasma"}, // server field + {ev_float, "ammo_rockets1"}, // server field + {ev_float, "ammo_shells1"}, // server field + {ev_float, "bouncefactor"}, // server field + {ev_float, "bouncestop"}, // server field + {ev_float, "button3"}, // server field + {ev_float, "button4"}, // server field + {ev_float, "button5"}, // server field + {ev_float, "button6"}, // server field + {ev_float, "button7"}, // server field + {ev_float, "button8"}, // server field + {ev_float, "button9"}, // server field + {ev_float, "button10"}, // server field + {ev_float, "button11"}, // server field + {ev_float, "button12"}, // server field + {ev_float, "button13"}, // server field + {ev_float, "button14"}, // server field + {ev_float, "button15"}, // server field + {ev_float, "button16"}, // server field + {ev_float, "buttonchat"}, // server field + {ev_float, "buttonuse"}, // server field + {ev_float, "clientcolors"}, // server field + {ev_float, "cursor_active"}, // server field + {ev_float, "disableclientprediction"}, // server field + {ev_float, "discardabledemo"}, // server field + {ev_float, "dphitcontentsmask"}, // server field + {ev_float, "frame1time"}, // server field + {ev_float, "frame1time"}, // server field + {ev_float, "frame2time"}, // server field + {ev_float, "frame2time"}, // server field + {ev_float, "frame2"}, // server field + {ev_float, "frame2"}, // server field + {ev_float, "frame3time"}, // server field + {ev_float, "frame3time"}, // server field + {ev_float, "frame3"}, // server field + {ev_float, "frame3"}, // server field + {ev_float, "frame4time"}, // server field + {ev_float, "frame4time"}, // server field + {ev_float, "frame4"}, // server field + {ev_float, "frame4"}, // server field + {ev_float, "frame"}, // server field + {ev_float, "fullbright"}, // server field + {ev_float, "glow_color"}, // server field + {ev_float, "glow_size"}, // server field + {ev_float, "glow_trail"}, // server field + {ev_float, "gravity"}, // server field + {ev_float, "gravity"}, // server field + {ev_float, "ideal_yaw"}, // server field + {ev_float, "idealpitch"}, // server field + {ev_float, "items2"}, // server field + {ev_float, "jointtype"}, // server field + {ev_float, "lerpfrac3"}, // server field + {ev_float, "lerpfrac3"}, // server field + {ev_float, "lerpfrac4"}, // server field + {ev_float, "lerpfrac4"}, // server field + {ev_float, "lerpfrac"}, // server field + {ev_float, "lerpfrac"}, // server field + {ev_float, "light_lev"}, // server field + {ev_float, "mass"}, // server field + {ev_float, "modelflags"}, // server field + {ev_float, "modelindex"}, // server field + {ev_float, "movetype"}, // server field + {ev_float, "pflags"}, // server field + {ev_float, "ping_movementloss"}, // server field + {ev_float, "ping_packetloss"}, // server field + {ev_float, "ping"}, // server field + {ev_float, "pitch_speed"}, // server field + {ev_float, "pmodel"}, // server field + {ev_float, "renderamt"}, // server field + {ev_float, "scale"}, // server field + {ev_float, "scale"}, // server field + {ev_float, "sendcomplexanimation"}, // server field + {ev_float, "skeletonindex"}, // server field + {ev_float, "skeletonindex"}, // server field + {ev_float, "solid"}, // server field + {ev_float, "style"}, // server field + {ev_float, "tag_index"}, // server field + {ev_float, "viewzoom"}, // server field + {ev_float, "yaw_speed"}, // server field + {ev_function, "SendEntity"}, // server field + {ev_function, "camera_transform"}, // server field + {ev_function, "contentstransition"}, // server field + {ev_function, "customizeentityforclient"}, // server field + {ev_function, "movetypesteplandevent"}, // server field + {ev_string, "classname"}, // server field + {ev_string, "clientstatus"}, // server field + {ev_string, "crypto_encryptmethod"}, // server field + {ev_string, "crypto_idfp"}, // server field + {ev_string, "crypto_keyfp"}, // server field + {ev_string, "crypto_mykeyfp"}, // server field + {ev_string, "crypto_signmethod"}, // server field + {ev_string, "netaddress"}, // server field + {ev_string, "playermodel"}, // server field + {ev_string, "playerskin"}, // server field + {ev_vector, "angles"}, // server field + {ev_vector, "avelocity"}, // server field + {ev_vector, "colormod"}, // server field + {ev_vector, "color"}, // server field + {ev_vector, "cursor_screen"}, // server field + {ev_vector, "cursor_trace_endpos"}, // server field + {ev_vector, "cursor_trace_start"}, // server field + {ev_vector, "glowmod"}, // server field + {ev_vector, "maxs"}, // server field + {ev_vector, "mins"}, // server field + {ev_vector, "movedir"}, // server field + {ev_vector, "movement"}, // server field + {ev_vector, "origin"}, // server field + {ev_vector, "punchvector"}, // server field + {ev_vector, "velocity"}, // server field }; #define SV_REQGLOBALS (sizeof(sv_reqglobals) / sizeof(prvm_required_field_t)) prvm_required_field_t sv_reqglobals[] = { - {ev_entity, "self"}, - {ev_entity, "trace_ent"}, - {ev_entity, "trace_networkentity"}, - {ev_float, "coop"}, - {ev_float, "deathmatch"}, - {ev_float, "dmg_save"}, - {ev_float, "dmg_take"}, - {ev_float, "drawfont"}, - {ev_float, "drawfontscale"}, - {ev_float, "gettaginfo_parent"}, - {ev_float, "intermission"}, - {ev_float, "particles_alphamax"}, - {ev_float, "particles_alphamin"}, - {ev_float, "require_spawnfunc_prefix"}, - {ev_float, "sb_showscores"}, - {ev_float, "serverdeltatime"}, - {ev_float, "serverprevtime"}, - {ev_float, "servertime"}, - {ev_float, "time"}, - {ev_float, "trace_allsolid"}, - {ev_float, "trace_dphitcontents"}, - {ev_float, "trace_dphitq3surfaceflags"}, - {ev_float, "trace_dpstartcontents"}, - {ev_float, "trace_fraction"}, - {ev_float, "trace_inopen"}, - {ev_float, "trace_inwater"}, - {ev_float, "trace_plane_dist"}, - {ev_float, "trace_startsolid"}, - {ev_float, "transparent_offset"}, - {ev_string, "SV_InitCmd"}, - {ev_string, "gettaginfo_name"}, - {ev_string, "trace_dphittexturename"}, - {ev_string, "worldstatus"}, - {ev_vector, "dmg_origin"}, - {ev_vector, "gettaginfo_forward"}, - {ev_vector, "gettaginfo_offset"}, - {ev_vector, "gettaginfo_right"}, - {ev_vector, "gettaginfo_up"}, - {ev_vector, "particles_colormax"}, - {ev_vector, "particles_colormin"}, - {ev_vector, "trace_endpos"}, - {ev_vector, "trace_plane_normal"}, - {ev_vector, "v_forward"}, - {ev_vector, "v_right"}, - {ev_vector, "v_up"}, - {ev_vector, "view_angles"}, - {ev_vector, "view_punchangle"}, - {ev_vector, "view_punchvector"}, + {ev_entity, "self"}, // server global + {ev_entity, "trace_ent"}, // server global + {ev_float, "gettaginfo_parent"}, // server global + {ev_float, "require_spawnfunc_prefix"}, // server global + {ev_float, "trace_allsolid"}, // server global + {ev_float, "trace_dphitcontents"}, // server global + {ev_float, "trace_dphitq3surfaceflags"}, // server global + {ev_float, "trace_dpstartcontents"}, // server global + {ev_float, "trace_fraction"}, // server global + {ev_float, "trace_inopen"}, // server global + {ev_float, "trace_inwater"}, // server global + {ev_float, "trace_plane_dist"}, // server global + {ev_float, "trace_startsolid"}, // server global + {ev_string, "SV_InitCmd"}, // server global + {ev_string, "gettaginfo_name"}, // server global + {ev_string, "trace_dphittexturename"}, // server global + {ev_string, "worldstatus"}, // server global + {ev_vector, "gettaginfo_forward"}, // server global + {ev_vector, "gettaginfo_offset"}, // server global + {ev_vector, "gettaginfo_right"}, // server global + {ev_vector, "gettaginfo_up"}, // server global + {ev_vector, "trace_endpos"}, // server global + {ev_vector, "trace_plane_normal"}, // server global + {ev_vector, "v_forward"}, // server global + {ev_vector, "v_right"}, // server global + {ev_vector, "v_up"}, // server global }; @@ -972,10 +940,10 @@ void SV_SendServerinfo (client_t *client) } //[515]: init stufftext string (it is sent before svc_serverinfo) - if (PRVM_GetString(PRVM_GLOBALFIELDSTRING(prog->globaloffsets.SV_InitCmd))) + if (PRVM_GetString(PRVM_serverglobalstring(SV_InitCmd))) { MSG_WriteByte (&client->netconnection->message, svc_stufftext); - MSG_WriteString (&client->netconnection->message, va("%s\n", PRVM_GetString(PRVM_GLOBALFIELDSTRING(prog->globaloffsets.SV_InitCmd)))); + MSG_WriteString (&client->netconnection->message, va("%s\n", PRVM_GetString(PRVM_serverglobalstring(SV_InitCmd)))); } } @@ -1162,7 +1130,7 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c // fast path for games that do not use legacy entity networking // note: still networks clients even if they are legacy - sendentity = PRVM_EDICTFIELDFUNCTION(ent, prog->fieldoffsets.SendEntity); + sendentity = PRVM_serveredictfunction(ent, SendEntity); if (sv_onlycsqcnetworking.integer && !sendentity && enumber > svs.maxclients) return false; @@ -1182,24 +1150,24 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c modelindex = (i >= 1 && i < MAX_MODELS && ent->fields.server->model && *PRVM_GetString(ent->fields.server->model) && sv.models[i]) ? i : 0; flags = 0; - i = (int)(PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.glow_size) * 0.25f); + i = (int)(PRVM_serveredictfloat(ent, glow_size) * 0.25f); glowsize = (unsigned char)bound(0, i, 255); - if (PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.glow_trail)) + if (PRVM_serveredictfloat(ent, glow_trail)) flags |= RENDER_GLOWTRAIL; - if (PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.viewmodelforclient)) + if (PRVM_serveredictedict(ent, viewmodelforclient)) flags |= RENDER_VIEWMODEL; - v = PRVM_EDICTFIELDVECTOR(ent, prog->fieldoffsets.color); + v = PRVM_serveredictvector(ent, color); f = v[0]*256; light[0] = (unsigned short)bound(0, f, 65535); f = v[1]*256; light[1] = (unsigned short)bound(0, f, 65535); f = v[2]*256; light[2] = (unsigned short)bound(0, f, 65535); - f = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.light_lev); + f = PRVM_serveredictfloat(ent, light_lev); light[3] = (unsigned short)bound(0, f, 65535); - lightstyle = (unsigned char)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.style); - lightpflags = (unsigned char)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.pflags); + lightstyle = (unsigned char)PRVM_serveredictfloat(ent, style); + lightpflags = (unsigned char)PRVM_serveredictfloat(ent, pflags); if (gamemode == GAME_TENEBRAE) { @@ -1250,7 +1218,7 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c // early culling checks // (final culling is done by SV_MarkWriteEntityStateToClient) - customizeentityforclient = PRVM_EDICTFIELDFUNCTION(ent, prog->fieldoffsets.customizeentityforclient); + customizeentityforclient = PRVM_serveredictfunction(ent, customizeentityforclient); if (!customizeentityforclient && enumber > svs.maxclients && (!modelindex && !specialvisibilityradius)) return false; @@ -1265,18 +1233,18 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c cs->modelindex = modelindex; cs->skin = (unsigned)ent->fields.server->skin; cs->frame = (unsigned)ent->fields.server->frame; - cs->viewmodelforclient = PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.viewmodelforclient); - cs->exteriormodelforclient = PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.exteriormodeltoclient); - cs->nodrawtoclient = PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.nodrawtoclient); - cs->drawonlytoclient = PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.drawonlytoclient); + cs->viewmodelforclient = PRVM_serveredictedict(ent, viewmodelforclient); + cs->exteriormodelforclient = PRVM_serveredictedict(ent, exteriormodeltoclient); + cs->nodrawtoclient = PRVM_serveredictedict(ent, nodrawtoclient); + cs->drawonlytoclient = PRVM_serveredictedict(ent, drawonlytoclient); cs->customizeentityforclient = customizeentityforclient; - cs->tagentity = PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.tag_entity); - cs->tagindex = (unsigned char)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.tag_index); + cs->tagentity = PRVM_serveredictedict(ent, tag_entity); + cs->tagindex = (unsigned char)PRVM_serveredictfloat(ent, tag_index); cs->glowsize = glowsize; // don't need to init cs->colormod because the defaultstate did that for us //cs->colormod[0] = cs->colormod[1] = cs->colormod[2] = 32; - v = PRVM_EDICTFIELDVECTOR(ent, prog->fieldoffsets.colormod); + v = PRVM_serveredictvector(ent, colormod); if (VectorLength2(v)) { i = (int)(v[0] * 32.0f);cs->colormod[0] = bound(0, i, 255); @@ -1286,7 +1254,7 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c // don't need to init cs->glowmod because the defaultstate did that for us //cs->glowmod[0] = cs->glowmod[1] = cs->glowmod[2] = 32; - v = PRVM_EDICTFIELDVECTOR(ent, prog->fieldoffsets.glowmod); + v = PRVM_serveredictvector(ent, glowmod); if (VectorLength2(v)) { i = (int)(v[0] * 32.0f);cs->glowmod[0] = bound(0, i, 255); @@ -1297,14 +1265,14 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c cs->modelindex = modelindex; cs->alpha = 255; - f = (PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.alpha) * 255.0f); + f = (PRVM_serveredictfloat(ent, alpha) * 255.0f); if (f) { i = (int)f; cs->alpha = (unsigned char)bound(0, i, 255); } // halflife - f = (PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.renderamt)); + f = (PRVM_serveredictfloat(ent, renderamt)); if (f) { i = (int)f; @@ -1312,7 +1280,7 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c } cs->scale = 16; - f = (PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.scale) * 16.0f); + f = (PRVM_serveredictfloat(ent, scale) * 16.0f); if (f) { i = (int)f; @@ -1320,14 +1288,14 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c } cs->glowcolor = 254; - f = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.glow_color); + f = PRVM_serveredictfloat(ent, glow_color); if (f) cs->glowcolor = (int)f; - if (PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.fullbright)) + if (PRVM_serveredictfloat(ent, fullbright)) cs->effects |= EF_FULLBRIGHT; - f = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.modelflags); + f = PRVM_serveredictfloat(ent, modelflags); if (f) cs->effects |= ((unsigned int)f & 0xff) << 24; @@ -1340,22 +1308,22 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c if (cs->viewmodelforclient) cs->flags |= RENDER_VIEWMODEL; // show relative to the view - if (PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.sendcomplexanimation)) + if (PRVM_serveredictfloat(ent, sendcomplexanimation)) { cs->flags |= RENDER_COMPLEXANIMATION; - if (PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.skeletonindex) >= 1) + if (PRVM_serveredictfloat(ent, skeletonindex) >= 1) cs->skeletonobject = ent->priv.server->skeleton; - cs->framegroupblend[0].frame = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.frame); - cs->framegroupblend[1].frame = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.frame2); - cs->framegroupblend[2].frame = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.frame3); - cs->framegroupblend[3].frame = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.frame4); - cs->framegroupblend[0].start = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.frame1time); - cs->framegroupblend[1].start = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.frame2time); - cs->framegroupblend[2].start = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.frame3time); - cs->framegroupblend[3].start = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.frame4time); - cs->framegroupblend[1].lerp = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.lerpfrac); - cs->framegroupblend[2].lerp = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.lerpfrac3); - cs->framegroupblend[3].lerp = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.lerpfrac4); + cs->framegroupblend[0].frame = PRVM_serveredictfloat(ent, frame); + cs->framegroupblend[1].frame = PRVM_serveredictfloat(ent, frame2); + cs->framegroupblend[2].frame = PRVM_serveredictfloat(ent, frame3); + cs->framegroupblend[3].frame = PRVM_serveredictfloat(ent, frame4); + cs->framegroupblend[0].start = PRVM_serveredictfloat(ent, frame1time); + cs->framegroupblend[1].start = PRVM_serveredictfloat(ent, frame2time); + cs->framegroupblend[2].start = PRVM_serveredictfloat(ent, frame3time); + cs->framegroupblend[3].start = PRVM_serveredictfloat(ent, frame4time); + cs->framegroupblend[1].lerp = PRVM_serveredictfloat(ent, lerpfrac); + cs->framegroupblend[2].lerp = PRVM_serveredictfloat(ent, lerpfrac3); + cs->framegroupblend[3].lerp = PRVM_serveredictfloat(ent, lerpfrac4); cs->framegroupblend[0].lerp = 1.0f - cs->framegroupblend[1].lerp - cs->framegroupblend[2].lerp - cs->framegroupblend[3].lerp; } @@ -1432,10 +1400,10 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c // (to let the QC know that they've been read) if (sendentity) { - sendflags = (unsigned int)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.SendFlags); - PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.SendFlags) = 0; + sendflags = (unsigned int)PRVM_serveredictfloat(ent, SendFlags); + PRVM_serveredictfloat(ent, SendFlags) = 0; // legacy self.Version system - if ((version = (unsigned int)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.Version))) + if ((version = (unsigned int)PRVM_serveredictfloat(ent, Version))) { if (sv.csqcentityversion[enumber] != version) sendflags = 0xFFFFFF; @@ -1538,7 +1506,7 @@ qboolean SV_CanSeeBox(int numtraces, vec_t enlarge, vec3_t eye, vec3_t entboxmin if (!model || !model->brush.TraceLineOfSight) continue; // skip obviously transparent entities - alpha = PRVM_EDICTFIELDFLOAT(touch, prog->fieldoffsets.alpha); + alpha = PRVM_serveredictfloat(touch, alpha); if (alpha && alpha < 1) continue; if ((int)touch->fields.server->effects & EF_ADDITIVE) @@ -1725,9 +1693,6 @@ void SV_AddCameraEyes(void) int n_cameras = 0; vec3_t mi, ma; - if(!prog->fieldoffsets.camera_transform) - return; - for(i = 0; i < sv.writeentitiestoclient_numeyes; ++i) eye_levels[i] = 0; @@ -1736,17 +1701,17 @@ void SV_AddCameraEyes(void) { if (!ed->priv.server->free) { - if(PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.camera_transform)) + if(PRVM_serveredictfunction(ed, camera_transform)) { prog->globals.server->self = e; prog->globals.server->other = sv.writeentitiestoclient_cliententitynumber; - VectorCopy(sv.writeentitiestoclient_eyes[0], PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.trace_endpos)); + VectorCopy(sv.writeentitiestoclient_eyes[0], PRVM_serverglobalvector(trace_endpos)); VectorCopy(sv.writeentitiestoclient_eyes[0], PRVM_G_VECTOR(OFS_PARM0)); VectorClear(PRVM_G_VECTOR(OFS_PARM1)); - PRVM_ExecuteProgram(PRVM_EDICTFIELDFUNCTION(ed, prog->fieldoffsets.camera_transform), "QC function e.camera_transform is missing"); - if(!VectorCompare(PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.trace_endpos), sv.writeentitiestoclient_eyes[0])) + PRVM_ExecuteProgram(PRVM_serveredictfunction(ed, camera_transform), "QC function e.camera_transform is missing"); + if(!VectorCompare(PRVM_serverglobalvector(trace_endpos), sv.writeentitiestoclient_eyes[0])) { - VectorCopy(PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.trace_endpos), camera_origins[n_cameras]); + VectorCopy(PRVM_serverglobalvector(trace_endpos), camera_origins[n_cameras]); cameras[n_cameras] = e; ++n_cameras; if(n_cameras >= MAX_LEVELNETWORKEYES) @@ -1990,11 +1955,11 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t // stuff the sigil bits into the high bits of items for sbar, or else // mix in items2 if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE) - items = (int)ent->fields.server->items | ((int)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.items2) << 23); + items = (int)ent->fields.server->items | ((int)PRVM_serveredictfloat(ent, items2) << 23); else items = (int)ent->fields.server->items | ((int)prog->globals.server->serverflags << 28); - VectorCopy(PRVM_EDICTFIELDVECTOR(ent, prog->fieldoffsets.punchvector), punchvector); + VectorCopy(PRVM_serveredictvector(ent, punchvector), punchvector); // cache weapon model name and index in client struct to save time // (this search can be almost 1% of cpu time!) @@ -2005,7 +1970,7 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t client->weaponmodelindex = SV_ModelIndex(s, 1); } - viewzoom = (int)(PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.viewzoom) * 255.0f); + viewzoom = (int)(PRVM_serveredictfloat(ent, viewzoom) * 255.0f); if (viewzoom == 0) viewzoom = 255; @@ -2029,7 +1994,7 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t bits |= (SU_VELOCITY1<fieldoffsets.gravity);if (!gravity) gravity = 1.0f; + gravity = PRVM_serveredictfloat(ent, gravity);if (!gravity) gravity = 1.0f; memset(stats, 0, sizeof(int[MAX_CL_STATS])); stats[STAT_VIEWHEIGHT] = (int)ent->fields.server->view_ofs[2]; @@ -2450,7 +2415,7 @@ static void SV_UpdateToReliableMessages (void) } // DP_SV_CLIENTCOLORS - host_client->colors = (int)PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.clientcolors); + host_client->colors = (int)PRVM_serveredictfloat(host_client->edict, clientcolors); if (host_client->old_colors != host_client->colors) { host_client->old_colors = host_client->colors; @@ -2461,27 +2426,23 @@ static void SV_UpdateToReliableMessages (void) } // NEXUIZ_PLAYERMODEL - if( prog->fieldoffsets.playermodel >= 0 ) { - model = PRVM_GetString(PRVM_EDICTFIELDSTRING(host_client->edict, prog->fieldoffsets.playermodel)); - if (model == NULL) - model = ""; - // always point the string back at host_client->name to keep it safe - strlcpy (host_client->playermodel, model, sizeof (host_client->playermodel)); - PRVM_EDICTFIELDSTRING(host_client->edict, prog->fieldoffsets.playermodel) = PRVM_SetEngineString(host_client->playermodel); - } + model = PRVM_GetString(PRVM_serveredictstring(host_client->edict, playermodel)); + if (model == NULL) + model = ""; + // always point the string back at host_client->name to keep it safe + strlcpy (host_client->playermodel, model, sizeof (host_client->playermodel)); + PRVM_serveredictstring(host_client->edict, playermodel) = PRVM_SetEngineString(host_client->playermodel); // NEXUIZ_PLAYERSKIN - if( prog->fieldoffsets.playerskin >= 0 ) { - skin = PRVM_GetString(PRVM_EDICTFIELDSTRING(host_client->edict, prog->fieldoffsets.playerskin)); - if (skin == NULL) - skin = ""; - // always point the string back at host_client->name to keep it safe - strlcpy (host_client->playerskin, skin, sizeof (host_client->playerskin)); - PRVM_EDICTFIELDSTRING(host_client->edict, prog->fieldoffsets.playerskin) = PRVM_SetEngineString(host_client->playerskin); - } + skin = PRVM_GetString(PRVM_serveredictstring(host_client->edict, playerskin)); + if (skin == NULL) + skin = ""; + // always point the string back at host_client->name to keep it safe + strlcpy (host_client->playerskin, skin, sizeof (host_client->playerskin)); + PRVM_serveredictstring(host_client->edict, playerskin) = PRVM_SetEngineString(host_client->playerskin); // TODO: add an extension name for this [1/17/2008 Black] - clientcamera = PRVM_EDICTFIELDEDICT(host_client->edict, prog->fieldoffsets.clientcamera); + clientcamera = PRVM_serveredictedict(host_client->edict, clientcamera); if (clientcamera > 0) { int oldclientcamera = host_client->clientcamera; @@ -3508,60 +3469,39 @@ static void SV_VM_CB_InitEdict(prvm_edict_t *e) // DP_SV_CLIENTNAME and DP_SV_CLIENTCOLORS will not immediately // reset them e->fields.server->netname = PRVM_SetEngineString(svs.clients[num].name); - PRVM_EDICTFIELDFLOAT(e, prog->fieldoffsets.clientcolors) = svs.clients[num].colors; + PRVM_serveredictfloat(e, clientcolors) = svs.clients[num].colors; // NEXUIZ_PLAYERMODEL and NEXUIZ_PLAYERSKIN - if( prog->fieldoffsets.playermodel >= 0 ) - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.playermodel) = PRVM_SetEngineString(svs.clients[num].playermodel); - if( prog->fieldoffsets.playerskin >= 0 ) - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.playerskin) = PRVM_SetEngineString(svs.clients[num].playerskin); + PRVM_serveredictstring(e, playermodel) = PRVM_SetEngineString(svs.clients[num].playermodel); + PRVM_serveredictstring(e, playerskin) = PRVM_SetEngineString(svs.clients[num].playerskin); // Assign netaddress (IP Address, etc) - if(prog->fieldoffsets.netaddress >= 0) - { // Valid Field; Process - if(svs.clients[num].netconnection != NULL) - {// Valid Address; Assign - // Acquire Readable Address - LHNETADDRESS_ToString(&svs.clients[num].netconnection->peeraddress, svs.clients[num].netaddress, sizeof(svs.clients[num].netaddress), false); - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.netaddress) = PRVM_SetEngineString(svs.clients[num].netaddress); - } - else - // Invalid / Bot - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.netaddress) = PRVM_SetEngineString("null/botclient"); - } - if(prog->fieldoffsets.crypto_idfp >= 0) - { // Valid Field; Process - if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.client_idfp[0]) - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.crypto_idfp) = PRVM_SetEngineString(svs.clients[num].netconnection->crypto.client_idfp); - else - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.crypto_idfp) = 0; - } - if(prog->fieldoffsets.crypto_keyfp >= 0) - { // Valid Field; Process - if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.client_keyfp[0]) - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.crypto_keyfp) = PRVM_SetEngineString(svs.clients[num].netconnection->crypto.client_keyfp); - else - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.crypto_keyfp) = 0; - } - if(prog->fieldoffsets.crypto_mykeyfp >= 0) - { // Valid Field; Process - if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.server_keyfp[0]) - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.crypto_mykeyfp) = PRVM_SetEngineString(svs.clients[num].netconnection->crypto.server_keyfp); - else - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.crypto_mykeyfp) = 0; - } - if(prog->fieldoffsets.crypto_encryptmethod >= 0) - { // Valid Field; Process - if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.use_aes) - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.crypto_encryptmethod) = PRVM_SetEngineString("AES128"); - else - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.crypto_encryptmethod) = 0; - } - if(prog->fieldoffsets.crypto_signmethod >= 0) - { // Valid Field; Process - if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated) - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.crypto_signmethod) = PRVM_SetEngineString("HMAC-SHA256"); - else - PRVM_EDICTFIELDSTRING(e, prog->fieldoffsets.crypto_signmethod) = 0; + if(svs.clients[num].netconnection != NULL) + { + // Acquire Readable Address + LHNETADDRESS_ToString(&svs.clients[num].netconnection->peeraddress, svs.clients[num].netaddress, sizeof(svs.clients[num].netaddress), false); + PRVM_serveredictstring(e, netaddress) = PRVM_SetEngineString(svs.clients[num].netaddress); } + else + PRVM_serveredictstring(e, netaddress) = PRVM_SetEngineString("null/botclient"); + if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.client_idfp[0]) + PRVM_serveredictstring(e, crypto_idfp) = PRVM_SetEngineString(svs.clients[num].netconnection->crypto.client_idfp); + else + PRVM_serveredictstring(e, crypto_idfp) = 0; + if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.client_keyfp[0]) + PRVM_serveredictstring(e, crypto_keyfp) = PRVM_SetEngineString(svs.clients[num].netconnection->crypto.client_keyfp); + else + PRVM_serveredictstring(e, crypto_keyfp) = 0; + if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.server_keyfp[0]) + PRVM_serveredictstring(e, crypto_mykeyfp) = PRVM_SetEngineString(svs.clients[num].netconnection->crypto.server_keyfp); + else + PRVM_serveredictstring(e, crypto_mykeyfp) = 0; + if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.use_aes) + PRVM_serveredictstring(e, crypto_encryptmethod) = PRVM_SetEngineString("AES128"); + else + PRVM_serveredictstring(e, crypto_encryptmethod) = 0; + if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated) + PRVM_serveredictstring(e, crypto_signmethod) = PRVM_SetEngineString("HMAC-SHA256"); + else + PRVM_serveredictstring(e, crypto_signmethod) = 0; } } diff --git a/sv_phys.c b/sv_phys.c index 541a1059..c0f89c89 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -52,7 +52,7 @@ int SV_GetPitchSign(prvm_edict_t *ent) model->type == mod_alias : ( - (((unsigned char)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.pflags)) & PFLAGS_FULLDYNAMIC) + (((unsigned char)PRVM_serveredictfloat(ent, pflags)) & PFLAGS_FULLDYNAMIC) || ((gamemode == GAME_TENEBRAE) && ((unsigned int)ent->fields.server->effects & (16 | 32))) ) @@ -73,7 +73,7 @@ int SV_GenericHitSuperContentsMask(const prvm_edict_t *passedict) { if (passedict) { - int dphitcontentsmask = (int)PRVM_EDICTFIELDFLOAT(passedict, prog->fieldoffsets.dphitcontentsmask); + int dphitcontentsmask = (int)PRVM_serveredictfloat(passedict, dphitcontentsmask); if (dphitcontentsmask) return dphitcontentsmask; else if (passedict->fields.server->solid == SOLID_SLIDEBOX) @@ -713,10 +713,10 @@ void SV_LinkEdict_TouchAreaGrid_Call(prvm_edict_t *touch, prvm_edict_t *ent) VectorSet (prog->globals.server->trace_plane_normal, 0, 0, 1); prog->globals.server->trace_plane_dist = 0; prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(ent); - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dpstartcontents) = 0; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dphitcontents) = 0; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dphitq3surfaceflags) = 0; - PRVM_GLOBALFIELDSTRING(prog->globaloffsets.trace_dphittexturename) = 0; + PRVM_serverglobalfloat(trace_dpstartcontents) = 0; + PRVM_serverglobalfloat(trace_dphitcontents) = 0; + PRVM_serverglobalfloat(trace_dphitq3surfaceflags) = 0; + PRVM_serverglobalstring(trace_dphittexturename) = 0; PRVM_ExecuteProgram (touch->fields.server->touch, "QC function self.touch is missing"); } @@ -1013,7 +1013,7 @@ int SV_CheckContentsTransition(prvm_edict_t *ent, const int nContents) if(ent->fields.server->watertype != nContents) { // Changed Contents // Acquire Contents Transition Function from QC - if(PRVM_EDICTFIELDFUNCTION(ent, prog->fieldoffsets.contentstransition)) + if(PRVM_serveredictfunction(ent, contentstransition)) { // Valid Function; Execute // Assign Valid Function bValidFunctionCall = true; @@ -1025,7 +1025,7 @@ int SV_CheckContentsTransition(prvm_edict_t *ent, const int nContents) // Assign Self prog->globals.server->self = PRVM_EDICT_TO_PROG(ent); // Execute VM Function - PRVM_ExecuteProgram(PRVM_EDICTFIELDFUNCTION(ent, prog->fieldoffsets.contentstransition), "contentstransition: NULL function"); + PRVM_ExecuteProgram(PRVM_serveredictfunction(ent, contentstransition), "contentstransition: NULL function"); } } @@ -1151,10 +1151,10 @@ void SV_Impact (prvm_edict_t *e1, trace_t *trace) VectorNegate(trace->plane.normal, prog->globals.server->trace_plane_normal); prog->globals.server->trace_plane_dist = -trace->plane.dist; prog->globals.server->trace_ent = PRVM_EDICT_TO_PROG(e1); - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dpstartcontents) = 0; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dphitcontents) = 0; - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.trace_dphitq3surfaceflags) = 0; - PRVM_GLOBALFIELDSTRING(prog->globaloffsets.trace_dphittexturename) = 0; + PRVM_serverglobalfloat(trace_dpstartcontents) = 0; + PRVM_serverglobalfloat(trace_dphitcontents) = 0; + PRVM_serverglobalfloat(trace_dphitq3surfaceflags) = 0; + PRVM_serverglobalstring(trace_dphittexturename) = 0; PRVM_ExecuteProgram (e2->fields.server->touch, "QC function self.touch is missing"); } @@ -1434,7 +1434,7 @@ static float SV_Gravity (prvm_edict_t *ent) { float ent_gravity; - ent_gravity = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.gravity); + ent_gravity = PRVM_serveredictfloat(ent, gravity); if (!ent_gravity) ent_gravity = 1.0f; return ent_gravity * sv_gravity.value * sv.frametime; @@ -2505,7 +2505,7 @@ void SV_Physics_Toss (prvm_edict_t *ent) if (ent->fields.server->movetype == MOVETYPE_BOUNCEMISSILE) { float bouncefactor; - bouncefactor = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.bouncefactor); + bouncefactor = PRVM_serveredictfloat(ent, bouncefactor); if (!bouncefactor) bouncefactor = 1.0f; @@ -2518,16 +2518,16 @@ void SV_Physics_Toss (prvm_edict_t *ent) float bouncefactor; float bouncestop; - bouncefactor = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.bouncefactor); + bouncefactor = PRVM_serveredictfloat(ent, bouncefactor); if (!bouncefactor) bouncefactor = 0.5f; - bouncestop = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.bouncestop); + bouncestop = PRVM_serveredictfloat(ent, bouncestop); if (!bouncestop) bouncestop = 60.0f / 800.0f; ClipVelocity (ent->fields.server->velocity, trace.plane.normal, ent->fields.server->velocity, 1 + bouncefactor); - ent_gravity = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.gravity); + ent_gravity = PRVM_serveredictfloat(ent, gravity); if (!ent_gravity) ent_gravity = 1.0f; // LordHavoc: fixed grenades not bouncing when fired down a slope @@ -2639,7 +2639,7 @@ void SV_Physics_Step (prvm_edict_t *ent) if (hitsound && (int)ent->fields.server->flags & FL_ONGROUND) { // DRESK - Check for Entity Land Event Function - if(PRVM_EDICTFIELDFUNCTION(ent, prog->fieldoffsets.movetypesteplandevent)) + if(PRVM_serveredictfunction(ent, movetypesteplandevent)) { // Valid Function; Execute // Prepare Parameters // Assign Velocity at Impact @@ -2649,7 +2649,7 @@ void SV_Physics_Step (prvm_edict_t *ent) // Assign Self prog->globals.server->self = PRVM_EDICT_TO_PROG(ent); // Execute VM Function - PRVM_ExecuteProgram(PRVM_EDICTFIELDFUNCTION(ent, prog->fieldoffsets.movetypesteplandevent), "movetypesteplandevent: NULL function"); + PRVM_ExecuteProgram(PRVM_serveredictfunction(ent, movetypesteplandevent), "movetypesteplandevent: NULL function"); } else // Check for Engine Landing Sound diff --git a/sv_user.c b/sv_user.c index 4a70f1a6..d675990f 100644 --- a/sv_user.c +++ b/sv_user.c @@ -199,7 +199,7 @@ void DropPunchAngle (void) len = 0; VectorScale (host_client->edict->fields.server->punchangle, len, host_client->edict->fields.server->punchangle); - VectorCopy(PRVM_EDICTFIELDVECTOR(host_client->edict, prog->fieldoffsets.punchvector), v); + VectorCopy(PRVM_serveredictvector(host_client->edict, punchvector), v); len = VectorNormalizeLength(v); if (len > 0) { @@ -208,7 +208,7 @@ void DropPunchAngle (void) len = 0; VectorScale(v, len, v); } - VectorCopy(v, PRVM_EDICTFIELDVECTOR(host_client->edict, prog->fieldoffsets.punchvector)); + VectorCopy(v, PRVM_serveredictvector(host_client->edict, punchvector)); } /* @@ -597,7 +597,7 @@ void SV_ExecuteClientMoves(void) if (ceil(max(sv_readmoves[sv_numreadmoves-1].receivetime - sv_readmoves[sv_numreadmoves-1].time, 0) * 1000.0) < sv_clmovement_minping.integer) host_client->clmovement_disabletimeout = realtime + sv_clmovement_minping_disabletime.value / 1000.0; // several conditions govern whether clientside movement prediction is allowed - if (sv_readmoves[sv_numreadmoves-1].sequence && sv_clmovement_enable.integer && sv_clmovement_inputtimeout.value > 0 && host_client->clmovement_disabletimeout <= realtime && host_client->edict->fields.server->movetype == MOVETYPE_WALK && (!PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.disableclientprediction))) + if (sv_readmoves[sv_numreadmoves-1].sequence && sv_clmovement_enable.integer && sv_clmovement_inputtimeout.value > 0 && host_client->clmovement_disabletimeout <= realtime && host_client->edict->fields.server->movetype == MOVETYPE_WALK && (!PRVM_serveredictfloat(host_client->edict, disableclientprediction))) { // process the moves in order and ignore old ones // but always trust the latest move @@ -738,31 +738,31 @@ void SV_ApplyClientMove (void) } VectorCopy(move->viewangles, host_client->edict->fields.server->v_angle); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button3) = ((move->buttons >> 2) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button4) = ((move->buttons >> 3) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button5) = ((move->buttons >> 4) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button6) = ((move->buttons >> 5) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button7) = ((move->buttons >> 6) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button8) = ((move->buttons >> 7) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button9) = ((move->buttons >> 11) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button10) = ((move->buttons >> 12) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button11) = ((move->buttons >> 13) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button12) = ((move->buttons >> 14) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button13) = ((move->buttons >> 15) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button14) = ((move->buttons >> 16) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button15) = ((move->buttons >> 17) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.button16) = ((move->buttons >> 18) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.buttonuse) = ((move->buttons >> 8) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.buttonchat) = ((move->buttons >> 9) & 1); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.cursor_active) = ((move->buttons >> 10) & 1); - VectorSet(PRVM_EDICTFIELDVECTOR(host_client->edict, prog->fieldoffsets.movement), move->forwardmove, move->sidemove, move->upmove); - VectorCopy(move->cursor_screen, PRVM_EDICTFIELDVECTOR(host_client->edict, prog->fieldoffsets.cursor_screen)); - VectorCopy(move->cursor_start, PRVM_EDICTFIELDVECTOR(host_client->edict, prog->fieldoffsets.cursor_trace_start)); - VectorCopy(move->cursor_impact, PRVM_EDICTFIELDVECTOR(host_client->edict, prog->fieldoffsets.cursor_trace_endpos)); - PRVM_EDICTFIELDEDICT(host_client->edict, prog->fieldoffsets.cursor_trace_ent) = PRVM_EDICT_TO_PROG(PRVM_EDICT_NUM(move->cursor_entitynumber)); - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.ping) = host_client->ping * 1000.0; - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.ping_packetloss) = packetloss / (float) NETGRAPH_PACKETS; - PRVM_EDICTFIELDFLOAT(host_client->edict, prog->fieldoffsets.ping_movementloss) = movementloss / (float) NETGRAPH_PACKETS; + PRVM_serveredictfloat(host_client->edict, button3) = ((move->buttons >> 2) & 1); + PRVM_serveredictfloat(host_client->edict, button4) = ((move->buttons >> 3) & 1); + PRVM_serveredictfloat(host_client->edict, button5) = ((move->buttons >> 4) & 1); + PRVM_serveredictfloat(host_client->edict, button6) = ((move->buttons >> 5) & 1); + PRVM_serveredictfloat(host_client->edict, button7) = ((move->buttons >> 6) & 1); + PRVM_serveredictfloat(host_client->edict, button8) = ((move->buttons >> 7) & 1); + PRVM_serveredictfloat(host_client->edict, button9) = ((move->buttons >> 11) & 1); + PRVM_serveredictfloat(host_client->edict, button10) = ((move->buttons >> 12) & 1); + PRVM_serveredictfloat(host_client->edict, button11) = ((move->buttons >> 13) & 1); + PRVM_serveredictfloat(host_client->edict, button12) = ((move->buttons >> 14) & 1); + PRVM_serveredictfloat(host_client->edict, button13) = ((move->buttons >> 15) & 1); + PRVM_serveredictfloat(host_client->edict, button14) = ((move->buttons >> 16) & 1); + PRVM_serveredictfloat(host_client->edict, button15) = ((move->buttons >> 17) & 1); + PRVM_serveredictfloat(host_client->edict, button16) = ((move->buttons >> 18) & 1); + PRVM_serveredictfloat(host_client->edict, buttonuse) = ((move->buttons >> 8) & 1); + PRVM_serveredictfloat(host_client->edict, buttonchat) = ((move->buttons >> 9) & 1); + PRVM_serveredictfloat(host_client->edict, cursor_active) = ((move->buttons >> 10) & 1); + VectorSet(PRVM_serveredictvector(host_client->edict, movement), move->forwardmove, move->sidemove, move->upmove); + VectorCopy(move->cursor_screen, PRVM_serveredictvector(host_client->edict, cursor_screen)); + VectorCopy(move->cursor_start, PRVM_serveredictvector(host_client->edict, cursor_trace_start)); + VectorCopy(move->cursor_impact, PRVM_serveredictvector(host_client->edict, cursor_trace_endpos)); + PRVM_serveredictedict(host_client->edict, cursor_trace_ent) = PRVM_EDICT_TO_PROG(PRVM_EDICT_NUM(move->cursor_entitynumber)); + PRVM_serveredictfloat(host_client->edict, ping) = host_client->ping * 1000.0; + PRVM_serveredictfloat(host_client->edict, ping_packetloss) = packetloss / (float) NETGRAPH_PACKETS; + PRVM_serveredictfloat(host_client->edict, ping_movementloss) = movementloss / (float) NETGRAPH_PACKETS; } void SV_FrameLost(int framenum) diff --git a/svvm_cmds.c b/svvm_cmds.c index b5a83994..f2028c47 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -674,7 +674,7 @@ static trace_t SV_Trace_Toss (prvm_edict_t *tossent, prvm_edict_t *ignore) VectorCopy(tossent->fields.server->angles , original_angles ); VectorCopy(tossent->fields.server->avelocity, original_avelocity); - gravity = PRVM_EDICTFIELDFLOAT(tossent, prog->fieldoffsets.gravity); + gravity = PRVM_serveredictfloat(tossent, gravity); if (!gravity) gravity = 1.0f; gravity *= sv_gravity.value * 0.025; @@ -1742,7 +1742,7 @@ static void VM_SV_setcolor (void) client = svs.clients + entnum-1; if (client->edict) { - PRVM_EDICTFIELDFLOAT(client->edict, prog->fieldoffsets.clientcolors) = i; + PRVM_serveredictfloat(client->edict, clientcolors) = i; client->edict->fields.server->team = (i & 15) + 1; } client->colors = i; @@ -2324,8 +2324,8 @@ static void VM_SV_setattachment (void) Con_DPrintf("setattachment(edict %i, edict %i, string \"%s\"): tried to find tag named \"%s\" on entity %i but it has no model\n", PRVM_NUM_FOR_EDICT(e), PRVM_NUM_FOR_EDICT(tagentity), tagname, tagname, PRVM_NUM_FOR_EDICT(tagentity)); } - PRVM_EDICTFIELDEDICT(e, prog->fieldoffsets.tag_entity) = PRVM_EDICT_TO_PROG(tagentity); - PRVM_EDICTFIELDFLOAT(e, prog->fieldoffsets.tag_index) = tagindex; + PRVM_serveredictedict(e, tag_entity) = PRVM_EDICT_TO_PROG(tagentity); + PRVM_serveredictfloat(e, tag_index) = tagindex; } ///////////////////////////////////////// @@ -2369,7 +2369,7 @@ void SV_GetEntityMatrix (prvm_edict_t *ent, matrix4x4_t *out, qboolean viewmatri float scale; float pitchsign = 1; - scale = PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.scale); + scale = PRVM_serveredictfloat(ent, scale); if (!scale) scale = 1.0f; @@ -2446,10 +2446,10 @@ int SV_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex) Matrix4x4_Concat(&tagmatrix, &attachmatrix, out); Matrix4x4_Concat(out, &entitymatrix, &tagmatrix); // next iteration we process the parent entity - if (PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.tag_entity)) + if (PRVM_serveredictedict(ent, tag_entity)) { - tagindex = (int)PRVM_EDICTFIELDFLOAT(ent, prog->fieldoffsets.tag_index); - ent = PRVM_EDICT_NUM(PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.tag_entity)); + tagindex = (int)PRVM_serveredictfloat(ent, tag_index); + ent = PRVM_EDICT_NUM(PRVM_serveredictedict(ent, tag_entity)); } else break; @@ -2457,10 +2457,10 @@ int SV_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex) } // RENDER_VIEWMODEL magic - if (PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.viewmodelforclient)) + if (PRVM_serveredictedict(ent, viewmodelforclient)) { Matrix4x4_Copy(&tagmatrix, out); - ent = PRVM_EDICT_NUM(PRVM_EDICTFIELDEDICT(ent, prog->fieldoffsets.viewmodelforclient)); + ent = PRVM_EDICT_NUM(PRVM_serveredictedict(ent, viewmodelforclient)); SV_GetEntityMatrix(ent, &entitymatrix, true); Matrix4x4_Concat(out, &entitymatrix, &tagmatrix); @@ -2556,12 +2556,12 @@ static void VM_SV_gettaginfo (void) SV_GetExtendedTagInfo(e, tagindex, &parentindex, &tagname, &tag_localmatrix); Matrix4x4_ToVectors(&tag_localmatrix, fo, le, up, trans); - PRVM_GLOBALFIELDFLOAT(prog->globaloffsets.gettaginfo_parent) = parentindex; - PRVM_GLOBALFIELDSTRING(prog->globaloffsets.gettaginfo_name) = tagname ? PRVM_SetTempString(tagname) : 0; - VectorCopy(trans, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.gettaginfo_offset)); - VectorCopy(fo, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.gettaginfo_forward)); - VectorScale(le, -1, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.gettaginfo_right)); - VectorCopy(up, PRVM_GLOBALFIELDVECTOR(prog->globaloffsets.gettaginfo_up)); + PRVM_serverglobalfloat(gettaginfo_parent) = parentindex; + PRVM_serverglobalstring(gettaginfo_name) = tagname ? PRVM_SetTempString(tagname) : 0; + VectorCopy(trans, PRVM_serverglobalvector(gettaginfo_offset)); + VectorCopy(fo, PRVM_serverglobalvector(gettaginfo_forward)); + VectorScale(le, -1, PRVM_serverglobalvector(gettaginfo_right)); + VectorCopy(up, PRVM_serverglobalvector(gettaginfo_up)); switch(returncode) { diff --git a/world.c b/world.c index e914f381..eadb9895 100644 --- a/world.c +++ b/world.c @@ -1755,10 +1755,10 @@ static void World_Physics_Frame_BodyToEntity(world_t *world, prvm_edict_t *ed) int jointtype; if (!body) return; - movetype = (int)PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.movetype); + movetype = (int)PRVM_gameedictfloat(ed, movetype); if (movetype != MOVETYPE_PHYSICS) { - jointtype = (int)PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.jointtype); + jointtype = (int)PRVM_gameedictfloat(ed, jointtype); switch(jointtype) { // TODO feed back data from physics @@ -1815,14 +1815,14 @@ static void World_Physics_Frame_BodyToEntity(world_t *world, prvm_edict_t *ed) avelocity[PITCH] *= pitchsign; } - VectorCopy(origin, PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.origin)); - VectorCopy(velocity, PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.velocity)); - //VectorCopy(forward, PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.axis_forward)); - //VectorCopy(left, PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.axis_left)); - //VectorCopy(up, PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.axis_up)); - //VectorCopy(spinvelocity, PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.spinvelocity)); - VectorCopy(angles, PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.angles)); - VectorCopy(avelocity, PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.avelocity)); + VectorCopy(origin, PRVM_gameedictvector(ed, origin)); + VectorCopy(velocity, PRVM_gameedictvector(ed, velocity)); + //VectorCopy(forward, PRVM_gameedictvector(ed, axis_forward)); + //VectorCopy(left, PRVM_gameedictvector(ed, axis_left)); + //VectorCopy(up, PRVM_gameedictvector(ed, axis_up)); + //VectorCopy(spinvelocity, PRVM_gameedictvector(ed, spinvelocity)); + VectorCopy(angles, PRVM_gameedictvector(ed, angles)); + VectorCopy(avelocity, PRVM_gameedictvector(ed, avelocity)); // values for BodyFromEntity to check if the qc modified anything later VectorCopy(origin, ed->priv.server->ode_origin); @@ -1852,14 +1852,14 @@ static void World_Physics_Frame_JointFromEntity(world_t *world, prvm_edict_t *ed VectorClear(velocity); VectorClear(angles); VectorClear(movedir); - movetype = (int)PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.movetype); - jointtype = (int)PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.jointtype); - enemy = PRVM_EDICTFIELDEDICT(ed, prog->fieldoffsets.enemy); - aiment = PRVM_EDICTFIELDEDICT(ed, prog->fieldoffsets.aiment); - VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.origin), origin); - VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.velocity), velocity); - VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.angles), angles); - VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.movedir), movedir); + movetype = (int)PRVM_gameedictfloat(ed, movetype); + jointtype = (int)PRVM_gameedictfloat(ed, jointtype); + enemy = PRVM_gameedictedict(ed, enemy); + aiment = PRVM_gameedictedict(ed, aiment); + VectorCopy(PRVM_gameedictvector(ed, origin), origin); + VectorCopy(PRVM_gameedictvector(ed, velocity), velocity); + VectorCopy(PRVM_gameedictvector(ed, angles), angles); + VectorCopy(PRVM_gameedictvector(ed, movedir), movedir); if(movetype == MOVETYPE_PHYSICS) jointtype = 0; // can't have both if(enemy <= 0 || enemy >= prog->num_edicts || prog->edicts[enemy].priv.required->free || prog->edicts[enemy].priv.server->ode_body == 0) @@ -2070,9 +2070,9 @@ static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed) #endif VectorClear(entmins); VectorClear(entmaxs); - solid = (int)PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.solid); - movetype = (int)PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.movetype); - scale = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.scale);if (!scale) scale = 1.0f; + solid = (int)PRVM_gameedictfloat(ed, solid); + movetype = (int)PRVM_gameedictfloat(ed, movetype); + scale = PRVM_gameedictfloat(ed, scale);if (!scale) scale = 1.0f; modelindex = 0; if (world == &sv.world) mempool = sv_mempool; @@ -2084,7 +2084,7 @@ static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed) switch(solid) { case SOLID_BSP: - modelindex = (int)PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.modelindex); + modelindex = (int)PRVM_gameedictfloat(ed, modelindex); if (world == &sv.world) model = SV_GetModelByIndex(modelindex); else if (world == &cl.world) @@ -2095,7 +2095,7 @@ static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed) { VectorScale(model->normalmins, scale, entmins); VectorScale(model->normalmaxs, scale, entmaxs); - massval = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.mass); + massval = PRVM_gameedictfloat(ed, mass); } else { @@ -2109,9 +2109,9 @@ static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed) case SOLID_PHYSICS_BOX: case SOLID_PHYSICS_SPHERE: case SOLID_PHYSICS_CAPSULE: - VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.mins), entmins); - VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.maxs), entmaxs); - massval = PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.mass); + VectorCopy(PRVM_gameedictvector(ed, mins), entmins); + VectorCopy(PRVM_gameedictvector(ed, maxs), entmaxs); + massval = PRVM_gameedictfloat(ed, mass); break; default: if (ed->priv.server->ode_physics) @@ -2151,7 +2151,7 @@ static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed) if (massval * geomsize[0] * geomsize[1] * geomsize[2] == 0) { if (movetype == MOVETYPE_PHYSICS) - Con_Printf("entity %i (classname %s) .mass * .size_x * .size_y * .size_z == 0\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDSTRING(ed, prog->fieldoffsets.classname))); + Con_Printf("entity %i (classname %s) .mass * .size_x * .size_y * .size_z == 0\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_gameedictstring(ed, classname))); massval = 1.0f; VectorSet(geomsize, 1.0f, 1.0f, 1.0f); } @@ -2162,7 +2162,7 @@ static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed) ed->priv.server->ode_offsetmatrix = identitymatrix; if (!model) { - Con_Printf("entity %i (classname %s) has no model\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDSTRING(ed, prog->fieldoffsets.classname))); + Con_Printf("entity %i (classname %s) has no model\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_gameedictstring(ed, classname))); goto treatasbox; } // add an optimized mesh to the model containing only the SUPERCONTENTS_SOLID surfaces @@ -2170,7 +2170,7 @@ static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed) Mod_CreateCollisionMesh(model); if (!model->brush.collisionmesh || !model->brush.collisionmesh->numtriangles) { - Con_Printf("entity %i (classname %s) has no geometry\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDSTRING(ed, prog->fieldoffsets.classname))); + Con_Printf("entity %i (classname %s) has no geometry\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_gameedictstring(ed, classname))); goto treatasbox; } // ODE requires persistent mesh storage, so we need to copy out @@ -2288,15 +2288,15 @@ treatasbox: VectorClear(angles); VectorClear(avelocity); gravity = true; - VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.origin), origin); - VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.velocity), velocity); - //VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.axis_forward), forward); - //VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.axis_left), left); - //VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.axis_up), up); - //VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.spinvelocity), spinvelocity); - VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.angles), angles); - VectorCopy(PRVM_EDICTFIELDVECTOR(ed, prog->fieldoffsets.avelocity), avelocity); - if (PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.gravity) != 0.0f && PRVM_EDICTFIELDFLOAT(ed, prog->fieldoffsets.gravity) < 0.5f) gravity = false; + VectorCopy(PRVM_gameedictvector(ed, origin), origin); + VectorCopy(PRVM_gameedictvector(ed, velocity), velocity); + //VectorCopy(PRVM_gameedictvector(ed, axis_forward), forward); + //VectorCopy(PRVM_gameedictvector(ed, axis_left), left); + //VectorCopy(PRVM_gameedictvector(ed, axis_up), up); + //VectorCopy(PRVM_gameedictvector(ed, spinvelocity), spinvelocity); + VectorCopy(PRVM_gameedictvector(ed, angles), angles); + VectorCopy(PRVM_gameedictvector(ed, avelocity), avelocity); + if (PRVM_gameedictfloat(ed, gravity) != 0.0f && PRVM_EDICTFIELDFLOAT(ed, gravity) < 0.5f) gravity = false; if (ed == prog->edicts) gravity = false; @@ -2346,9 +2346,9 @@ treatasbox: if (IS_NAN(test)) { modified = true; - //Con_Printf("Fixing NAN values on entity %i : .classname = \"%s\" .origin = '%f %f %f' .velocity = '%f %f %f' .axis_forward = '%f %f %f' .axis_left = '%f %f %f' .axis_up = %f %f %f' .spinvelocity = '%f %f %f'\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDSTRING(ed, prog->fieldoffsets.classname)), origin[0], origin[1], origin[2], velocity[0], velocity[1], velocity[2], forward[0], forward[1], forward[2], left[0], left[1], left[2], up[0], up[1], up[2], spinvelocity[0], spinvelocity[1], spinvelocity[2]); + //Con_Printf("Fixing NAN values on entity %i : .classname = \"%s\" .origin = '%f %f %f' .velocity = '%f %f %f' .axis_forward = '%f %f %f' .axis_left = '%f %f %f' .axis_up = %f %f %f' .spinvelocity = '%f %f %f'\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_gameedictstring(ed, classname)), origin[0], origin[1], origin[2], velocity[0], velocity[1], velocity[2], forward[0], forward[1], forward[2], left[0], left[1], left[2], up[0], up[1], up[2], spinvelocity[0], spinvelocity[1], spinvelocity[2]); if (physics_ode_trick_fixnan.integer >= 2) - Con_Printf("Fixing NAN values on entity %i : .classname = \"%s\" .origin = '%f %f %f' .velocity = '%f %f %f' .angles = '%f %f %f' .avelocity = '%f %f %f'\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDSTRING(ed, prog->fieldoffsets.classname)), origin[0], origin[1], origin[2], velocity[0], velocity[1], velocity[2], angles[0], angles[1], angles[2], avelocity[0], avelocity[1], avelocity[2]); + Con_Printf("Fixing NAN values on entity %i : .classname = \"%s\" .origin = '%f %f %f' .velocity = '%f %f %f' .angles = '%f %f %f' .avelocity = '%f %f %f'\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_gameedictstring(ed, classname)), origin[0], origin[1], origin[2], velocity[0], velocity[1], velocity[2], angles[0], angles[1], angles[2], avelocity[0], avelocity[1], avelocity[2]); test = VectorLength2(origin); if (IS_NAN(test)) VectorClear(origin); @@ -2534,8 +2534,8 @@ static void nearCallback (void *data, dGeomID o1, dGeomID o2) ed1 = NULL; if(ed1) { - bouncefactor1 = PRVM_EDICTFIELDFLOAT(ed1, prog->fieldoffsets.bouncefactor); - bouncestop1 = PRVM_EDICTFIELDFLOAT(ed1, prog->fieldoffsets.bouncestop); + bouncefactor1 = PRVM_gameedictfloat(ed1, bouncefactor); + bouncestop1 = PRVM_gameedictfloat(ed1, bouncestop); if (!bouncestop1) bouncestop1 = 60.0f / 800.0f; } @@ -2545,8 +2545,8 @@ static void nearCallback (void *data, dGeomID o1, dGeomID o2) ed2 = NULL; if(ed2) { - bouncefactor2 = PRVM_EDICTFIELDFLOAT(ed2, prog->fieldoffsets.bouncefactor); - bouncestop2 = PRVM_EDICTFIELDFLOAT(ed2, prog->fieldoffsets.bouncestop); + bouncefactor2 = PRVM_gameedictfloat(ed2, bouncefactor); + bouncestop2 = PRVM_gameedictfloat(ed2, bouncestop); if (!bouncestop2) bouncestop2 = 60.0f / 800.0f; } -- 2.39.2