float maxfrac, maxrealfrac;
int n;
entity_render_t *ent;
- float tracemins[3], tracemaxs[3];
+ vec_t tracemins[3], tracemaxs[3];
trace_t trace;
- float tempnormal[3], starttransformed[3], endtransformed[3];
+ vec_t tempnormal[3], starttransformed[3], endtransformed[3];
#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
vec3_t end;
vec_t len = 0;
VectorCopy(mins, PRVM_clientedictvector(ent, absmin));
VectorCopy(maxs, PRVM_clientedictvector(ent, absmax));
- World_LinkEdict(&cl.world, ent, PRVM_clientedictvector(ent, absmin), PRVM_clientedictvector(ent, absmax));
+ World_LinkEdict(&cl.world, ent, mins, maxs);
}
int CL_GenericHitSuperContentsMask(const prvm_edict_t *passedict)
int passedictprog;
prvm_edict_t *traceowner, *touch;
trace_t trace;
+ // temporary storage because prvm_vec_t may need conversion
+ vec3_t touchmins, touchmaxs;
// bounding box of entire move area
vec3_t clipboxmins, clipboxmaxs;
// size when clipping against monsters
else
Matrix4x4_CreateTranslate(&matrix, PRVM_clientedictvector(touch, origin)[0], PRVM_clientedictvector(touch, origin)[1], PRVM_clientedictvector(touch, origin)[2]);
Matrix4x4_Invert_Simple(&imatrix, &matrix);
+ VectorCopy(PRVM_clientedictvector(touch, mins), touchmins);
+ VectorCopy(PRVM_clientedictvector(touch, maxs), touchmaxs);
if ((int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER)
- Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipstart, hitsupercontentsmask);
+ Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipstart, hitsupercontentsmask);
else
- Collision_ClipPointToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, hitsupercontentsmask);
+ Collision_ClipPointToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, hitsupercontentsmask);
if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
*hitnetworkentity = 0;
int passedictprog;
prvm_edict_t *traceowner, *touch;
trace_t trace;
+ // temporary storage because prvm_vec_t may need conversion
+ vec3_t touchmins, touchmaxs;
// bounding box of entire move area
vec3_t clipboxmins, clipboxmaxs;
// size when clipping against monsters
else
Matrix4x4_CreateTranslate(&matrix, PRVM_clientedictvector(touch, origin)[0], PRVM_clientedictvector(touch, origin)[1], PRVM_clientedictvector(touch, origin)[2]);
Matrix4x4_Invert_Simple(&imatrix, &matrix);
+ VectorCopy(PRVM_clientedictvector(touch, mins), touchmins);
+ VectorCopy(PRVM_clientedictvector(touch, maxs), touchmaxs);
if (type == MOVE_MISSILE && (int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER)
- Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
+ Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
else
- Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, hitsurfaces);
+ Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, hitsurfaces);
if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
*hitnetworkentity = 0;
qboolean pointtrace;
prvm_edict_t *traceowner, *touch;
trace_t trace;
+ // temporary storage because prvm_vec_t may need conversion
+ vec3_t touchmins, touchmaxs;
// bounding box of entire move area
vec3_t clipboxmins, clipboxmaxs;
// size of the moving object
else
Matrix4x4_CreateTranslate(&matrix, PRVM_clientedictvector(touch, origin)[0], PRVM_clientedictvector(touch, origin)[1], PRVM_clientedictvector(touch, origin)[2]);
Matrix4x4_Invert_Simple(&imatrix, &matrix);
+ VectorCopy(PRVM_clientedictvector(touch, mins), touchmins);
+ VectorCopy(PRVM_clientedictvector(touch, maxs), touchmaxs);
if ((int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER)
- Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
+ Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
else
- Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask);
+ Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask);
if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
*hitnetworkentity = 0;
const matrix4x4_t *matrix;
matrix4x4_t blendmatrix, tempmatrix, matrix2;
int frame;
- float origin[3], angles[3], lerp;
+ vec_t origin[3], angles[3], lerp;
entity_t *t;
entity_render_t *r;
//entity_persistent_t *p = &e->persistent;
if ((e->state_current.lightpflags & PFLAGS_FULLDYNAMIC) && r_refdef.scene.numlights < MAX_DLIGHTS)
{
matrix4x4_t dlightmatrix;
- float light[4];
+ vec4_t light;
VectorScale(e->state_current.light, (1.0f / 256.0f), light);
light[3] = e->state_current.light[3];
if (light[0] == 0 && light[1] == 0 && light[2] == 0)
void CL_SpawnDecalParticleForPoint(const vec3_t org, float maxdist, float size, float alpha, int texnum, int color1, int color2)
{
int i;
- float bestfrac, bestorg[3], bestnormal[3];
- float org2[3];
+ vec_t bestfrac;
+ vec3_t bestorg;
+ vec3_t bestnormal;
+ vec3_t org2;
int besthitent = 0, hitent;
trace_t trace;
bestfrac = 10;
void CL_EntityParticles (const entity_t *ent)
{
int i;
- float pitch, yaw, dist = 64, beamlength = 16, org[3], v[3];
+ vec_t pitch, yaw, dist = 64, beamlength = 16;
+ vec3_t org, v;
static vec3_t avelocities[NUMVERTEXNORMALS];
if (!cl_particles.integer) return;
if (cl.time <= cl.oldtime) return; // don't spawn new entity particles while paused
void CL_ReadPointFile_f (void)
{
- vec3_t org, leakorg;
+ double org[3], leakorg[3];
+ vec3_t vecorg;
int r, c, s;
char *pointfile = NULL, *pointfilepos, *t, tchar;
char name[MAX_QPATH];
#if _MSC_VER >= 1400
#define sscanf sscanf_s
#endif
- r = sscanf (pointfilepos,"%f %f %f", &org[0], &org[1], &org[2]);
+ r = sscanf (pointfilepos,"%lf %lf %lf", &org[0], &org[1], &org[2]);
+ VectorCopy(org, vecorg);
*t = tchar;
pointfilepos = t;
if (r != 3)
if (cl.num_particles < cl.max_particles - 3)
{
s++;
- CL_NewParticle(org, pt_alphastatic, particlepalette[(-c)&15], particlepalette[(-c)&15], tex_particle, 2, 0, 255, 0, 0, 0, org[0], org[1], org[2], 0, 0, 0, 0, 0, 0, 0, true, 1<<30, 1, PBLEND_ALPHA, PARTICLE_BILLBOARD, -1, -1, -1, 1, 1, 0, 0, NULL);
+ CL_NewParticle(vecorg, pt_alphastatic, particlepalette[(-c)&15], particlepalette[(-c)&15], tex_particle, 2, 0, 255, 0, 0, 0, org[0], org[1], org[2], 0, 0, 0, 0, 0, 0, 0, true, 1<<30, 1, PBLEND_ALPHA, PARTICLE_BILLBOARD, -1, -1, -1, 1, 1, 0, 0, NULL);
}
}
Mem_Free(pointfile);
- VectorCopy(leakorg, org);
- Con_Printf("%i points read (%i particles spawned)\nLeak at %f %f %f\n", c, s, org[0], org[1], org[2]);
+ VectorCopy(leakorg, vecorg);
+ Con_Printf("%i points read (%i particles spawned)\nLeak at %f %f %f\n", c, s, leakorg[0], leakorg[1], leakorg[2]);
- CL_NewParticle(org, pt_beam, 0xFF0000, 0xFF0000, tex_beam, 64, 0, 255, 0, 0, 0, org[0] - 4096, org[1], org[2], org[0] + 4096, org[1], org[2], 0, 0, 0, 0, false, 1<<30, 1, PBLEND_ADD, PARTICLE_HBEAM, -1, -1, -1, 1, 1, 0, 0, NULL);
- CL_NewParticle(org, pt_beam, 0x00FF00, 0x00FF00, tex_beam, 64, 0, 255, 0, 0, 0, org[0], org[1] - 4096, org[2], org[0], org[1] + 4096, org[2], 0, 0, 0, 0, false, 1<<30, 1, PBLEND_ADD, PARTICLE_HBEAM, -1, -1, -1, 1, 1, 0, 0, NULL);
- CL_NewParticle(org, pt_beam, 0x0000FF, 0x0000FF, tex_beam, 64, 0, 255, 0, 0, 0, org[0], org[1], org[2] - 4096, org[0], org[1], org[2] + 4096, 0, 0, 0, 0, false, 1<<30, 1, PBLEND_ADD, PARTICLE_HBEAM, -1, -1, -1, 1, 1, 0, 0, NULL);
+ CL_NewParticle(vecorg, pt_beam, 0xFF0000, 0xFF0000, tex_beam, 64, 0, 255, 0, 0, 0, org[0] - 4096, org[1], org[2], org[0] + 4096, org[1], org[2], 0, 0, 0, 0, false, 1<<30, 1, PBLEND_ADD, PARTICLE_HBEAM, -1, -1, -1, 1, 1, 0, 0, NULL);
+ CL_NewParticle(vecorg, pt_beam, 0x00FF00, 0x00FF00, tex_beam, 64, 0, 255, 0, 0, 0, org[0], org[1] - 4096, org[2], org[0], org[1] + 4096, org[2], 0, 0, 0, 0, false, 1<<30, 1, PBLEND_ADD, PARTICLE_HBEAM, -1, -1, -1, 1, 1, 0, 0, NULL);
+ CL_NewParticle(vecorg, pt_beam, 0x0000FF, 0x0000FF, tex_beam, 64, 0, 255, 0, 0, 0, org[0], org[1], org[2] - 4096, org[0], org[1], org[2] + 4096, 0, 0, 0, 0, false, 1<<30, 1, PBLEND_ADD, PARTICLE_HBEAM, -1, -1, -1, 1, 1, 0, 0, NULL);
}
/*
const decal_t *d;
float *v3f, *t2f, *c4f;
particletexture_t *tex;
- float right[3], up[3], size, ca;
+ vec_t right[3], up[3], size, ca;
float alphascale = (1.0f / 65536.0f) * cl_particles_alpha.value;
RSurf_ActiveWorldEntity();
static void R_DrawParticle_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
{
+ vec3_t vecorg, vecvel, baseright, baseup;
int surfacelistindex;
int batchstart, batchcount;
const particle_t *p;
particletexture_t *tex;
float up2[3], v[3], right[3], up[3], fog, ifog, size, len, lenfactor, alpha;
// float ambient[3], diffuse[3], diffusenormal[3];
- float palpha, spintime, spinrad, spincos, spinsin, spinm1, spinm2, spinm3, spinm4, baseright[3], baseup[3];
+ float palpha, spintime, spinrad, spincos, spinsin, spinm1, spinm2, spinm3, spinm4;
vec4_t colormultiplier;
float minparticledist_start, minparticledist_end;
qboolean dofade;
c4f[3] = alpha;
// note: lighting is not cheap!
if (particletype[p->typeindex].lighting)
- R_LightPoint(c4f, p->org, LP_LIGHTMAP | LP_RTWORLD | LP_DYNLIGHT);
+ {
+ vecorg[0] = p->org[0];
+ vecorg[1] = p->org[1];
+ vecorg[2] = p->org[2];
+ R_LightPoint(c4f, vecorg, LP_LIGHTMAP | LP_RTWORLD | LP_DYNLIGHT);
+ }
// mix in the fog color
if (r_refdef.fogenabled)
{
t2f[6] = tex->s2;t2f[7] = tex->t2;
break;
case PARTICLE_ORIENTED_DOUBLESIDED:
- VectorVectors(p->vel, baseright, baseup);
+ vecvel[0] = p->vel[0];
+ vecvel[1] = p->vel[1];
+ vecvel[2] = p->vel[2];
+ VectorVectors(vecvel, baseright, baseup);
if (p->angle + p->spin)
{
spinrad = (p->angle + p->spin * (spintime - p->delayedspawn)) * (float)(M_PI / 180.0f);
double last_trace_visibility;
// user wavefunc parameters (from csqc)
- float userwavefunc_param[Q3WAVEFUNC_USER_COUNT];
+ vec_t userwavefunc_param[Q3WAVEFUNC_USER_COUNT];
}
entity_render_t;
typedef struct entity_persistent_s
{
- vec3_t trail_origin;
-
- // particle trail
- float trail_time;
+ vec3_t trail_origin; // previous position for particle trail spawning
+ vec3_t oldorigin; // lerp
+ vec3_t oldangles; // lerp
+ vec3_t neworigin; // lerp
+ vec3_t newangles; // lerp
+ vec_t lerpstarttime; // lerp
+ vec_t lerpdeltatime; // lerp
+ float muzzleflash; // muzzleflash intensity, fades over time
+ float trail_time; // residual error accumulation for particle trail spawning (to keep spacing across frames)
qboolean trail_allowed; // set to false by teleports, true by update code, prevents bad lerps
-
- // muzzleflash fading
- float muzzleflash;
-
- // interpolated movement
-
- // start time of move
- float lerpstarttime;
- // time difference from start to end of move
- float lerpdeltatime;
- // the move itself, start and end
- float oldorigin[3];
- float oldangles[3];
- float neworigin[3];
- float newangles[3];
}
entity_persistent_t;
// #1 void(vector ang) makevectors
static void VM_CL_makevectors (prvm_prog_t *prog)
{
+ vec3_t angles, forward, right, up;
VM_SAFEPARMCOUNT(1, VM_CL_makevectors);
- AngleVectors (PRVM_G_VECTOR(OFS_PARM0), PRVM_clientglobalvector(v_forward), PRVM_clientglobalvector(v_right), PRVM_clientglobalvector(v_up));
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), angles);
+ AngleVectors(angles, forward, right, up);
+ VectorCopy(forward, PRVM_clientglobalvector(v_forward));
+ VectorCopy(right, PRVM_clientglobalvector(v_right));
+ VectorCopy(up, PRVM_clientglobalvector(v_up));
}
// #2 void(entity e, vector o) setorigin
static void VM_CL_setorigin (prvm_prog_t *prog)
{
prvm_edict_t *e;
- float *org;
+ prvm_vec_t *org;
VM_SAFEPARMCOUNT(2, VM_CL_setorigin);
e = PRVM_G_EDICT(OFS_PARM0);
CL_LinkEdict(e);
}
-static void SetMinMaxSize (prvm_prog_t *prog, prvm_edict_t *e, float *min, float *max)
+static void SetMinMaxSizePRVM (prvm_prog_t *prog, prvm_edict_t *e, prvm_vec_t *min, prvm_vec_t *max)
{
int i;
CL_LinkEdict (e);
}
+static void SetMinMaxSize (prvm_prog_t *prog, prvm_edict_t *e, const vec_t *min, const vec_t *max)
+{
+ prvm_vec3_t mins, maxs;
+ VectorCopy(min, mins);
+ VectorCopy(max, maxs);
+ SetMinMaxSizePRVM(prog, e, mins, maxs);
+}
+
// #3 void(entity e, string m) setmodel
static void VM_CL_setmodel (prvm_prog_t *prog)
{
if( mod ) {
// TODO: check if this breaks needed consistency and maybe add a cvar for it too?? [1/10/2008 Black]
- //SetMinMaxSize (e, mod->normalmins, mod->normalmaxs);
+ // LordHavoc: erm you broke it by commenting this out - setmodel must do setsize or else the qc can't find out the model size, and ssqc does this by necessity, consistency.
+ SetMinMaxSize (prog, e, mod->normalmins, mod->normalmaxs);
}
else
{
static void VM_CL_setsize (prvm_prog_t *prog)
{
prvm_edict_t *e;
- float *min, *max;
+ vec3_t mins, maxs;
VM_SAFEPARMCOUNT(3, VM_CL_setsize);
e = PRVM_G_EDICT(OFS_PARM0);
VM_Warning(prog, "setsize: can not modify free entity\n");
return;
}
- min = PRVM_G_VECTOR(OFS_PARM1);
- max = PRVM_G_VECTOR(OFS_PARM2);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), mins);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), maxs);
- SetMinMaxSize( prog, e, min, max );
+ SetMinMaxSize( prog, e, mins, maxs );
CL_LinkEdict(e);
}
// #16 void(vector v1, vector v2, float movetype, entity ignore) traceline
static void VM_CL_traceline (prvm_prog_t *prog)
{
- float *v1, *v2;
+ vec3_t v1, v2;
trace_t trace;
int move, svent;
prvm_edict_t *ent;
prog->xfunction->builtinsprofile += 30;
- v1 = PRVM_G_VECTOR(OFS_PARM0);
- v2 = PRVM_G_VECTOR(OFS_PARM1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), v1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), v2);
move = (int)PRVM_G_FLOAT(OFS_PARM2);
ent = PRVM_G_EDICT(OFS_PARM3);
- if (IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || IS_NAN(v2[0]) || IS_NAN(v2[1]) || IS_NAN(v2[2]))
+ if (VEC_IS_NAN(v1[0]) || VEC_IS_NAN(v1[1]) || VEC_IS_NAN(v1[2]) || VEC_IS_NAN(v2[0]) || VEC_IS_NAN(v2[1]) || VEC_IS_NAN(v2[2]))
prog->error_cmd("%s: NAN errors detected in traceline('%f %f %f', '%f %f %f', %i, entity %i)\n", prog->name, v1[0], v1[1], v1[2], v2[0], v2[1], v2[2], move, PRVM_EDICT_TO_PROG(ent));
trace = CL_TraceLine(v1, v2, move, ent, CL_GenericHitSuperContentsMask(ent), CL_HitNetworkBrushModels(move), CL_HitNetworkPlayers(move), &svent, true, false);
// LordHavoc: added this for my own use, VERY useful, similar to traceline
static void VM_CL_tracebox (prvm_prog_t *prog)
{
- float *v1, *v2, *m1, *m2;
+ vec3_t v1, v2, m1, m2;
trace_t trace;
int move, svent;
prvm_edict_t *ent;
prog->xfunction->builtinsprofile += 30;
- v1 = PRVM_G_VECTOR(OFS_PARM0);
- m1 = PRVM_G_VECTOR(OFS_PARM1);
- m2 = PRVM_G_VECTOR(OFS_PARM2);
- v2 = PRVM_G_VECTOR(OFS_PARM3);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), v1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), m1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), m2);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM3), v2);
move = (int)PRVM_G_FLOAT(OFS_PARM4);
ent = PRVM_G_EDICT(OFS_PARM5);
- if (IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || IS_NAN(v2[0]) || IS_NAN(v2[1]) || IS_NAN(v2[2]))
+ if (VEC_IS_NAN(v1[0]) || VEC_IS_NAN(v1[1]) || VEC_IS_NAN(v1[2]) || VEC_IS_NAN(v2[0]) || VEC_IS_NAN(v2[1]) || VEC_IS_NAN(v2[2]))
prog->error_cmd("%s: NAN errors detected in tracebox('%f %f %f', '%f %f %f', '%f %f %f', '%f %f %f', %i, entity %i)\n", prog->name, v1[0], v1[1], v1[2], m1[0], m1[1], m1[2], m2[0], m2[1], m2[2], v2[0], v2[1], v2[2], move, PRVM_EDICT_TO_PROG(ent));
trace = CL_TraceBox(v1, m1, m2, v2, move, ent, CL_GenericHitSuperContentsMask(ent), CL_HitNetworkBrushModels(move), CL_HitNetworkPlayers(move), &svent, true);
{
int i;
float gravity;
- vec3_t move, end;
+ vec3_t start, end, mins, maxs, move;
vec3_t original_origin;
vec3_t original_velocity;
vec3_t original_angles;
VectorMA (PRVM_clientedictvector(tossent, angles), 0.05, PRVM_clientedictvector(tossent, avelocity), PRVM_clientedictvector(tossent, angles));
VectorScale (PRVM_clientedictvector(tossent, velocity), 0.05, move);
VectorAdd (PRVM_clientedictvector(tossent, origin), move, end);
- trace = CL_TraceBox(PRVM_clientedictvector(tossent, origin), PRVM_clientedictvector(tossent, mins), PRVM_clientedictvector(tossent, maxs), end, MOVE_NORMAL, tossent, CL_GenericHitSuperContentsMask(tossent), true, true, NULL, true);
+ VectorCopy(PRVM_clientedictvector(tossent, origin), start);
+ VectorCopy(PRVM_clientedictvector(tossent, mins), mins);
+ VectorCopy(PRVM_clientedictvector(tossent, maxs), maxs);
+ trace = CL_TraceBox(start, mins, maxs, end, MOVE_NORMAL, tossent, CL_GenericHitSuperContentsMask(tossent), true, true, NULL, true);
VectorCopy (trace.endpos, PRVM_clientedictvector(tossent, origin));
if (trace.fraction < 1)
static void VM_CL_droptofloor (prvm_prog_t *prog)
{
prvm_edict_t *ent;
- vec3_t end;
+ vec3_t start, end, mins, maxs;
trace_t trace;
VM_SAFEPARMCOUNTRANGE(0, 2, VM_CL_droptofloor); // allow 2 parameters because the id1 defs.qc had an incorrect prototype
return;
}
- VectorCopy (PRVM_clientedictvector(ent, origin), end);
+ VectorCopy(PRVM_clientedictvector(ent, origin), start);
+ VectorCopy(PRVM_clientedictvector(ent, mins), mins);
+ VectorCopy(PRVM_clientedictvector(ent, maxs), maxs);
+ VectorCopy(PRVM_clientedictvector(ent, origin), end);
end[2] -= 256;
- trace = CL_TraceBox(PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, mins), PRVM_clientedictvector(ent, maxs), end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, NULL, true);
+ trace = CL_TraceBox(start, mins, maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, NULL, true);
if (trace.fraction != 1)
{
// #41 float(vector v) pointcontents
static void VM_CL_pointcontents (prvm_prog_t *prog)
{
+ vec3_t point;
VM_SAFEPARMCOUNT(1, VM_CL_pointcontents);
- PRVM_G_FLOAT(OFS_RETURN) = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, CL_PointSuperContents(PRVM_G_VECTOR(OFS_PARM0)));
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), point);
+ PRVM_G_FLOAT(OFS_RETURN) = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, CL_PointSuperContents(point));
}
// #48 void(vector o, vector d, float color, float count) particle
static void VM_CL_particle (prvm_prog_t *prog)
{
- float *org, *dir;
+ vec3_t org, dir;
int count;
unsigned char color;
VM_SAFEPARMCOUNT(4, VM_CL_particle);
- org = PRVM_G_VECTOR(OFS_PARM0);
- dir = PRVM_G_VECTOR(OFS_PARM1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), dir);
color = (int)PRVM_G_FLOAT(OFS_PARM2);
count = (int)PRVM_G_FLOAT(OFS_PARM3);
CL_ParticleEffect(EFFECT_SVC_PARTICLE, count, org, org, dir, dir, NULL, color);
// #74 void(vector pos, string samp, float vol, float atten) ambientsound
static void VM_CL_ambientsound (prvm_prog_t *prog)
{
- float *f;
+ vec3_t f;
sfx_t *s;
VM_SAFEPARMCOUNT(4, VM_CL_ambientsound);
s = S_FindName(PRVM_G_STRING(OFS_PARM0));
- f = PRVM_G_VECTOR(OFS_PARM1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), f);
S_StaticSound (s, f, PRVM_G_FLOAT(OFS_PARM2), PRVM_G_FLOAT(OFS_PARM3)*64);
}
static void VM_CL_getlight (prvm_prog_t *prog)
{
vec3_t ambientcolor, diffusecolor, diffusenormal;
- vec_t *p;
+ vec3_t p;
VM_SAFEPARMCOUNTRANGE(1, 3, VM_CL_getlight);
- p = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), p);
VectorClear(ambientcolor);
VectorClear(diffusecolor);
VectorClear(diffusenormal);
static void VM_CL_R_SetView (prvm_prog_t *prog)
{
int c;
- float *f;
+ prvm_vec_t *f;
float k;
VM_SAFEPARMCOUNTRANGE(1, 3, VM_CL_R_SetView);
static void VM_CL_R_AddDynamicLight (prvm_prog_t *prog)
{
double t = Sys_DirtyTime();
- vec_t *org;
+ vec3_t org;
float radius = 300;
- vec_t *col;
+ vec3_t col;
int style = -1;
const char *cubemapname = NULL;
int pflags = PFLAGS_CORONA | PFLAGS_FULLDYNAMIC;
if (r_refdef.scene.numlights >= MAX_DLIGHTS)
return;
- org = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
radius = PRVM_G_FLOAT(OFS_PARM1);
- col = PRVM_G_VECTOR(OFS_PARM2);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), col);
if (prog->argc >= 4)
{
style = (int)PRVM_G_FLOAT(OFS_PARM3);
//#310 vector (vector v) cs_unproject (EXT_CSQC)
static void VM_CL_unproject (prvm_prog_t *prog)
{
- float *f;
- vec3_t temp;
+ vec3_t f;
+ vec3_t temp;
+ vec3_t result;
VM_SAFEPARMCOUNT(1, VM_CL_unproject);
- f = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), f);
VectorSet(temp,
f[2],
(-1.0 + 2.0 * (f[0] / vid_conwidth.integer)) * f[2] * -r_refdef.view.frustum_x,
(-1.0 + 2.0 * (f[1] / vid_conheight.integer)) * f[2] * -r_refdef.view.frustum_y);
if(v_flipped.integer)
temp[1] = -temp[1];
- Matrix4x4_Transform(&r_refdef.view.matrix, temp, PRVM_G_VECTOR(OFS_RETURN));
+ Matrix4x4_Transform(&r_refdef.view.matrix, temp, result);
+ VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN));
}
//#311 vector (vector v) cs_project (EXT_CSQC)
static void VM_CL_project (prvm_prog_t *prog)
{
- float *f;
- vec3_t v;
+ vec3_t f;
+ vec3_t v;
matrix4x4_t m;
VM_SAFEPARMCOUNT(1, VM_CL_project);
- f = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), f);
Matrix4x4_Invert_Simple(&m, &r_refdef.view.matrix);
Matrix4x4_Transform(&m, f, v);
if(v_flipped.integer)
static void VM_CL_trailparticles (prvm_prog_t *prog)
{
int i;
- float *start, *end;
+ vec3_t start, end, velocity;
prvm_edict_t *t;
VM_SAFEPARMCOUNTRANGE(4, 5, VM_CL_trailparticles);
t = PRVM_G_EDICT(OFS_PARM0);
i = (int)PRVM_G_FLOAT(OFS_PARM1);
- start = PRVM_G_VECTOR(OFS_PARM2);
- end = PRVM_G_VECTOR(OFS_PARM3);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), start);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM3), end);
+ VectorCopy(PRVM_clientedictvector(t, velocity), velocity);
if (i < 0)
return;
- CL_ParticleEffect(i, 1, start, end, PRVM_clientedictvector(t, velocity), PRVM_clientedictvector(t, velocity), NULL, prog->argc >= 5 ? (int)PRVM_G_FLOAT(OFS_PARM4) : 0);
+ CL_ParticleEffect(i, 1, start, end, velocity, velocity, NULL, prog->argc >= 5 ? (int)PRVM_G_FLOAT(OFS_PARM4) : 0);
}
//#337 void(float effectnum, vector origin, vector dir, float count[, float color]) pointparticles (EXT_CSQC)
{
int i;
float n;
- float *f, *v;
+ vec3_t f, v;
VM_SAFEPARMCOUNTRANGE(4, 5, VM_CL_pointparticles);
i = (int)PRVM_G_FLOAT(OFS_PARM0);
- f = PRVM_G_VECTOR(OFS_PARM1);
- v = PRVM_G_VECTOR(OFS_PARM2);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), f);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), v);
n = PRVM_G_FLOAT(OFS_PARM3);
if (i < 0)
return;
{
int effectnum;
// prvm_edict_t *own;
- float *origin_from, *origin_to, *dir_from, *dir_to;
+ vec3_t origin_from, origin_to, dir_from, dir_to;
float count;
int flags;
float tintmins[4], tintmaxs[4];
effectnum = (int)PRVM_G_FLOAT(OFS_PARM0);
// own = PRVM_G_EDICT(OFS_PARM1); // TODO find use for this
- origin_from = PRVM_G_VECTOR(OFS_PARM2);
- origin_to = PRVM_G_VECTOR(OFS_PARM3);
- dir_from = PRVM_G_VECTOR(OFS_PARM4);
- dir_to = PRVM_G_VECTOR(OFS_PARM5);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), origin_from);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM3), origin_to );
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM4), dir_from );
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM5), dir_to );
count = PRVM_G_FLOAT(OFS_PARM6);
if(prog->argc >= 8)
flags = PRVM_G_FLOAT(OFS_PARM7);
//#351 void(vector origin, vector forward, vector right, vector up) SetListener (EXT_CSQC)
static void VM_CL_setlistener (prvm_prog_t *prog)
{
+ vec3_t origin, forward, left, up;
VM_SAFEPARMCOUNT(4, VM_CL_setlistener);
- Matrix4x4_FromVectors(&cl.csqc_listenermatrix, PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), PRVM_G_VECTOR(OFS_PARM3), PRVM_G_VECTOR(OFS_PARM0));
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), origin);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), forward);
+ VectorNegate(PRVM_G_VECTOR(OFS_PARM2), left);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM3), up);
+ Matrix4x4_FromVectors(&cl.csqc_listenermatrix, forward, left, up, origin);
cl.csqc_usecsqclistener = true; //use csqc listener at this frame
}
renderflags = (int)PRVM_clientedictfloat(ent, renderflags);
if (renderflags & RF_USEAXIS)
{
- vec3_t left;
+ vec3_t forward, left, up, origin;
+ VectorCopy(PRVM_clientglobalvector(v_forward), forward);
VectorNegate(PRVM_clientglobalvector(v_right), left);
- Matrix4x4_FromVectors(&staticent->render.matrix, PRVM_clientglobalvector(v_forward), left, PRVM_clientglobalvector(v_up), PRVM_clientedictvector(ent, origin));
+ VectorCopy(PRVM_clientglobalvector(v_up), up);
+ VectorCopy(PRVM_clientedictvector(ent, origin), origin);
+ Matrix4x4_FromVectors(&staticent->render.matrix, forward, left, up, origin);
Matrix4x4_Scale(&staticent->render.matrix, staticent->render.scale, 1);
}
else
VM_Warning(prog, "copyentity: can not modify free entity\n");
return;
}
- memcpy(out->fields.vp, in->fields.vp, prog->entityfields * 4);
+ memcpy(out->fields.fp, in->fields.fp, prog->entityfields * sizeof(prvm_vec_t));
CL_LinkEdict(out);
}
// #404 void(vector org, string modelname, float startframe, float endframe, float framerate) effect (DP_SV_EFFECT)
static void VM_CL_effect (prvm_prog_t *prog)
{
+ vec3_t org;
VM_SAFEPARMCOUNT(5, VM_CL_effect);
- CL_Effect(PRVM_G_VECTOR(OFS_PARM0), (int)PRVM_G_FLOAT(OFS_PARM1), (int)PRVM_G_FLOAT(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), PRVM_G_FLOAT(OFS_PARM4));
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
+ CL_Effect(org, (int)PRVM_G_FLOAT(OFS_PARM1), (int)PRVM_G_FLOAT(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), PRVM_G_FLOAT(OFS_PARM4));
}
// #405 void(vector org, vector velocity, float howmany) te_blood (DP_TE_BLOOD)
static void VM_CL_te_blood (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, vel, pos2;
VM_SAFEPARMCOUNT(3, VM_CL_te_blood);
if (PRVM_G_FLOAT(OFS_PARM2) < 1)
return;
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), vel);
CL_FindNonSolidLocation(pos, pos2, 4);
- CL_ParticleEffect(EFFECT_TE_BLOOD, PRVM_G_FLOAT(OFS_PARM2), pos2, pos2, PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM1), NULL, 0);
+ CL_ParticleEffect(EFFECT_TE_BLOOD, PRVM_G_FLOAT(OFS_PARM2), pos2, pos2, vel, vel, NULL, 0);
}
// #406 void(vector mincorner, vector maxcorner, float explosionspeed, float howmany) te_bloodshower (DP_TE_BLOODSHOWER)
static void VM_CL_te_bloodshower (prvm_prog_t *prog)
{
vec_t speed;
- vec3_t vel1, vel2;
+ vec3_t mincorner, maxcorner, vel1, vel2;
VM_SAFEPARMCOUNT(4, VM_CL_te_bloodshower);
if (PRVM_G_FLOAT(OFS_PARM3) < 1)
return;
vel2[0] = speed;
vel2[1] = speed;
vel2[2] = speed;
- CL_ParticleEffect(EFFECT_TE_BLOOD, PRVM_G_FLOAT(OFS_PARM3), PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), vel1, vel2, NULL, 0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), mincorner);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), maxcorner);
+ CL_ParticleEffect(EFFECT_TE_BLOOD, PRVM_G_FLOAT(OFS_PARM3), mincorner, maxcorner, vel1, vel2, NULL, 0);
}
// #407 void(vector org, vector color) te_explosionrgb (DP_TE_EXPLOSIONRGB)
static void VM_CL_te_explosionrgb (prvm_prog_t *prog)
{
- float *pos;
+ vec3_t pos;
vec3_t pos2;
matrix4x4_t tempmatrix;
VM_SAFEPARMCOUNT(2, VM_CL_te_explosionrgb);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 10);
CL_ParticleExplosion(pos2);
Matrix4x4_CreateTranslate(&tempmatrix, pos2[0], pos2[1], pos2[2]);
// #408 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color, float gravityflag, float randomveljitter) te_particlecube (DP_TE_PARTICLECUBE)
static void VM_CL_te_particlecube (prvm_prog_t *prog)
{
+ vec3_t mincorner, maxcorner, vel;
VM_SAFEPARMCOUNT(7, VM_CL_te_particlecube);
- CL_ParticleCube(PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4), PRVM_G_FLOAT(OFS_PARM5), PRVM_G_FLOAT(OFS_PARM6));
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), mincorner);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), maxcorner);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), vel);
+ CL_ParticleCube(mincorner, maxcorner, vel, (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4), PRVM_G_FLOAT(OFS_PARM5), PRVM_G_FLOAT(OFS_PARM6));
}
// #409 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlerain (DP_TE_PARTICLERAIN)
static void VM_CL_te_particlerain (prvm_prog_t *prog)
{
+ vec3_t mincorner, maxcorner, vel;
VM_SAFEPARMCOUNT(5, VM_CL_te_particlerain);
- CL_ParticleRain(PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4), 0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), mincorner);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), maxcorner);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), vel);
+ CL_ParticleRain(mincorner, maxcorner, vel, (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4), 0);
}
// #410 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlesnow (DP_TE_PARTICLESNOW)
static void VM_CL_te_particlesnow (prvm_prog_t *prog)
{
+ vec3_t mincorner, maxcorner, vel;
VM_SAFEPARMCOUNT(5, VM_CL_te_particlesnow);
- CL_ParticleRain(PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4), 1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), mincorner);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), maxcorner);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), vel);
+ CL_ParticleRain(mincorner, maxcorner, vel, (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4), 1);
}
// #411 void(vector org, vector vel, float howmany) te_spark
static void VM_CL_te_spark (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2, vel;
VM_SAFEPARMCOUNT(3, VM_CL_te_spark);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), vel);
CL_FindNonSolidLocation(pos, pos2, 4);
- CL_ParticleEffect(EFFECT_TE_SPARK, PRVM_G_FLOAT(OFS_PARM2), pos2, pos2, PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM1), NULL, 0);
+ CL_ParticleEffect(EFFECT_TE_SPARK, PRVM_G_FLOAT(OFS_PARM2), pos2, pos2, vel, vel, NULL, 0);
}
extern cvar_t cl_sound_ric_gunshot;
// #412 void(vector org) te_gunshotquad (DP_QUADEFFECTS1)
static void VM_CL_te_gunshotquad (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
int rnd;
VM_SAFEPARMCOUNT(1, VM_CL_te_gunshotquad);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 4);
CL_ParticleEffect(EFFECT_TE_GUNSHOTQUAD, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
if(cl_sound_ric_gunshot.integer >= 2)
// #413 void(vector org) te_spikequad (DP_QUADEFFECTS1)
static void VM_CL_te_spikequad (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
int rnd;
VM_SAFEPARMCOUNT(1, VM_CL_te_spikequad);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 4);
CL_ParticleEffect(EFFECT_TE_SPIKEQUAD, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
if (rand() % 5) S_StartSound(-1, 0, cl.sfx_tink1, pos2, 1, 1);
// #414 void(vector org) te_superspikequad (DP_QUADEFFECTS1)
static void VM_CL_te_superspikequad (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
int rnd;
VM_SAFEPARMCOUNT(1, VM_CL_te_superspikequad);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 4);
CL_ParticleEffect(EFFECT_TE_SUPERSPIKEQUAD, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
if (rand() % 5) S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
// #415 void(vector org) te_explosionquad (DP_QUADEFFECTS1)
static void VM_CL_te_explosionquad (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
VM_SAFEPARMCOUNT(1, VM_CL_te_explosionquad);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 10);
CL_ParticleEffect(EFFECT_TE_EXPLOSIONQUAD, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
S_StartSound(-1, 0, cl.sfx_r_exp3, pos2, 1, 1);
// #416 void(vector org) te_smallflash (DP_TE_SMALLFLASH)
static void VM_CL_te_smallflash (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
VM_SAFEPARMCOUNT(1, VM_CL_te_smallflash);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 10);
CL_ParticleEffect(EFFECT_TE_SMALLFLASH, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
}
// #417 void(vector org, float radius, float lifetime, vector color) te_customflash (DP_TE_CUSTOMFLASH)
static void VM_CL_te_customflash (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
matrix4x4_t tempmatrix;
VM_SAFEPARMCOUNT(4, VM_CL_te_customflash);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 4);
Matrix4x4_CreateTranslate(&tempmatrix, pos2[0], pos2[1], pos2[2]);
CL_AllocLightFlash(NULL, &tempmatrix, PRVM_G_FLOAT(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM3)[0], PRVM_G_VECTOR(OFS_PARM3)[1], PRVM_G_VECTOR(OFS_PARM3)[2], PRVM_G_FLOAT(OFS_PARM1) / PRVM_G_FLOAT(OFS_PARM2), PRVM_G_FLOAT(OFS_PARM2), 0, -1, true, 1, 0.25, 1, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
// #418 void(vector org) te_gunshot (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_gunshot (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
int rnd;
VM_SAFEPARMCOUNT(1, VM_CL_te_gunshot);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 4);
CL_ParticleEffect(EFFECT_TE_GUNSHOT, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
if(cl_sound_ric_gunshot.integer == 1 || cl_sound_ric_gunshot.integer == 3)
// #419 void(vector org) te_spike (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_spike (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
int rnd;
VM_SAFEPARMCOUNT(1, VM_CL_te_spike);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 4);
CL_ParticleEffect(EFFECT_TE_SPIKE, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
if (rand() % 5) S_StartSound(-1, 0, cl.sfx_tink1, pos2, 1, 1);
// #420 void(vector org) te_superspike (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_superspike (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
int rnd;
VM_SAFEPARMCOUNT(1, VM_CL_te_superspike);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 4);
CL_ParticleEffect(EFFECT_TE_SUPERSPIKE, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
if (rand() % 5) S_StartSound(-1, 0, cl.sfx_tink1, pos2, 1, 1);
// #421 void(vector org) te_explosion (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_explosion (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
VM_SAFEPARMCOUNT(1, VM_CL_te_explosion);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 10);
CL_ParticleEffect(EFFECT_TE_EXPLOSION, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
S_StartSound(-1, 0, cl.sfx_r_exp3, pos2, 1, 1);
// #422 void(vector org) te_tarexplosion (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_tarexplosion (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
VM_SAFEPARMCOUNT(1, VM_CL_te_tarexplosion);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 10);
CL_ParticleEffect(EFFECT_TE_TAREXPLOSION, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
S_StartSound(-1, 0, cl.sfx_r_exp3, pos2, 1, 1);
// #423 void(vector org) te_wizspike (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_wizspike (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
VM_SAFEPARMCOUNT(1, VM_CL_te_wizspike);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 4);
CL_ParticleEffect(EFFECT_TE_WIZSPIKE, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
S_StartSound(-1, 0, cl.sfx_wizhit, pos2, 1, 1);
// #424 void(vector org) te_knightspike (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_knightspike (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
VM_SAFEPARMCOUNT(1, VM_CL_te_knightspike);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 4);
CL_ParticleEffect(EFFECT_TE_KNIGHTSPIKE, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
S_StartSound(-1, 0, cl.sfx_knighthit, pos2, 1, 1);
// #425 void(vector org) te_lavasplash (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_lavasplash (prvm_prog_t *prog)
{
+ vec3_t pos;
VM_SAFEPARMCOUNT(1, VM_CL_te_lavasplash);
- CL_ParticleEffect(EFFECT_TE_LAVASPLASH, 1, PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM0), vec3_origin, vec3_origin, NULL, 0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
+ CL_ParticleEffect(EFFECT_TE_LAVASPLASH, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
}
// #426 void(vector org) te_teleport (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_teleport (prvm_prog_t *prog)
{
+ vec3_t pos;
VM_SAFEPARMCOUNT(1, VM_CL_te_teleport);
- CL_ParticleEffect(EFFECT_TE_TELEPORT, 1, PRVM_G_VECTOR(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM0), vec3_origin, vec3_origin, NULL, 0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
+ CL_ParticleEffect(EFFECT_TE_TELEPORT, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
}
// #427 void(vector org, float colorstart, float colorlength) te_explosion2 (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_explosion2 (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2, color;
+ vec3_t pos, pos2, color;
matrix4x4_t tempmatrix;
int colorStart, colorLength;
unsigned char *tempcolor;
VM_SAFEPARMCOUNT(3, VM_CL_te_explosion2);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
colorStart = (int)PRVM_G_FLOAT(OFS_PARM1);
colorLength = (int)PRVM_G_FLOAT(OFS_PARM2);
CL_FindNonSolidLocation(pos, pos2, 10);
// #428 void(entity own, vector start, vector end) te_lightning1 (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_lightning1 (prvm_prog_t *prog)
{
+ vec3_t start, end;
VM_SAFEPARMCOUNT(3, VM_CL_te_lightning1);
- CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt, true);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), start);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), end);
+ CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), start, end, cl.model_bolt, true);
}
// #429 void(entity own, vector start, vector end) te_lightning2 (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_lightning2 (prvm_prog_t *prog)
{
+ vec3_t start, end;
VM_SAFEPARMCOUNT(3, VM_CL_te_lightning2);
- CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt2, true);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), start);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), end);
+ CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), start, end, cl.model_bolt2, true);
}
// #430 void(entity own, vector start, vector end) te_lightning3 (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_lightning3 (prvm_prog_t *prog)
{
+ vec3_t start, end;
VM_SAFEPARMCOUNT(3, VM_CL_te_lightning3);
- CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt3, false);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), start);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), end);
+ CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), start, end, cl.model_bolt3, false);
}
// #431 void(entity own, vector start, vector end) te_beam (DP_TE_STANDARDEFFECTBUILTINS)
static void VM_CL_te_beam (prvm_prog_t *prog)
{
+ vec3_t start, end;
VM_SAFEPARMCOUNT(3, VM_CL_te_beam);
- CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_beam, false);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), start);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), end);
+ CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), start, end, cl.model_beam, false);
}
// #433 void(vector org) te_plasmaburn (DP_TE_PLASMABURN)
static void VM_CL_te_plasmaburn (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2;
VM_SAFEPARMCOUNT(1, VM_CL_te_plasmaburn);
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
CL_FindNonSolidLocation(pos, pos2, 4);
CL_ParticleEffect(EFFECT_TE_PLASMABURN, 1, pos2, pos2, vec3_origin, vec3_origin, NULL, 0);
}
// #457 void(vector org, vector velocity, float howmany) te_flamejet (DP_TE_FLAMEJET)
static void VM_CL_te_flamejet (prvm_prog_t *prog)
{
- float *pos;
- vec3_t pos2;
+ vec3_t pos, pos2, vel;
VM_SAFEPARMCOUNT(3, VM_CL_te_flamejet);
if (PRVM_G_FLOAT(OFS_PARM2) < 1)
return;
- pos = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), vel);
CL_FindNonSolidLocation(pos, pos2, 4);
- CL_ParticleEffect(EFFECT_TE_FLAMEJET, PRVM_G_FLOAT(OFS_PARM2), pos2, pos2, PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM1), NULL, 0);
+ CL_ParticleEffect(EFFECT_TE_FLAMEJET, PRVM_G_FLOAT(OFS_PARM2), pos2, pos2, vel, vel, NULL, 0);
}
int parentindex;
const char *tagname;
int returncode;
- vec3_t fo, le, up, trans;
+ vec3_t forward, left, up, origin;
const dp_model_t *model;
VM_SAFEPARMCOUNT(2, VM_CL_gettaginfo);
e = PRVM_G_EDICT(OFS_PARM0);
tagindex = (int)PRVM_G_FLOAT(OFS_PARM1);
returncode = CL_GetTagMatrix(prog, &tag_matrix, e, tagindex);
- Matrix4x4_ToVectors(&tag_matrix, PRVM_clientglobalvector(v_forward), le, PRVM_clientglobalvector(v_up), PRVM_G_VECTOR(OFS_RETURN));
- VectorScale(le, -1, PRVM_clientglobalvector(v_right));
+ Matrix4x4_ToVectors(&tag_matrix, forward, left, up, origin);
+ VectorCopy(forward, PRVM_clientglobalvector(v_forward));
+ VectorScale(left, -1, PRVM_clientglobalvector(v_right));
+ VectorCopy(up, PRVM_clientglobalvector(v_up));
+ VectorCopy(origin, PRVM_G_VECTOR(OFS_RETURN));
model = CL_GetModelFromEdict(e);
VM_GenerateFrameGroupBlend(prog, e->priv.server->framegroupblend, e);
VM_FrameBlendFromFrameGroupBlend(e->priv.server->frameblend, e->priv.server->framegroupblend, model, cl.time);
VM_UpdateEdictSkeleton(prog, e, model, e->priv.server->frameblend);
CL_GetExtendedTagInfo(prog, e, tagindex, &parentindex, &tagname, &tag_localmatrix);
- Matrix4x4_ToVectors(&tag_localmatrix, fo, le, up, trans);
+ Matrix4x4_ToVectors(&tag_localmatrix, forward, left, up, origin);
PRVM_clientglobalfloat(gettaginfo_parent) = parentindex;
PRVM_clientglobalstring(gettaginfo_name) = tagname ? PRVM_SetTempString(prog, tagname) : 0;
- VectorCopy(trans, PRVM_clientglobalvector(gettaginfo_offset));
- VectorCopy(fo, PRVM_clientglobalvector(gettaginfo_forward));
- VectorScale(le, -1, PRVM_clientglobalvector(gettaginfo_right));
+ VectorCopy(forward, PRVM_clientglobalvector(gettaginfo_forward));
+ VectorScale(left, -1, PRVM_clientglobalvector(gettaginfo_right));
VectorCopy(up, PRVM_clientglobalvector(gettaginfo_up));
+ VectorCopy(origin, PRVM_clientglobalvector(gettaginfo_offset));
switch(returncode)
{
qboolean verified;
vmparticletheme_t *themes;
int max_themes;
- // global addresses
- float *particle_type;
- float *particle_blendmode;
- float *particle_orientation;
- float *particle_color1;
- float *particle_color2;
- float *particle_tex;
- float *particle_size;
- float *particle_sizeincrease;
- float *particle_alpha;
- float *particle_alphafade;
- float *particle_time;
- float *particle_gravity;
- float *particle_bounce;
- float *particle_airfriction;
- float *particle_liquidfriction;
- float *particle_originjitter;
- float *particle_velocityjitter;
- float *particle_qualityreduction;
- float *particle_stretch;
- float *particle_staincolor1;
- float *particle_staincolor2;
- float *particle_stainalpha;
- float *particle_stainsize;
- float *particle_staintex;
- float *particle_delayspawn;
- float *particle_delaycollision;
- float *particle_angle;
- float *particle_spin;
}vmparticlespawner_t;
vmparticlespawner_t vmpartspawner;
vmpartspawner.max_themes = maxthemes;
vmpartspawner.initialized = true;
vmpartspawner.verified = true;
- // get field addresses for fast querying (we can do 1000 calls of spawnparticle in a frame)
- 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
}
// reset particle theme to default values
}
// particle theme -> QC globals
-static void VM_CL_ParticleThemeToGlobals(vmparticletheme_t *theme)
-{
- *vmpartspawner.particle_type = theme->typeindex;
- *vmpartspawner.particle_blendmode = theme->blendmode;
- *vmpartspawner.particle_orientation = theme->orientation;
- vmpartspawner.particle_color1[0] = (theme->color1 >> 16) & 0xFF; // VorteX: int only can store 0-255, not 0-256 which means 0 - 0,99609375...
- vmpartspawner.particle_color1[1] = (theme->color1 >> 8) & 0xFF;
- vmpartspawner.particle_color1[2] = (theme->color1 >> 0) & 0xFF;
- vmpartspawner.particle_color2[0] = (theme->color2 >> 16) & 0xFF;
- vmpartspawner.particle_color2[1] = (theme->color2 >> 8) & 0xFF;
- vmpartspawner.particle_color2[2] = (theme->color2 >> 0) & 0xFF;
- *vmpartspawner.particle_tex = (float)theme->tex;
- *vmpartspawner.particle_size = theme->size;
- *vmpartspawner.particle_sizeincrease = theme->sizeincrease;
- *vmpartspawner.particle_alpha = theme->alpha/256;
- *vmpartspawner.particle_alphafade = theme->alphafade/256;
- *vmpartspawner.particle_time = theme->lifetime;
- *vmpartspawner.particle_gravity = theme->gravity;
- *vmpartspawner.particle_bounce = theme->bounce;
- *vmpartspawner.particle_airfriction = theme->airfriction;
- *vmpartspawner.particle_liquidfriction = theme->liquidfriction;
- *vmpartspawner.particle_originjitter = theme->originjitter;
- *vmpartspawner.particle_velocityjitter = theme->velocityjitter;
- *vmpartspawner.particle_qualityreduction = theme->qualityreduction;
- *vmpartspawner.particle_stretch = theme->stretch;
- vmpartspawner.particle_staincolor1[0] = ((int)theme->staincolor1 >> 16) & 0xFF;
- vmpartspawner.particle_staincolor1[1] = ((int)theme->staincolor1 >> 8) & 0xFF;
- vmpartspawner.particle_staincolor1[2] = ((int)theme->staincolor1 >> 0) & 0xFF;
- vmpartspawner.particle_staincolor2[0] = ((int)theme->staincolor2 >> 16) & 0xFF;
- vmpartspawner.particle_staincolor2[1] = ((int)theme->staincolor2 >> 8) & 0xFF;
- vmpartspawner.particle_staincolor2[2] = ((int)theme->staincolor2 >> 0) & 0xFF;
- *vmpartspawner.particle_staintex = (float)theme->staintex;
- *vmpartspawner.particle_stainalpha = (float)theme->stainalpha/256;
- *vmpartspawner.particle_stainsize = (float)theme->stainsize;
- *vmpartspawner.particle_delayspawn = theme->delayspawn;
- *vmpartspawner.particle_delaycollision = theme->delaycollision;
- *vmpartspawner.particle_angle = theme->angle;
- *vmpartspawner.particle_spin = theme->spin;
+static void VM_CL_ParticleThemeToGlobals(vmparticletheme_t *theme, prvm_prog_t *prog)
+{
+ PRVM_clientglobalfloat(particle_type) = theme->typeindex;
+ PRVM_clientglobalfloat(particle_blendmode) = theme->blendmode;
+ PRVM_clientglobalfloat(particle_orientation) = theme->orientation;
+ // VorteX: int only can store 0-255, not 0-256 which means 0 - 0,99609375...
+ VectorSet(PRVM_clientglobalvector(particle_color1), (theme->color1 >> 16) & 0xFF, (theme->color1 >> 8) & 0xFF, (theme->color1 >> 0) & 0xFF);
+ VectorSet(PRVM_clientglobalvector(particle_color2), (theme->color2 >> 16) & 0xFF, (theme->color2 >> 8) & 0xFF, (theme->color2 >> 0) & 0xFF);
+ PRVM_clientglobalfloat(particle_tex) = (float)theme->tex;
+ PRVM_clientglobalfloat(particle_size) = theme->size;
+ PRVM_clientglobalfloat(particle_sizeincrease) = theme->sizeincrease;
+ PRVM_clientglobalfloat(particle_alpha) = theme->alpha/256;
+ PRVM_clientglobalfloat(particle_alphafade) = theme->alphafade/256;
+ PRVM_clientglobalfloat(particle_time) = theme->lifetime;
+ PRVM_clientglobalfloat(particle_gravity) = theme->gravity;
+ PRVM_clientglobalfloat(particle_bounce) = theme->bounce;
+ PRVM_clientglobalfloat(particle_airfriction) = theme->airfriction;
+ PRVM_clientglobalfloat(particle_liquidfriction) = theme->liquidfriction;
+ PRVM_clientglobalfloat(particle_originjitter) = theme->originjitter;
+ PRVM_clientglobalfloat(particle_velocityjitter) = theme->velocityjitter;
+ PRVM_clientglobalfloat(particle_qualityreduction) = theme->qualityreduction;
+ PRVM_clientglobalfloat(particle_stretch) = theme->stretch;
+ VectorSet(PRVM_clientglobalvector(particle_staincolor1), ((int)theme->staincolor1 >> 16) & 0xFF, ((int)theme->staincolor1 >> 8) & 0xFF, ((int)theme->staincolor1 >> 0) & 0xFF);
+ VectorSet(PRVM_clientglobalvector(particle_staincolor2), ((int)theme->staincolor2 >> 16) & 0xFF, ((int)theme->staincolor2 >> 8) & 0xFF, ((int)theme->staincolor2 >> 0) & 0xFF);
+ PRVM_clientglobalfloat(particle_staintex) = (float)theme->staintex;
+ PRVM_clientglobalfloat(particle_stainalpha) = (float)theme->stainalpha/256;
+ PRVM_clientglobalfloat(particle_stainsize) = (float)theme->stainsize;
+ PRVM_clientglobalfloat(particle_delayspawn) = theme->delayspawn;
+ PRVM_clientglobalfloat(particle_delaycollision) = theme->delaycollision;
+ PRVM_clientglobalfloat(particle_angle) = theme->angle;
+ PRVM_clientglobalfloat(particle_spin) = theme->spin;
}
// QC globals -> particle theme
-static void VM_CL_ParticleThemeFromGlobals(vmparticletheme_t *theme)
-{
- theme->typeindex = (unsigned short)*vmpartspawner.particle_type;
- theme->blendmode = (pblend_t)(int)*vmpartspawner.particle_blendmode;
- theme->orientation = (porientation_t)(int)*vmpartspawner.particle_orientation;
- theme->color1 = ((int)vmpartspawner.particle_color1[0] << 16) + ((int)vmpartspawner.particle_color1[1] << 8) + ((int)vmpartspawner.particle_color1[2]);
- theme->color2 = ((int)vmpartspawner.particle_color2[0] << 16) + ((int)vmpartspawner.particle_color2[1] << 8) + ((int)vmpartspawner.particle_color2[2]);
- theme->tex = (int)*vmpartspawner.particle_tex;
- theme->size = *vmpartspawner.particle_size;
- theme->sizeincrease = *vmpartspawner.particle_sizeincrease;
- theme->alpha = *vmpartspawner.particle_alpha*256;
- theme->alphafade = *vmpartspawner.particle_alphafade*256;
- theme->lifetime = *vmpartspawner.particle_time;
- theme->gravity = *vmpartspawner.particle_gravity;
- theme->bounce = *vmpartspawner.particle_bounce;
- theme->airfriction = *vmpartspawner.particle_airfriction;
- theme->liquidfriction = *vmpartspawner.particle_liquidfriction;
- theme->originjitter = *vmpartspawner.particle_originjitter;
- theme->velocityjitter = *vmpartspawner.particle_velocityjitter;
- theme->qualityreduction = (*vmpartspawner.particle_qualityreduction) ? true : false;
- theme->stretch = *vmpartspawner.particle_stretch;
- theme->staincolor1 = ((int)vmpartspawner.particle_staincolor1[0])*65536 + (int)(vmpartspawner.particle_staincolor1[1])*256 + (int)(vmpartspawner.particle_staincolor1[2]);
- theme->staincolor2 = (int)(vmpartspawner.particle_staincolor2[0])*65536 + (int)(vmpartspawner.particle_staincolor2[1])*256 + (int)(vmpartspawner.particle_staincolor2[2]);
- theme->staintex =(int)*vmpartspawner.particle_staintex;
- theme->stainalpha = *vmpartspawner.particle_stainalpha*256;
- theme->stainsize = *vmpartspawner.particle_stainsize;
- theme->delayspawn = *vmpartspawner.particle_delayspawn;
- theme->delaycollision = *vmpartspawner.particle_delaycollision;
- theme->angle = *vmpartspawner.particle_angle;
- theme->spin = *vmpartspawner.particle_spin;
+static void VM_CL_ParticleThemeFromGlobals(vmparticletheme_t *theme, prvm_prog_t *prog)
+{
+ theme->typeindex = (unsigned short)PRVM_clientglobalfloat(particle_type);
+ theme->blendmode = (pblend_t)(int)PRVM_clientglobalfloat(particle_blendmode);
+ theme->orientation = (porientation_t)(int)PRVM_clientglobalfloat(particle_orientation);
+ theme->color1 = ((int)PRVM_clientglobalvector(particle_color1)[0] << 16) + ((int)PRVM_clientglobalvector(particle_color1)[1] << 8) + ((int)PRVM_clientglobalvector(particle_color1)[2]);
+ theme->color2 = ((int)PRVM_clientglobalvector(particle_color2)[0] << 16) + ((int)PRVM_clientglobalvector(particle_color2)[1] << 8) + ((int)PRVM_clientglobalvector(particle_color2)[2]);
+ theme->tex = (int)PRVM_clientglobalfloat(particle_tex);
+ theme->size = PRVM_clientglobalfloat(particle_size);
+ theme->sizeincrease = PRVM_clientglobalfloat(particle_sizeincrease);
+ theme->alpha = PRVM_clientglobalfloat(particle_alpha)*256;
+ theme->alphafade = PRVM_clientglobalfloat(particle_alphafade)*256;
+ theme->lifetime = PRVM_clientglobalfloat(particle_time);
+ theme->gravity = PRVM_clientglobalfloat(particle_gravity);
+ theme->bounce = PRVM_clientglobalfloat(particle_bounce);
+ theme->airfriction = PRVM_clientglobalfloat(particle_airfriction);
+ theme->liquidfriction = PRVM_clientglobalfloat(particle_liquidfriction);
+ theme->originjitter = PRVM_clientglobalfloat(particle_originjitter);
+ theme->velocityjitter = PRVM_clientglobalfloat(particle_velocityjitter);
+ theme->qualityreduction = PRVM_clientglobalfloat(particle_qualityreduction) != 0 ? true : false;
+ theme->stretch = PRVM_clientglobalfloat(particle_stretch);
+ theme->staincolor1 = ((int)PRVM_clientglobalvector(particle_staincolor1)[0])*65536 + (int)(PRVM_clientglobalvector(particle_staincolor1)[1])*256 + (int)(PRVM_clientglobalvector(particle_staincolor1)[2]);
+ theme->staincolor2 = (int)(PRVM_clientglobalvector(particle_staincolor2)[0])*65536 + (int)(PRVM_clientglobalvector(particle_staincolor2)[1])*256 + (int)(PRVM_clientglobalvector(particle_staincolor2)[2]);
+ theme->staintex =(int)PRVM_clientglobalfloat(particle_staintex);
+ theme->stainalpha = PRVM_clientglobalfloat(particle_stainalpha)*256;
+ theme->stainsize = PRVM_clientglobalfloat(particle_stainsize);
+ theme->delayspawn = PRVM_clientglobalfloat(particle_delayspawn);
+ theme->delaycollision = PRVM_clientglobalfloat(particle_delaycollision);
+ theme->angle = PRVM_clientglobalfloat(particle_angle);
+ theme->spin = PRVM_clientglobalfloat(particle_spin);
}
// init particle spawner interface
VM_Warning(prog, "VM_CL_ResetParticle: particle spawner not initialized\n");
return;
}
- VM_CL_ParticleThemeToGlobals(&vmpartspawner.themes[0]);
+ VM_CL_ParticleThemeToGlobals(&vmpartspawner.themes[0], prog);
}
// void(float themenum) particletheme
if (themenum < 0 || themenum >= vmpartspawner.max_themes)
{
VM_Warning(prog, "VM_CL_ParticleTheme: bad theme number %i\n", themenum);
- VM_CL_ParticleThemeToGlobals(&vmpartspawner.themes[0]);
+ VM_CL_ParticleThemeToGlobals(&vmpartspawner.themes[0], prog);
return;
}
if (vmpartspawner.themes[themenum].initialized == false)
{
VM_Warning(prog, "VM_CL_ParticleTheme: theme #%i not exists\n", themenum);
- VM_CL_ParticleThemeToGlobals(&vmpartspawner.themes[0]);
+ VM_CL_ParticleThemeToGlobals(&vmpartspawner.themes[0], prog);
return;
}
// load particle theme into globals
- VM_CL_ParticleThemeToGlobals(&vmpartspawner.themes[themenum]);
+ VM_CL_ParticleThemeToGlobals(&vmpartspawner.themes[themenum], prog);
}
// float() saveparticletheme
return;
}
vmpartspawner.themes[themenum].initialized = true;
- VM_CL_ParticleThemeFromGlobals(&vmpartspawner.themes[themenum]);
+ VM_CL_ParticleThemeFromGlobals(&vmpartspawner.themes[themenum], prog);
PRVM_G_FLOAT(OFS_RETURN) = themenum;
return;
}
return;
}
vmpartspawner.themes[themenum].initialized = true;
- VM_CL_ParticleThemeFromGlobals(&vmpartspawner.themes[themenum]);
+ VM_CL_ParticleThemeFromGlobals(&vmpartspawner.themes[themenum], prog);
}
// void(float themenum) freeparticletheme
if (vmpartspawner.themes[themenum].initialized == false)
{
VM_Warning(prog, "VM_CL_ParticleThemeFree: theme #%i already freed\n", themenum);
- VM_CL_ParticleThemeToGlobals(&vmpartspawner.themes[0]);
+ VM_CL_ParticleThemeToGlobals(&vmpartspawner.themes[0], prog);
return;
}
// free theme
// returns 0 if failed, 1 if succesful
static void VM_CL_SpawnParticle (prvm_prog_t *prog)
{
- float *org, *dir;
+ vec3_t org, dir;
vmparticletheme_t *theme;
particle_t *part;
int themenum;
PRVM_G_FLOAT(OFS_RETURN) = 0;
return;
}
- org = PRVM_G_VECTOR(OFS_PARM0);
- dir = PRVM_G_VECTOR(OFS_PARM1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), dir);
if (prog->argc < 3) // global-set particle
{
- part = CL_NewParticle(org, (unsigned short)*vmpartspawner.particle_type, ((int)(vmpartspawner.particle_color1[0]) << 16) + ((int)(vmpartspawner.particle_color1[1]) << 8) + ((int)(vmpartspawner.particle_color1[2])), ((int)vmpartspawner.particle_color2[0] << 16) + ((int)vmpartspawner.particle_color2[1] << 8) + ((int)vmpartspawner.particle_color2[2]), (int)*vmpartspawner.particle_tex, *vmpartspawner.particle_size, *vmpartspawner.particle_sizeincrease, *vmpartspawner.particle_alpha*256, *vmpartspawner.particle_alphafade*256, *vmpartspawner.particle_gravity, *vmpartspawner.particle_bounce, org[0], org[1], org[2], dir[0], dir[1], dir[2], *vmpartspawner.particle_airfriction, *vmpartspawner.particle_liquidfriction, *vmpartspawner.particle_originjitter, *vmpartspawner.particle_velocityjitter, (*vmpartspawner.particle_qualityreduction) ? true : false, *vmpartspawner.particle_time, *vmpartspawner.particle_stretch, (pblend_t)(int)*vmpartspawner.particle_blendmode, (porientation_t)(int)*vmpartspawner.particle_orientation, (int)(vmpartspawner.particle_staincolor1[0])*65536 + (int)(vmpartspawner.particle_staincolor1[1])*256 + (int)(vmpartspawner.particle_staincolor1[2]), (int)(vmpartspawner.particle_staincolor2[0])*65536 + (int)(vmpartspawner.particle_staincolor2[1])*256 + (int)(vmpartspawner.particle_staincolor2[2]), (int)*vmpartspawner.particle_staintex, *vmpartspawner.particle_stainalpha*256, *vmpartspawner.particle_stainsize, *vmpartspawner.particle_angle, *vmpartspawner.particle_spin, NULL);
+ part = CL_NewParticle(org,
+ (unsigned short)PRVM_clientglobalfloat(particle_type),
+ ((int)PRVM_clientglobalvector(particle_color1)[0] << 16) + ((int)PRVM_clientglobalvector(particle_color1)[1] << 8) + ((int)PRVM_clientglobalvector(particle_color1)[2]),
+ ((int)PRVM_clientglobalvector(particle_color2)[0] << 16) + ((int)PRVM_clientglobalvector(particle_color2)[1] << 8) + ((int)PRVM_clientglobalvector(particle_color2)[2]),
+ (int)PRVM_clientglobalfloat(particle_tex),
+ PRVM_clientglobalfloat(particle_size),
+ PRVM_clientglobalfloat(particle_sizeincrease),
+ PRVM_clientglobalfloat(particle_alpha)*256,
+ PRVM_clientglobalfloat(particle_alphafade)*256,
+ PRVM_clientglobalfloat(particle_gravity),
+ PRVM_clientglobalfloat(particle_bounce),
+ org[0],
+ org[1],
+ org[2],
+ dir[0],
+ dir[1],
+ dir[2],
+ PRVM_clientglobalfloat(particle_airfriction),
+ PRVM_clientglobalfloat(particle_liquidfriction),
+ PRVM_clientglobalfloat(particle_originjitter),
+ PRVM_clientglobalfloat(particle_velocityjitter),
+ (PRVM_clientglobalfloat(particle_qualityreduction)) ? true : false,
+ PRVM_clientglobalfloat(particle_time),
+ PRVM_clientglobalfloat(particle_stretch),
+ (pblend_t)(int)PRVM_clientglobalfloat(particle_blendmode),
+ (porientation_t)(int)PRVM_clientglobalfloat(particle_orientation),
+ (int)(PRVM_clientglobalvector(particle_staincolor1)[0])*65536 + (int)(PRVM_clientglobalvector(particle_staincolor1)[1])*256 + (int)(PRVM_clientglobalvector(particle_staincolor1)[2]),
+ (int)(PRVM_clientglobalvector(particle_staincolor2)[0])*65536 + (int)(PRVM_clientglobalvector(particle_staincolor2)[1])*256 + (int)(PRVM_clientglobalvector(particle_staincolor2)[2]),
+ (int)PRVM_clientglobalfloat(particle_staintex),
+ PRVM_clientglobalfloat(particle_stainalpha)*256,
+ PRVM_clientglobalfloat(particle_stainsize),
+ PRVM_clientglobalfloat(particle_angle),
+ PRVM_clientglobalfloat(particle_spin),
+ NULL);
if (!part)
{
PRVM_G_FLOAT(OFS_RETURN) = 0;
return;
}
- if (*vmpartspawner.particle_delayspawn)
- part->delayedspawn = cl.time + *vmpartspawner.particle_delayspawn;
- //if (*vmpartspawner.particle_delaycollision)
- // part->delayedcollisions = cl.time + *vmpartspawner.particle_delaycollision;
+ if (PRVM_clientglobalfloat(particle_delayspawn))
+ part->delayedspawn = cl.time + PRVM_clientglobalfloat(particle_delayspawn);
+ //if (PRVM_clientglobalfloat(particle_delaycollision))
+ // part->delayedcollisions = cl.time + PRVM_clientglobalfloat(particle_delaycollision);
}
else // quick themed particle
{
return;
}
theme = &vmpartspawner.themes[themenum];
- part = CL_NewParticle(org, theme->typeindex, theme->color1, theme->color2, theme->tex, theme->size, theme->sizeincrease, theme->alpha, theme->alphafade, theme->gravity, theme->bounce, org[0], org[1], org[2], dir[0], dir[1], dir[2], theme->airfriction, theme->liquidfriction, theme->originjitter, theme->velocityjitter, theme->qualityreduction, theme->lifetime, theme->stretch, theme->blendmode, theme->orientation, theme->staincolor1, theme->staincolor2, theme->staintex, theme->stainalpha, theme->stainsize, theme->angle, theme->spin, NULL);
+ part = CL_NewParticle(org,
+ theme->typeindex,
+ theme->color1,
+ theme->color2,
+ theme->tex,
+ theme->size,
+ theme->sizeincrease,
+ theme->alpha,
+ theme->alphafade,
+ theme->gravity,
+ theme->bounce,
+ org[0],
+ org[1],
+ org[2],
+ dir[0],
+ dir[1],
+ dir[2],
+ theme->airfriction,
+ theme->liquidfriction,
+ theme->originjitter,
+ theme->velocityjitter,
+ theme->qualityreduction,
+ theme->lifetime,
+ theme->stretch,
+ theme->blendmode,
+ theme->orientation,
+ theme->staincolor1,
+ theme->staincolor2,
+ theme->staintex,
+ theme->stainalpha,
+ theme->stainsize,
+ theme->angle,
+ theme->spin,
+ NULL);
if (!part)
{
PRVM_G_FLOAT(OFS_RETURN) = 0;
// returns 0 if failed, 1 if success
static void VM_CL_SpawnParticleDelayed (prvm_prog_t *prog)
{
- float *org, *dir;
+ vec3_t org, dir;
vmparticletheme_t *theme;
particle_t *part;
int themenum;
PRVM_G_FLOAT(OFS_RETURN) = 0;
return;
}
- org = PRVM_G_VECTOR(OFS_PARM0);
- dir = PRVM_G_VECTOR(OFS_PARM1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), dir);
if (prog->argc < 5) // global-set particle
- part = CL_NewParticle(org, (unsigned short)*vmpartspawner.particle_type, ((int)vmpartspawner.particle_color1[0] << 16) + ((int)vmpartspawner.particle_color1[1] << 8) + ((int)vmpartspawner.particle_color1[2]), ((int)vmpartspawner.particle_color2[0] << 16) + ((int)vmpartspawner.particle_color2[1] << 8) + ((int)vmpartspawner.particle_color2[2]), (int)*vmpartspawner.particle_tex, *vmpartspawner.particle_size, *vmpartspawner.particle_sizeincrease, *vmpartspawner.particle_alpha*256, *vmpartspawner.particle_alphafade*256, *vmpartspawner.particle_gravity, *vmpartspawner.particle_bounce, org[0], org[1], org[2], dir[0], dir[1], dir[2], *vmpartspawner.particle_airfriction, *vmpartspawner.particle_liquidfriction, *vmpartspawner.particle_originjitter, *vmpartspawner.particle_velocityjitter, (*vmpartspawner.particle_qualityreduction) ? true : false, *vmpartspawner.particle_time, *vmpartspawner.particle_stretch, (pblend_t)(int)*vmpartspawner.particle_blendmode, (porientation_t)(int)*vmpartspawner.particle_orientation, ((int)vmpartspawner.particle_staincolor1[0] << 16) + ((int)vmpartspawner.particle_staincolor1[1] << 8) + ((int)vmpartspawner.particle_staincolor1[2]), ((int)vmpartspawner.particle_staincolor2[0] << 16) + ((int)vmpartspawner.particle_staincolor2[1] << 8) + ((int)vmpartspawner.particle_staincolor2[2]), (int)*vmpartspawner.particle_staintex, *vmpartspawner.particle_stainalpha*256, *vmpartspawner.particle_stainsize, *vmpartspawner.particle_angle, *vmpartspawner.particle_spin, NULL);
+ part = CL_NewParticle(org,
+ (unsigned short)PRVM_clientglobalfloat(particle_type),
+ ((int)PRVM_clientglobalvector(particle_color1)[0] << 16) + ((int)PRVM_clientglobalvector(particle_color1)[1] << 8) + ((int)PRVM_clientglobalvector(particle_color1)[2]),
+ ((int)PRVM_clientglobalvector(particle_color2)[0] << 16) + ((int)PRVM_clientglobalvector(particle_color2)[1] << 8) + ((int)PRVM_clientglobalvector(particle_color2)[2]),
+ (int)PRVM_clientglobalfloat(particle_tex),
+ PRVM_clientglobalfloat(particle_size),
+ PRVM_clientglobalfloat(particle_sizeincrease),
+ PRVM_clientglobalfloat(particle_alpha)*256,
+ PRVM_clientglobalfloat(particle_alphafade)*256,
+ PRVM_clientglobalfloat(particle_gravity),
+ PRVM_clientglobalfloat(particle_bounce),
+ org[0],
+ org[1],
+ org[2],
+ dir[0],
+ dir[1],
+ dir[2],
+ PRVM_clientglobalfloat(particle_airfriction),
+ PRVM_clientglobalfloat(particle_liquidfriction),
+ PRVM_clientglobalfloat(particle_originjitter),
+ PRVM_clientglobalfloat(particle_velocityjitter),
+ (PRVM_clientglobalfloat(particle_qualityreduction)) ? true : false,
+ PRVM_clientglobalfloat(particle_time),
+ PRVM_clientglobalfloat(particle_stretch),
+ (pblend_t)(int)PRVM_clientglobalfloat(particle_blendmode),
+ (porientation_t)(int)PRVM_clientglobalfloat(particle_orientation),
+ ((int)PRVM_clientglobalvector(particle_staincolor1)[0] << 16) + ((int)PRVM_clientglobalvector(particle_staincolor1)[1] << 8) + ((int)PRVM_clientglobalvector(particle_staincolor1)[2]),
+ ((int)PRVM_clientglobalvector(particle_staincolor2)[0] << 16) + ((int)PRVM_clientglobalvector(particle_staincolor2)[1] << 8) + ((int)PRVM_clientglobalvector(particle_staincolor2)[2]),
+ (int)PRVM_clientglobalfloat(particle_staintex),
+ PRVM_clientglobalfloat(particle_stainalpha)*256,
+ PRVM_clientglobalfloat(particle_stainsize),
+ PRVM_clientglobalfloat(particle_angle),
+ PRVM_clientglobalfloat(particle_spin),
+ NULL);
else // themed particle
{
themenum = (int)PRVM_G_FLOAT(OFS_PARM4);
return;
}
theme = &vmpartspawner.themes[themenum];
- part = CL_NewParticle(org, theme->typeindex, theme->color1, theme->color2, theme->tex, theme->size, theme->sizeincrease, theme->alpha, theme->alphafade, theme->gravity, theme->bounce, org[0], org[1], org[2], dir[0], dir[1], dir[2], theme->airfriction, theme->liquidfriction, theme->originjitter, theme->velocityjitter, theme->qualityreduction, theme->lifetime, theme->stretch, theme->blendmode, theme->orientation, theme->staincolor1, theme->staincolor2, theme->staintex, theme->stainalpha, theme->stainsize, theme->angle, theme->spin, NULL);
+ part = CL_NewParticle(org,
+ theme->typeindex,
+ theme->color1,
+ theme->color2,
+ theme->tex,
+ theme->size,
+ theme->sizeincrease,
+ theme->alpha,
+ theme->alphafade,
+ theme->gravity,
+ theme->bounce,
+ org[0],
+ org[1],
+ org[2],
+ dir[0],
+ dir[1],
+ dir[2],
+ theme->airfriction,
+ theme->liquidfriction,
+ theme->originjitter,
+ theme->velocityjitter,
+ theme->qualityreduction,
+ theme->lifetime,
+ theme->stretch,
+ theme->blendmode,
+ theme->orientation,
+ theme->staincolor1,
+ theme->staincolor2,
+ theme->staintex,
+ theme->stainalpha,
+ theme->stainsize,
+ theme->angle,
+ theme->spin,
+ NULL);
}
if (!part)
{
static void VM_CL_GetEntity (prvm_prog_t *prog)
{
int entnum, fieldnum;
- float org[3], v1[3], v2[3];
+ vec3_t forward, left, up, org;
VM_SAFEPARMCOUNT(2, VM_CL_GetEntityVec);
entnum = PRVM_G_FLOAT(OFS_PARM0);
PRVM_G_FLOAT(OFS_RETURN) = cl.entities_active[entnum];
break;
case 1: // origin
- Matrix4x4_OriginFromMatrix(&cl.entities[entnum].render.matrix, PRVM_G_VECTOR(OFS_RETURN));
+ Matrix4x4_OriginFromMatrix(&cl.entities[entnum].render.matrix, org);
+ VectorCopy(org, PRVM_G_VECTOR(OFS_RETURN));
break;
case 2: // forward
- Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, PRVM_G_VECTOR(OFS_RETURN), v1, v2, org);
+ Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, forward, left, up, org);
+ VectorCopy(forward, PRVM_G_VECTOR(OFS_RETURN));
break;
case 3: // right
- Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, v1, PRVM_G_VECTOR(OFS_RETURN), v2, org);
+ Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, forward, left, up, org);
+ VectorNegate(left, PRVM_G_VECTOR(OFS_RETURN));
break;
case 4: // up
- Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, v1, v2, PRVM_G_VECTOR(OFS_RETURN), org);
+ Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, forward, left, up, org);
+ VectorCopy(up, PRVM_G_VECTOR(OFS_RETURN));
break;
case 5: // scale
PRVM_G_FLOAT(OFS_RETURN) = Matrix4x4_ScaleFromMatrix(&cl.entities[entnum].render.matrix);
break;
case 6: // origin + v_forward, v_right, v_up
- Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, PRVM_clientglobalvector(v_forward), PRVM_clientglobalvector(v_right), PRVM_clientglobalvector(v_up), PRVM_G_VECTOR(OFS_RETURN));
+ Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, forward, left, up, org);
+ VectorCopy(forward, PRVM_clientglobalvector(v_forward));
+ VectorNegate(left, PRVM_clientglobalvector(v_right));
+ VectorCopy(up, PRVM_clientglobalvector(v_up));
+ VectorCopy(org, PRVM_G_VECTOR(OFS_RETURN));
break;
case 7: // alpha
PRVM_G_FLOAT(OFS_RETURN) = cl.entities[entnum].render.alpha;
prvm_prog_t *prog = CLVM_prog;
float dz;
vec3_t oldorg, neworg, end, traceendpos;
+ vec3_t mins, maxs, start;
trace_t trace;
int i, svent;
prvm_edict_t *enemy;
// try the move
+ VectorCopy(PRVM_clientedictvector(ent, mins), mins);
+ VectorCopy(PRVM_clientedictvector(ent, maxs), maxs);
VectorCopy (PRVM_clientedictvector(ent, origin), oldorg);
VectorAdd (PRVM_clientedictvector(ent, origin), move, neworg);
if (dz < 30)
neworg[2] += 8;
}
- trace = CL_TraceBox(PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, mins), PRVM_clientedictvector(ent, maxs), neworg, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
+ VectorCopy(PRVM_clientedictvector(ent, origin), start);
+ trace = CL_TraceBox(start, mins, maxs, neworg, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
if (settrace)
CL_VM_SetTraceGlobals(prog, &trace, svent);
VectorCopy (neworg, end);
end[2] -= sv_stepheight.value*2;
- trace = CL_TraceBox(neworg, PRVM_clientedictvector(ent, mins), PRVM_clientedictvector(ent, maxs), end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
+ trace = CL_TraceBox(neworg, mins, maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
if (settrace)
CL_VM_SetTraceGlobals(prog, &trace, svent);
if (trace.startsolid)
{
neworg[2] -= sv_stepheight.value;
- trace = CL_TraceBox(neworg, PRVM_clientedictvector(ent, mins), PRVM_clientedictvector(ent, maxs), end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
+ trace = CL_TraceBox(neworg, mins, maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), true, true, &svent, true);
if (settrace)
CL_VM_SetTraceGlobals(prog, &trace, svent);
if (trace.startsolid)
*/
matrix4x4_t m;
vec3_t v = {0, 0, 0};
- vec3_t x, y, z;
+ vec3_t a, x, y, z;
VM_SAFEPARMCOUNT(1, VM_CL_RotateMoves);
- AngleVectorsFLU(PRVM_G_VECTOR(OFS_PARM0), x, y, z);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), a);
+ AngleVectorsFLU(a, x, y, z);
Matrix4x4_FromVectors(&m, x, y, z, v);
CL_RotateMoves(&m);
}
MSG_WriteCoord32f (sb, f);
}
-void MSG_WriteVector (sizebuf_t *sb, float *v, protocolversion_t protocol)
+void MSG_WriteVector (sizebuf_t *sb, const vec3_t v, protocolversion_t protocol)
{
MSG_WriteCoord (sb, v[0], protocol);
MSG_WriteCoord (sb, v[1], protocol);
return MSG_ReadCoord32f(sb);
}
-void MSG_ReadVector (sizebuf_t *sb, float *v, protocolversion_t protocol)
+void MSG_ReadVector (sizebuf_t *sb, vec3_t v, protocolversion_t protocol)
{
v[0] = MSG_ReadCoord(sb, protocol);
v[1] = MSG_ReadCoord(sb, protocol);
void MSG_WriteByte (sizebuf_t *sb, int c);
void MSG_WriteShort (sizebuf_t *sb, int c);
void MSG_WriteLong (sizebuf_t *sb, int c);
-void MSG_WriteFloat (sizebuf_t *sb, float f);
+void MSG_WriteFloat (sizebuf_t *sb, vec_t f);
void MSG_WriteString (sizebuf_t *sb, const char *s);
void MSG_WriteUnterminatedString (sizebuf_t *sb, const char *s);
-void MSG_WriteAngle8i (sizebuf_t *sb, float f);
-void MSG_WriteAngle16i (sizebuf_t *sb, float f);
-void MSG_WriteAngle32f (sizebuf_t *sb, float f);
-void MSG_WriteCoord13i (sizebuf_t *sb, float f);
-void MSG_WriteCoord16i (sizebuf_t *sb, float f);
-void MSG_WriteCoord32f (sizebuf_t *sb, float f);
-void MSG_WriteCoord (sizebuf_t *sb, float f, protocolversion_t protocol);
-void MSG_WriteVector (sizebuf_t *sb, float *v, protocolversion_t protocol);
-void MSG_WriteAngle (sizebuf_t *sb, float f, protocolversion_t protocol);
+void MSG_WriteAngle8i (sizebuf_t *sb, vec_t f);
+void MSG_WriteAngle16i (sizebuf_t *sb, vec_t f);
+void MSG_WriteAngle32f (sizebuf_t *sb, vec_t f);
+void MSG_WriteCoord13i (sizebuf_t *sb, vec_t f);
+void MSG_WriteCoord16i (sizebuf_t *sb, vec_t f);
+void MSG_WriteCoord32f (sizebuf_t *sb, vec_t f);
+void MSG_WriteCoord (sizebuf_t *sb, vec_t f, protocolversion_t protocol);
+void MSG_WriteVector (sizebuf_t *sb, const vec3_t v, protocolversion_t protocol);
+void MSG_WriteAngle (sizebuf_t *sb, vec_t f, protocolversion_t protocol);
void MSG_BeginReading (sizebuf_t *sb);
int MSG_ReadLittleShort (sizebuf_t *sb);
float MSG_ReadCoord16i (sizebuf_t *sb);
float MSG_ReadCoord32f (sizebuf_t *sb);
float MSG_ReadCoord (sizebuf_t *sb, protocolversion_t protocol);
-void MSG_ReadVector (sizebuf_t *sb, float *v, protocolversion_t protocol);
+void MSG_ReadVector (sizebuf_t *sb, vec3_t v, protocolversion_t protocol);
float MSG_ReadAngle (sizebuf_t *sb, protocolversion_t protocol);
//@}
//============================================================================
// Client prog handling
//[515]: omg !!! optimize it ! a lot of hacks here and there also :P
-#define CSQC_RETURNVAL prog->globals.generic[OFS_RETURN]
+#define CSQC_RETURNVAL prog->globals.fp[OFS_RETURN]
#define CSQC_BEGIN
#define CSQC_END
//[515]: set globals before calling R_UpdateView, WEIRD CRAP
static void CSQC_SetGlobals (void)
{
+ vec3_t pmove_org;
prvm_prog_t *prog = CLVM_prog;
CSQC_BEGIN
PRVM_clientglobalfloat(time) = cl.time;
// LordHavoc: Spike says not to do this, but without pmove_org the
// CSQC is useless as it can't alter the view origin without
// completely replacing it
- Matrix4x4_OriginFromMatrix(&cl.entities[cl.viewentity].render.matrix, PRVM_clientglobalvector(pmove_org));
+ Matrix4x4_OriginFromMatrix(&cl.entities[cl.viewentity].render.matrix, pmove_org);
+ VectorCopy(pmove_org, PRVM_clientglobalvector(pmove_org));
VectorCopy(cl.movement_velocity, PRVM_clientglobalvector(pmove_vel));
PRVM_clientglobalfloat(pmove_onground) = cl.onground;
PRVM_clientglobalfloat(pmove_inwater) = cl.inwater;
R_DecalSystem_Reset(&entrender->decalsystem);
memset(entrender, 0, sizeof(*entrender));
World_UnlinkEdict(ed);
- memset(ed->fields.vp, 0, prog->entityfields * 4);
+ memset(ed->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
VM_RemoveEdictSkeleton(prog, ed);
World_Physics_RemoveFromEntity(&cl.world, ed);
World_Physics_RemoveJointFromEntity(&cl.world, ed);
R_DrawNoModel_TransparentCallback(ent, rsurface.rtlight, 0, NULL);
}
-void R_CalcBeam_Vertex3f (float *vert, const vec3_t org1, const vec3_t org2, float width)
+void R_CalcBeam_Vertex3f (float *vert, const float *org1, const float *org2, float width)
{
vec3_t right1, right2, diff, normal;
SV_SendClientMessages();
if (sv.paused == 1 && realtime > sv.pausedstart && sv.pausedstart > 0) {
- prog->globals.generic[OFS_PARM0] = realtime - sv.pausedstart;
+ prog->globals.fp[OFS_PARM0] = realtime - sv.pausedstart;
PRVM_serverglobalfloat(time) = sv.time;
prog->ExecuteProgram(prog, PRVM_serverfunction(SV_PausedTic), "QC function SV_PausedTic is missing");
}
while (entnum >= prog->max_edicts)
PRVM_MEM_IncreaseEdicts(prog);
ent = PRVM_EDICT_NUM(entnum);
- memset(ent->fields.vp, 0, prog->entityfields * 4);
+ memset(ent->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
ent->priv.server->free = false;
if(developer_entityparsing.integer)
if (host_client->edict && PRVM_serverfunction(SV_ChangeTeam))
{
Con_DPrint("Calling SV_ChangeTeam\n");
- prog->globals.generic[OFS_PARM0] = playercolor;
+ prog->globals.fp[OFS_PARM0] = playercolor;
PRVM_serverglobalfloat(time) = sv.time;
PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict);
prog->ExecuteProgram(prog, PRVM_serverfunction(SV_ChangeTeam), "QC function SV_ChangeTeam is missing");
, in->m[3][0], in->m[3][1], in->m[3][2], in->m[3][3]);
}
-int Math_atov(const char *s, vec3_t out)
+int Math_atov(const char *s, prvm_vec3_t out)
{
int i;
VectorClear(out);
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#endif
-typedef float vec_t;
-typedef vec_t vec2_t[2];
-typedef vec_t vec3_t[3];
-typedef vec_t vec4_t[4];
-typedef vec_t vec5_t[5];
-typedef vec_t vec6_t[6];
-typedef vec_t vec7_t[7];
-typedef vec_t vec8_t[8];
struct mplane_s;
extern vec3_t vec3_origin;
-#define nanmask (255<<23)
-#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
+#define float_nanmask (0x7F800000)
+#define double_nanmask (0x7FF8000000000000)
+#define FLOAT_IS_NAN(x) (((*(int *)&x)&float_nanmask)==float_nanmask)
+#define DOUBLE_IS_NAN(x) (((*(long long *)&x)&double_nanmask)==double_nanmask)
+
+#ifdef VEC_64
+#define VEC_IS_NAN(x) DOUBLE_IS_NAN(x)
+#else
+#define VEC_IS_NAN(x) FLOAT_IS_NAN(x)
+#endif
+
+#ifdef PRVM_64
+#define PRVM_IS_NAN(x) DOUBLE_IS_NAN(x)
+#else
+#define PRVM_IS_NAN(x) FLOAT_IS_NAN(x)
+#endif
#define bound(min,num,max) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min))
#define Vector2Compare(a,b) (((a)[0]==(b)[0])&&((a)[1]==(b)[1]))
#define Vector2Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1])
#define Vector2Negate(a,b) ((b)[0]=-((a)[0]),(b)[1]=-((a)[1]))
-#define Vector2Set(a,b,c,d,e) ((a)[0]=(b),(a)[1]=(c))
+#define Vector2Set(a,b,c) ((a)[0]=(b),(a)[1]=(c))
#define Vector2Scale(in, scale, out) ((out)[0] = (in)[0] * (scale),(out)[1] = (in)[1] * (scale))
#define Vector2Normalize2(v,dest) {float ilength = (float) sqrt(DotProduct2((v),(v)));if (ilength) ilength = 1.0f / ilength;dest[0] = (v)[0] * ilength;dest[1] = (v)[1] * ilength;}
struct matrix4x4_s;
/// print a matrix to the console
void Matrix4x4_Print(const struct matrix4x4_s *in);
-int Math_atov(const char *s, vec3_t out);
+int Math_atov(const char *s, prvm_vec3_t out);
void BoxFromPoints(vec3_t mins, vec3_t maxs, int numpoints, vec_t *point3f);
typedef struct matrix4x4_s
{
- float m[4][4];
+ vec_t m[4][4];
}
matrix4x4_t;
void Matrix4x4_CreateFromQuakeEntity(matrix4x4_t *out, double x, double y, double z, double pitch, double yaw, double roll, double scale);
// converts a matrix4x4 to a set of 3D vectors for the 3 axial directions, and the translate
-void Matrix4x4_ToVectors(const matrix4x4_t *in, float vx[3], float vy[3], float vz[3], float t[3]);
+void Matrix4x4_ToVectors(const matrix4x4_t *in, vec_t vx[3], vec_t vy[3], vec_t vz[3], vec_t t[3]);
// creates a matrix4x4 from a set of 3D vectors for axial directions, and translate
-void Matrix4x4_FromVectors(matrix4x4_t *out, const float vx[3], const float vy[3], const float vz[3], const float t[3]);
+void Matrix4x4_FromVectors(matrix4x4_t *out, const vec_t vx[3], const vec_t vy[3], const vec_t vz[3], const vec_t t[3]);
// converts a matrix4x4 to a double[16] array in the OpenGL orientation
void Matrix4x4_ToArrayDoubleGL(const matrix4x4_t *in, double out[16]);
void Matrix4x4_Blend (matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2, double blend);
// transforms a 3D vector through a matrix4x4
-void Matrix4x4_Transform (const matrix4x4_t *in, const float v[3], float out[3]);
+void Matrix4x4_Transform (const matrix4x4_t *in, const vec_t v[3], vec_t out[3]);
// transforms a 4D vector through a matrix4x4
// (warning: if you don't know why you would need this, you don't need it)
// (warning: the 4th component of the vector should be 1.0)
-void Matrix4x4_Transform4 (const matrix4x4_t *in, const float v[4], float out[4]);
+void Matrix4x4_Transform4 (const matrix4x4_t *in, const vec_t v[4], vec_t out[4]);
// reverse transforms a 3D vector through a matrix4x4, at least for *simple*
// cases (rotation and translation *ONLY*), this attempts to undo the results
// of Transform
-//void Matrix4x4_SimpleUntransform (const matrix4x4_t *in, const float v[3], float out[3]);
+//void Matrix4x4_SimpleUntransform (const matrix4x4_t *in, const vec_t v[3], vec_t out[3]);
// transforms a direction vector through the rotation part of a matrix
-void Matrix4x4_Transform3x3 (const matrix4x4_t *in, const float v[3], float out[3]);
+void Matrix4x4_Transform3x3 (const matrix4x4_t *in, const vec_t v[3], vec_t out[3]);
// transforms a positive distance plane (A*x+B*y+C*z-D=0) through a rotation or translation matrix
-void Matrix4x4_TransformPositivePlane (const matrix4x4_t *in, float x, float y, float z, float d, float *o);
+void Matrix4x4_TransformPositivePlane (const matrix4x4_t *in, vec_t x, vec_t y, vec_t z, vec_t d, vec_t *o);
// transforms a standard plane (A*x+B*y+C*z+D=0) through a rotation or translation matrix
-void Matrix4x4_TransformStandardPlane (const matrix4x4_t *in, float x, float y, float z, float d, float *o);
+void Matrix4x4_TransformStandardPlane (const matrix4x4_t *in, vec_t x, vec_t y, vec_t z, vec_t d, vec_t *o);
// ease of use functions
// immediately applies a Translate to the matrix
void Matrix4x4_ConcatScale3 (matrix4x4_t *out, double x, double y, double z);
// extracts origin vector (translate) from matrix
-void Matrix4x4_OriginFromMatrix (const matrix4x4_t *in, float *out);
+void Matrix4x4_OriginFromMatrix (const matrix4x4_t *in, vec_t *out);
// extracts scaling factor from matrix (only works for uniform scaling)
double Matrix4x4_ScaleFromMatrix (const matrix4x4_t *in);
prvm_prog_t *prog = MVM_prog;
// pass key
- prog->globals.generic[OFS_PARM0] = (float) key;
- prog->globals.generic[OFS_PARM1] = (float) ascii;
+ prog->globals.fp[OFS_PARM0] = (float) key;
+ prog->globals.fp[OFS_PARM1] = (float) ascii;
if (downevent)
prog->ExecuteProgram(prog, PRVM_menufunction(m_keydown),"m_keydown(float key, float ascii) required");
else if (PRVM_menufunction(m_keyup))
{
prvm_prog_t *prog = MVM_prog;
- prog->globals.generic[OFS_PARM0] = (float) mode;
+ prog->globals.fp[OFS_PARM0] = (float) mode;
prog->ExecuteProgram(prog, PRVM_menufunction(m_toggle),"m_toggle(float mode) required");
}
int (*FindBoxClusters)(struct model_s *model, const vec3_t mins, const vec3_t maxs, int maxclusters, int *clusterlist);
void (*LightPoint)(struct model_s *model, const vec3_t p, vec3_t ambientcolor, vec3_t diffusecolor, vec3_t diffusenormal);
void (*FindNonSolidLocation)(struct model_s *model, const vec3_t in, vec3_t out, vec_t radius);
- mleaf_t *(*PointInLeaf)(struct model_s *model, const float *p);
+ mleaf_t *(*PointInLeaf)(struct model_s *model, const vec3_t p);
// these are actually only found on brushq1, but NULL is handled gracefully
void (*AmbientSoundLevelsForPoint)(struct model_s *model, const vec3_t p, unsigned char *out, int outsize);
void (*RoundUpToHullSize)(struct model_s *cmodel, const vec3_t inmins, const vec3_t inmaxs, vec3_t outmins, vec3_t outmaxs);
VM_SAFEPARMCOUNT(2,VM_M_copyentity);
in = PRVM_G_EDICT(OFS_PARM0);
out = PRVM_G_EDICT(OFS_PARM1);
- memcpy(out->fields.vp, in->fields.vp, prog->entityfields * 4);
+ memcpy(out->fields.fp, in->fields.fp, prog->entityfields * sizeof(prvm_vec_t));
}
//#66 vector() getmousepos (EXT_CSQC)
typedef union prvm_eval_s
{
- string_t string;
- float _float;
- float vector[3];
- func_t function;
- int ivector[3];
- int _int;
- int edict;
+ prvm_int_t string;
+ prvm_vec_t _float;
+ prvm_vec_t vector[3];
+ prvm_int_t function;
+ prvm_int_t ivector[3];
+ prvm_int_t _int;
+ prvm_int_t edict;
} prvm_eval_t;
typedef struct prvm_required_field_s
union
{
prvm_edict_private_t *required;
- vec_t *vp;
+ prvm_vec_t *fp;
+ prvm_int_t *ip;
// FIXME: this server pointer really means world, not server
// (it is used by both server qc and client qc, but not menu qc)
edict_engineprivate_t *server;
// QuakeC fields (stored in dynamically resized array)
union
{
- vec_t *vp;
+ prvm_vec_t *fp;
+ prvm_int_t *ip;
// entvars_t *server;
// cl_entvars_t *client;
} fields;
#define PRVM_menufunction(funcname) (prog->funcoffsets.funcname)
#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_EDICTFIELDVALUE(ed, fieldoffset) (fieldoffset < 0 ? Con_Printf("Invalid fieldoffset at %s:%i\n", __FILE__, __LINE__), &prvm_badvalue : (prvm_eval_t *)(ed->fields.fp + fieldoffset))
#define PRVM_EDICTFIELDFLOAT(ed, fieldoffset) (PRVM_EDICTFIELDVALUE(ed, fieldoffset)->_float)
#define PRVM_EDICTFIELDVECTOR(ed, fieldoffset) (PRVM_EDICTFIELDVALUE(ed, fieldoffset)->vector)
#define PRVM_EDICTFIELDSTRING(ed, fieldoffset) (PRVM_EDICTFIELDVALUE(ed, fieldoffset)->string)
#define PRVM_EDICTFIELDEDICT(ed, fieldoffset) (PRVM_EDICTFIELDVALUE(ed, fieldoffset)->edict)
#define PRVM_EDICTFIELDFUNCTION(ed, fieldoffset) (PRVM_EDICTFIELDVALUE(ed, fieldoffset)->function)
-#define PRVM_GLOBALFIELDVALUE(fieldoffset) (fieldoffset < 0 ? Con_Printf("Invalid fieldoffset at %s:%i\n", __FILE__, __LINE__), &prvm_badvalue : (prvm_eval_t *)((int *)prog->globals.generic + fieldoffset))
+#define PRVM_GLOBALFIELDVALUE(fieldoffset) (fieldoffset < 0 ? Con_Printf("Invalid fieldoffset at %s:%i\n", __FILE__, __LINE__), &prvm_badvalue : (prvm_eval_t *)(prog->globals.fp + fieldoffset))
#define PRVM_GLOBALFIELDFLOAT(fieldoffset) (PRVM_GLOBALFIELDVALUE(fieldoffset)->_float)
#define PRVM_GLOBALFIELDVECTOR(fieldoffset) (PRVM_GLOBALFIELDVALUE(fieldoffset)->vector)
#define PRVM_GLOBALFIELDSTRING(fieldoffset) (PRVM_GLOBALFIELDVALUE(fieldoffset)->string)
#define PRVM_GLOBALFIELDEDICT(fieldoffset) (PRVM_GLOBALFIELDVALUE(fieldoffset)->edict)
#define PRVM_GLOBALFIELDFUNCTION(fieldoffset) (PRVM_GLOBALFIELDVALUE(fieldoffset)->function)
#else
-#define PRVM_EDICTFIELDVALUE(ed, fieldoffset) ((prvm_eval_t *)((int *)ed->fields.vp + fieldoffset))
-#define PRVM_EDICTFIELDFLOAT(ed, fieldoffset) (((prvm_eval_t *)((int *)ed->fields.vp + fieldoffset))->_float)
-#define PRVM_EDICTFIELDVECTOR(ed, fieldoffset) (((prvm_eval_t *)((int *)ed->fields.vp + fieldoffset))->vector)
-#define PRVM_EDICTFIELDSTRING(ed, fieldoffset) (((prvm_eval_t *)((int *)ed->fields.vp + fieldoffset))->string)
-#define PRVM_EDICTFIELDEDICT(ed, fieldoffset) (((prvm_eval_t *)((int *)ed->fields.vp + fieldoffset))->edict)
-#define PRVM_EDICTFIELDFUNCTION(ed, fieldoffset) (((prvm_eval_t *)((int *)ed->fields.vp + fieldoffset))->function)
-#define PRVM_GLOBALFIELDVALUE(fieldoffset) ((prvm_eval_t *)((int *)prog->globals.generic + fieldoffset))
-#define PRVM_GLOBALFIELDFLOAT(fieldoffset) (((prvm_eval_t *)((int *)prog->globals.generic + fieldoffset))->_float)
-#define PRVM_GLOBALFIELDVECTOR(fieldoffset) (((prvm_eval_t *)((int *)prog->globals.generic + fieldoffset))->vector)
-#define PRVM_GLOBALFIELDSTRING(fieldoffset) (((prvm_eval_t *)((int *)prog->globals.generic + fieldoffset))->string)
-#define PRVM_GLOBALFIELDEDICT(fieldoffset) (((prvm_eval_t *)((int *)prog->globals.generic + fieldoffset))->edict)
-#define PRVM_GLOBALFIELDFUNCTION(fieldoffset) (((prvm_eval_t *)((int *)prog->globals.generic + fieldoffset))->function)
+#define PRVM_EDICTFIELDVALUE(ed, fieldoffset) ((prvm_eval_t *)(ed->fields.fp + fieldoffset))
+#define PRVM_EDICTFIELDFLOAT(ed, fieldoffset) (((prvm_eval_t *)(ed->fields.fp + fieldoffset))->_float)
+#define PRVM_EDICTFIELDVECTOR(ed, fieldoffset) (((prvm_eval_t *)(ed->fields.fp + fieldoffset))->vector)
+#define PRVM_EDICTFIELDSTRING(ed, fieldoffset) (((prvm_eval_t *)(ed->fields.fp + fieldoffset))->string)
+#define PRVM_EDICTFIELDEDICT(ed, fieldoffset) (((prvm_eval_t *)(ed->fields.fp + fieldoffset))->edict)
+#define PRVM_EDICTFIELDFUNCTION(ed, fieldoffset) (((prvm_eval_t *)(ed->fields.fp + fieldoffset))->function)
+#define PRVM_GLOBALFIELDVALUE(fieldoffset) ((prvm_eval_t *)(prog->globals.fp + fieldoffset))
+#define PRVM_GLOBALFIELDFLOAT(fieldoffset) (((prvm_eval_t *)(prog->globals.fp + fieldoffset))->_float)
+#define PRVM_GLOBALFIELDVECTOR(fieldoffset) (((prvm_eval_t *)(prog->globals.fp + fieldoffset))->vector)
+#define PRVM_GLOBALFIELDSTRING(fieldoffset) (((prvm_eval_t *)(prog->globals.fp + fieldoffset))->string)
+#define PRVM_GLOBALFIELDEDICT(fieldoffset) (((prvm_eval_t *)(prog->globals.fp + fieldoffset))->edict)
+#define PRVM_GLOBALFIELDFUNCTION(fieldoffset) (((prvm_eval_t *)(prog->globals.fp + fieldoffset))->function)
#endif
//============================================================================
double *statement_profile; // only incremented if prvm_statementprofiling is on
union {
- vec_t *generic;
+ prvm_vec_t *fp;
+ prvm_int_t *ip;
// globalvars_t *server;
// cl_globalvars_t *client;
} globals;
prvm_stack_t stack[PRVM_MAX_STACK_DEPTH+1];
int depth;
- int localstack[PRVM_LOCALSTACK_SIZE];
+ prvm_int_t localstack[PRVM_LOCALSTACK_SIZE];
int localstack_used;
unsigned short filecrc;
int reserved_edicts; // [INIT]
prvm_edict_t *edicts;
- vec_t *edictsfields;
- void *edictprivate;
+ prvm_vec_t *edictsfields;
+ void *edictprivate;
// size of the engine private struct
int edictprivate_size; // [INIT]
//============================================================================
-#define PRVM_G_FLOAT(o) (prog->globals.generic[o])
-#define PRVM_G_INT(o) (*(int *)&prog->globals.generic[o])
-#define PRVM_G_EDICT(o) (PRVM_PROG_TO_EDICT(*(int *)&prog->globals.generic[o]))
+#define PRVM_G_FLOAT(o) (prog->globals.fp[o])
+#define PRVM_G_INT(o) (prog->globals.ip[o])
+#define PRVM_G_EDICT(o) (PRVM_PROG_TO_EDICT(prog->globals.ip[o]))
#define PRVM_G_EDICTNUM(o) PRVM_NUM_FOR_EDICT(PRVM_G_EDICT(o))
-#define PRVM_G_VECTOR(o) (&prog->globals.generic[o])
-#define PRVM_G_STRING(o) (PRVM_GetString(prog, *(string_t *)&prog->globals.generic[o]))
-//#define PRVM_G_FUNCTION(prog, o) (*(func_t *)&prog->globals.generic[o])
+#define PRVM_G_VECTOR(o) (&prog->globals.fp[o])
+#define PRVM_G_STRING(o) (PRVM_GetString(prog, prog->globals.ip[o]))
+//#define PRVM_G_FUNCTION(prog, o) (prog->globals.ip[o])
// FIXME: make these go away?
-#define PRVM_E_FLOAT(e,o) (((float*)e->fields.vp)[o])
-#define PRVM_E_INT(e,o) (((int*)e->fields.vp)[o])
-//#define PRVM_E_VECTOR(e,o) (&((float*)e->fields.vp)[o])
-#define PRVM_E_STRING(e,o) (PRVM_GetString(prog, *(string_t *)&((float*)e->fields.vp)[o]))
+#define PRVM_E_FLOAT(e,o) (e->fields.fp[o])
+#define PRVM_E_INT(e,o) (e->fields.fp[o])
+//#define PRVM_E_VECTOR(e,o) (&(e->fields.fp[o]))
+#define PRVM_E_STRING(e,o) (PRVM_GetString(prog, e->fields.ip[o]))
extern int prvm_type_size[8]; // for consistency : I think a goal of this sub-project is to
// make the new vm mostly independent from the old one, thus if it's necessary, I copy everything
*/
void VM_normalize(prvm_prog_t *prog)
{
- float *value1;
+ prvm_vec_t *value1;
vec3_t newvalue;
double f;
*/
void VM_vectoyaw(prvm_prog_t *prog)
{
- float *value1;
- float yaw;
+ prvm_vec_t *value1;
+ prvm_vec_t yaw;
VM_SAFEPARMCOUNT(1,VM_vectoyaw);
*/
void VM_vectoangles(prvm_prog_t *prog)
{
+ vec3_t result, forward, up;
VM_SAFEPARMCOUNTRANGE(1, 2,VM_vectoangles);
- AnglesFromVectors(PRVM_G_VECTOR(OFS_RETURN), PRVM_G_VECTOR(OFS_PARM0), prog->argc >= 2 ? PRVM_G_VECTOR(OFS_PARM1) : NULL, true);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), forward);
+ if (prog->argc >= 2)
+ {
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), up);
+ AnglesFromVectors(result, forward, up, true);
+ }
+ else
+ AnglesFromVectors(result, forward, NULL, true);
+ VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN));
}
/*
// put the data into a string
ddef_t *d;
int type, j;
- int *v;
+ prvm_eval_t *val;
prvm_edict_t * ent;
int i = (int)PRVM_G_FLOAT(OFS_PARM0);
char valuebuf[MAX_INPUTLINE];
VM_Warning(prog, "VM_entityfielddata: %s: entity %i is free !\n", prog->name, PRVM_NUM_FOR_EDICT(ent));
return;
}
- v = (int *)((char *)ent->fields.vp + d->ofs*4);
+ val = (prvm_eval_t *)(ent->fields.fp + d->ofs);
// if it's 0 or blank, return an empty string
type = d->type & ~DEF_SAVEGLOBAL;
for (j=0 ; j<prvm_type_size[type] ; j++)
- if (v[j])
+ if (val->ivector[j])
break;
if (j == prvm_type_size[type])
{
return;
}
- PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, PRVM_UglyValueString(prog, (etype_t)d->type, (prvm_eval_t *)v, valuebuf, sizeof(valuebuf)));
+ PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, PRVM_UglyValueString(prog, (etype_t)d->type, val, valuebuf, sizeof(valuebuf)));
}
// KrimZon - DP_QC_ENTITYDATA
*/
void VM_drawcharacter(prvm_prog_t *prog)
{
- float *pos,*scale,*rgb;
+ prvm_vec_t *pos,*scale,*rgb;
char character;
int flag;
float sx, sy;
*/
void VM_drawstring(prvm_prog_t *prog)
{
- float *pos,*scale,*rgb;
+ prvm_vec_t *pos,*scale,*rgb;
const char *string;
int flag = 0;
float sx, sy;
*/
void VM_drawcolorcodedstring(prvm_prog_t *prog)
{
- float *pos, *scale;
+ prvm_vec_t *pos, *scale;
const char *string;
int flag;
vec3_t rgb;
void VM_stringwidth(prvm_prog_t *prog)
{
const char *string;
- float *szv;
+ vec2_t szv;
float mult; // sz is intended font size so we can later add freetype support, mult is font size multiplier in pixels per character cell
int colors;
float sx, sy;
getdrawfontscale(prog, &sx, &sy);
if(prog->argc == 3)
{
- szv = PRVM_G_VECTOR(OFS_PARM2);
+ Vector2Copy(PRVM_G_VECTOR(OFS_PARM2), szv);
mult = 1;
}
else
{
// we want the width for 8x8 font size, divided by 8
- static float defsize[] = {8, 8};
- szv = defsize;
+ Vector2Set(szv, 8, 8);
mult = 0.125;
// to make sure snapping is turned off, ALWAYS use a nontrivial scale in this case
if(sx >= 0.9 && sx <= 1.1)
void VM_drawpic(prvm_prog_t *prog)
{
const char *picname;
- float *size, *pos, *rgb;
+ prvm_vec_t *size, *pos, *rgb;
int flag = 0;
VM_SAFEPARMCOUNTRANGE(5,6,VM_drawpic);
void VM_drawrotpic(prvm_prog_t *prog)
{
const char *picname;
- float *size, *pos, *org, *rgb;
+ prvm_vec_t *size, *pos, *org, *rgb;
int flag;
VM_SAFEPARMCOUNT(8,VM_drawrotpic);
void VM_drawsubpic(prvm_prog_t *prog)
{
const char *picname;
- float *size, *pos, *rgb, *srcPos, *srcSize, alpha;
+ prvm_vec_t *size, *pos, *rgb, *srcPos, *srcSize, alpha;
int flag;
VM_SAFEPARMCOUNT(8,VM_drawsubpic);
*/
void VM_drawfill(prvm_prog_t *prog)
{
- float *size, *pos, *rgb;
+ prvm_vec_t *size, *pos, *rgb;
int flag;
VM_SAFEPARMCOUNT(5,VM_drawfill);
*/
void VM_makevectors (prvm_prog_t *prog)
{
+ vec3_t angles, forward, right, up;
VM_SAFEPARMCOUNT(1, VM_makevectors);
- AngleVectors(PRVM_G_VECTOR(OFS_PARM0), PRVM_gameglobalvector(v_forward), PRVM_gameglobalvector(v_right), PRVM_gameglobalvector(v_up));
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), angles);
+ AngleVectors(angles, forward, right, up);
+ VectorCopy(forward, PRVM_gameglobalvector(v_forward));
+ VectorCopy(right, PRVM_gameglobalvector(v_right));
+ VectorCopy(up, PRVM_gameglobalvector(v_up));
}
/*
*/
void VM_vectorvectors (prvm_prog_t *prog)
{
+ vec3_t forward, right, up;
VM_SAFEPARMCOUNT(1, VM_vectorvectors);
- VectorNormalize2(PRVM_G_VECTOR(OFS_PARM0), PRVM_gameglobalvector(v_forward));
- VectorVectors(PRVM_gameglobalvector(v_forward), PRVM_gameglobalvector(v_right), PRVM_gameglobalvector(v_up));
+ VectorNormalize2(PRVM_G_VECTOR(OFS_PARM0), forward);
+ VectorVectors(forward, right, up);
+ VectorCopy(forward, PRVM_gameglobalvector(v_forward));
+ VectorCopy(right, PRVM_gameglobalvector(v_right));
+ VectorCopy(up, PRVM_gameglobalvector(v_up));
}
/*
*/
void VM_drawline (prvm_prog_t *prog)
{
- float *c1, *c2, *rgb;
+ prvm_vec_t *c1, *c2, *rgb;
float alpha, width;
unsigned char flags;
char formatbuf[16];
char *f;
int isfloat;
- static int dummyivec[3] = {0, 0, 0};
- static float dummyvec[3] = {0, 0, 0};
+ static prvm_int_t dummyivec[3] = {0, 0, 0};
+ static prvm_vec_t dummyvec[3] = {0, 0, 0};
char vabuf[1024];
#define PRINTF_ALTERNATE 1
#define GETARG_FLOAT(a) (((a)>=1 && (a)<prog->argc) ? (PRVM_G_FLOAT(OFS_PARM0 + 3 * (a))) : 0)
#define GETARG_VECTOR(a) (((a)>=1 && (a)<prog->argc) ? (PRVM_G_VECTOR(OFS_PARM0 + 3 * (a))) : dummyvec)
#define GETARG_INT(a) (((a)>=1 && (a)<prog->argc) ? (PRVM_G_INT(OFS_PARM0 + 3 * (a))) : 0)
-#define GETARG_INTVECTOR(a) (((a)>=1 && (a)<prog->argc) ? ((int*) PRVM_G_VECTOR(OFS_PARM0 + 3 * (a))) : dummyivec)
+#define GETARG_INTVECTOR(a) (((a)>=1 && (a)<prog->argc) ? ((prvm_int_t*) PRVM_G_VECTOR(OFS_PARM0 + 3 * (a))) : dummyivec)
#define GETARG_STRING(a) (((a)>=1 && (a)<prog->argc) ? (PRVM_G_STRING(OFS_PARM0 + 3 * (a))) : "")
for(;;)
dp_model_t *model;
msurface_t *surface;
int pointnum;
+ vec3_t result;
VM_SAFEPARMCOUNT(3, VM_getsurfacepoint);
VectorClear(PRVM_G_VECTOR(OFS_RETURN));
ed = PRVM_G_EDICT(OFS_PARM0);
if (pointnum < 0 || pointnum >= surface->num_vertices)
return;
animatemodel(prog, model, ed);
- applytransform_forward(prog, &(animatemodel_cache.data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, PRVM_G_VECTOR(OFS_RETURN));
+ applytransform_forward(prog, &(animatemodel_cache.data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result);
+ VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN));
}
//PF_getsurfacepointattribute, // #486 vector(entity e, float s, float n, float a) getsurfacepointattribute = #486;
// float SPA_POSITION = 0;
msurface_t *surface;
int pointnum;
int attributetype;
+ vec3_t result;
VM_SAFEPARMCOUNT(4, VM_getsurfacepoint);
VectorClear(PRVM_G_VECTOR(OFS_RETURN));
switch( attributetype ) {
// float SPA_POSITION = 0;
case 0:
- applytransform_forward(prog, &(animatemodel_cache.data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, PRVM_G_VECTOR(OFS_RETURN));
+ applytransform_forward(prog, &(animatemodel_cache.data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result);
+ VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN));
break;
// float SPA_S_AXIS = 1;
case 1:
- applytransform_forward_direction(prog, &(animatemodel_cache.data_svector3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, PRVM_G_VECTOR(OFS_RETURN));
+ applytransform_forward_direction(prog, &(animatemodel_cache.data_svector3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result);
+ VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN));
break;
// float SPA_T_AXIS = 2;
case 2:
- applytransform_forward_direction(prog, &(animatemodel_cache.data_tvector3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, PRVM_G_VECTOR(OFS_RETURN));
+ applytransform_forward_direction(prog, &(animatemodel_cache.data_tvector3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result);
+ VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN));
break;
// float SPA_R_AXIS = 3; // same as SPA_NORMAL
case 3:
- applytransform_forward_direction(prog, &(animatemodel_cache.data_normal3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, PRVM_G_VECTOR(OFS_RETURN));
+ applytransform_forward_direction(prog, &(animatemodel_cache.data_normal3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result);
+ VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN));
break;
// float SPA_TEXCOORDS0 = 4;
case 4: {
- float *ret = PRVM_G_VECTOR(OFS_RETURN);
float *texcoord = &(model->surfmesh.data_texcoordtexture2f + 2 * surface->num_firstvertex)[pointnum * 2];
- ret[0] = texcoord[0];
- ret[1] = texcoord[1];
- ret[2] = 0.0f;
+ result[0] = texcoord[0];
+ result[1] = texcoord[1];
+ result[2] = 0.0f;
+ VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN));
break;
}
// float SPA_LIGHTMAP0_TEXCOORDS = 5;
case 5: {
- float *ret = PRVM_G_VECTOR(OFS_RETURN);
float *texcoord = &(model->surfmesh.data_texcoordlightmap2f + 2 * surface->num_firstvertex)[pointnum * 2];
- ret[0] = texcoord[0];
- ret[1] = texcoord[1];
- ret[2] = 0.0f;
+ result[0] = texcoord[0];
+ result[1] = texcoord[1];
+ result[2] = 0.0f;
+ VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN));
break;
}
// float SPA_LIGHTMAP0_COLOR = 6;
dp_model_t *model;
msurface_t *surface;
vec3_t normal;
+ vec3_t result;
VM_SAFEPARMCOUNT(2, VM_getsurfacenormal);
VectorClear(PRVM_G_VECTOR(OFS_RETURN));
if (!(model = getmodel(prog, PRVM_G_EDICT(OFS_PARM0))) || !(surface = getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
// well for curved surfaces or arbitrary meshes
animatemodel(prog, model, PRVM_G_EDICT(OFS_PARM0));
TriangleNormal((animatemodel_cache.data_vertex3f + 3 * surface->num_firstvertex), (animatemodel_cache.data_vertex3f + 3 * surface->num_firstvertex) + 3, (animatemodel_cache.data_vertex3f + 3 * surface->num_firstvertex) + 6, normal);
- applytransform_forward_normal(prog, normal, PRVM_G_EDICT(OFS_PARM0), PRVM_G_VECTOR(OFS_RETURN));
- VectorNormalize(PRVM_G_VECTOR(OFS_RETURN));
+ applytransform_forward_normal(prog, normal, PRVM_G_EDICT(OFS_PARM0), result);
+ VectorNormalize(result);
+ VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN));
}
//PF_getsurfacetexture, // #437 string(entity e, float s) getsurfacetexture = #437;
void VM_getsurfacetexture(prvm_prog_t *prog)
prvm_edict_t *ed;
dp_model_t *model;
msurface_t *surface;
- vec_t *point;
+ vec3_t point;
VM_SAFEPARMCOUNT(2, VM_getsurfacenearpoint);
PRVM_G_FLOAT(OFS_RETURN) = -1;
ed = PRVM_G_EDICT(OFS_PARM0);
- point = PRVM_G_VECTOR(OFS_PARM1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), point);
if (!ed || ed->priv.server->free)
return;
prvm_edict_t *ed;
dp_model_t *model;
msurface_t *surface;
- vec3_t p, out;
+ vec3_t p, out, inp;
VM_SAFEPARMCOUNT(3, VM_te_getsurfaceclippedpoint);
VectorClear(PRVM_G_VECTOR(OFS_RETURN));
ed = PRVM_G_EDICT(OFS_PARM0);
if (!(model = getmodel(prog, ed)) || !(surface = getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
return;
animatemodel(prog, model, ed);
- applytransform_inverted(prog, PRVM_G_VECTOR(OFS_PARM2), ed, p);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), inp);
+ applytransform_inverted(prog, inp, ed, p);
clippointtosurface(prog, ed, model, surface, p, out);
VectorAdd(out, PRVM_serveredictvector(ed, origin), PRVM_G_VECTOR(OFS_RETURN));
}
#define VM_SAFEPARMCOUNT(p,f)
#endif
-#define VM_RETURN_EDICT(e) (((int *)prog->globals.generic)[OFS_RETURN] = PRVM_EDICT_TO_PROG(e))
+#define VM_RETURN_EDICT(e) (prog->globals.ip[OFS_RETURN] = PRVM_EDICT_TO_PROG(e))
#define VM_STRINGTEMP_LENGTH MAX_INPUTLINE
// alloc edict fields
prog->entityfieldsarea = prog->entityfields * prog->max_edicts;
- prog->edictsfields = (vec_t *)Mem_Alloc(prog->progs_mempool, prog->entityfieldsarea * sizeof(vec_t));
+ prog->edictsfields = (prvm_vec_t *)Mem_Alloc(prog->progs_mempool, prog->entityfieldsarea * sizeof(prvm_vec_t));
// set edict pointers
for(i = 0; i < prog->max_edicts; i++)
{
prog->edicts[i].priv.required = (prvm_edict_private_t *)((unsigned char *)prog->edictprivate + i * prog->edictprivate_size);
- prog->edicts[i].fields.vp = prog->edictsfields + i * prog->entityfields;
+ prog->edicts[i].fields.fp = prog->edictsfields + i * prog->entityfields;
}
}
prog->max_edicts = min(prog->max_edicts + 256, prog->limit_edicts);
prog->entityfieldsarea = prog->entityfields * prog->max_edicts;
- prog->edictsfields = (vec_t*)Mem_Realloc(prog->progs_mempool, (void *)prog->edictsfields, prog->entityfieldsarea * sizeof(vec_t));
+ prog->edictsfields = (prvm_vec_t*)Mem_Realloc(prog->progs_mempool, (void *)prog->edictsfields, prog->entityfieldsarea * sizeof(prvm_vec_t));
prog->edictprivate = (void *)Mem_Realloc(prog->progs_mempool, (void *)prog->edictprivate, prog->max_edicts * prog->edictprivate_size);
//set e and v pointers
for(i = 0; i < prog->max_edicts; i++)
{
prog->edicts[i].priv.required = (prvm_edict_private_t *)((unsigned char *)prog->edictprivate + i * prog->edictprivate_size);
- prog->edicts[i].fields.vp = prog->edictsfields + i * prog->entityfields;
+ prog->edicts[i].fields.fp = prog->edictsfields + i * prog->entityfields;
}
prog->end_increase_edicts(prog);
*/
void PRVM_ED_ClearEdict(prvm_prog_t *prog, prvm_edict_t *e)
{
- memset(e->fields.vp, 0, prog->entityfields * 4);
+ memset(e->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
e->priv.required->free = false;
// AK: Let the init_edict function determine if something needs to be initialized
char *s;
//size_t i;
ddef_t *def;
- void *val;
+ prvm_eval_t *val;
char valuebuf[MAX_INPUTLINE];
- val = (void *)&prog->globals.generic[ofs];
+ val = (prvm_eval_t *)&prog->globals.fp[ofs];
def = PRVM_ED_GlobalAtOfs(prog, ofs);
if (!def)
dpsnprintf (line, linelength, "GLOBAL%i", ofs);
else
{
- s = PRVM_ValueString (prog, (etype_t)def->type, (prvm_eval_t *)val, valuebuf, sizeof(valuebuf));
+ s = PRVM_ValueString (prog, (etype_t)def->type, val, valuebuf, sizeof(valuebuf));
dpsnprintf (line, linelength, "%s (=%s)", PRVM_GetString(prog, def->s_name), s);
}
{
size_t l;
ddef_t *d;
- int *v;
+ prvm_eval_t *val;
int i, j;
const char *name;
int type;
// Didn't match; skip
continue;
- v = (int *)(ed->fields.vp + d->ofs);
+ val = (prvm_eval_t *)(ed->fields.fp + d->ofs);
// if the value is still all 0, skip the field
type = d->type & ~DEF_SAVEGLOBAL;
for (j=0 ; j<prvm_type_size[type] ; j++)
- if (v[j])
+ if (val->ivector[j])
break;
if (j == prvm_type_size[type])
continue;
strlcat(tempstring, " ", sizeof(tempstring));
strlcat(tempstring, " ", sizeof(tempstring));
- name = PRVM_ValueString(prog, (etype_t)d->type, (prvm_eval_t *)v, valuebuf, sizeof(valuebuf));
+ name = PRVM_ValueString(prog, (etype_t)d->type, val, valuebuf, sizeof(valuebuf));
if (strlen(name) > sizeof(tempstring2)-4)
{
memcpy (tempstring2, name, sizeof(tempstring2)-4);
void PRVM_ED_Write (prvm_prog_t *prog, qfile_t *f, prvm_edict_t *ed)
{
ddef_t *d;
- int *v;
+ prvm_eval_t *val;
int i, j;
const char *name;
int type;
if(strlen(name) > 1 && name[strlen(name)-2] == '_')
continue; // skip _x, _y, _z vars, and ALSO other _? vars as some mods expect them to be never saved (TODO: a gameplayfix for using the "more precise" condition above?)
- v = (int *)(ed->fields.vp + d->ofs);
+ val = (prvm_eval_t *)(ed->fields.fp + d->ofs);
// if the value is still all 0, skip the field
type = d->type & ~DEF_SAVEGLOBAL;
for (j=0 ; j<prvm_type_size[type] ; j++)
- if (v[j])
+ if (val->ivector[j])
break;
if (j == prvm_type_size[type])
continue;
FS_Printf(f,"\"%s\" ",name);
prog->statestring = va(vabuf, sizeof(vabuf), "PRVM_ED_Write, ent=%d, name=%s", i, name);
- FS_Printf(f,"\"%s\"\n", PRVM_UglyValueString(prog, (etype_t)d->type, (prvm_eval_t *)v, valuebuf, sizeof(valuebuf)));
+ FS_Printf(f,"\"%s\"\n", PRVM_UglyValueString(prog, (etype_t)d->type, val, valuebuf, sizeof(valuebuf)));
prog->statestring = NULL;
}
prog->statestring = va(vabuf, sizeof(vabuf), "PRVM_ED_WriteGlobals, name=%s", name);
FS_Printf(f,"\"%s\" ", name);
- FS_Printf(f,"\"%s\"\n", PRVM_UglyValueString(prog, (etype_t)type, (prvm_eval_t *)&prog->globals.generic[def->ofs], valuebuf, sizeof(valuebuf)));
+ FS_Printf(f,"\"%s\"\n", PRVM_UglyValueString(prog, (etype_t)type, (prvm_eval_t *)&prog->globals.fp[def->ofs], valuebuf, sizeof(valuebuf)));
prog->statestring = NULL;
}
FS_Print(f,"}\n");
mfunction_t *func;
if (ent)
- val = (prvm_eval_t *)(ent->fields.vp + key->ofs);
+ val = (prvm_eval_t *)(ent->fields.fp + key->ofs);
else
- val = (prvm_eval_t *)(prog->globals.generic + key->ofs);
+ val = (prvm_eval_t *)(prog->globals.fp + key->ofs);
switch (key->type & ~DEF_SAVEGLOBAL)
{
case ev_string:
PRVM_MEM_IncreaseEdicts(prog);
// if IncreaseEdicts was called the base pointer needs to be updated
if (ent)
- val = (prvm_eval_t *)(ent->fields.vp + key->ofs);
+ val = (prvm_eval_t *)(ent->fields.fp + key->ofs);
val->edict = PRVM_EDICT_TO_PROG(PRVM_EDICT_NUM((int)i));
break;
goto fail;
}
- v = (prvm_eval_t *)(ed->fields.vp + key->ofs);
+ v = (prvm_eval_t *)(ed->fields.fp + key->ofs);
s = PRVM_UglyValueString(prog, (etype_t)key->type, v, valuebuf, sizeof(valuebuf));
if(Cmd_Argc() == 5)
{
goto fail;
}
- v = (prvm_eval_t *) &prog->globals.generic[key->ofs];
+ v = (prvm_eval_t *) &prog->globals.fp[key->ofs];
s = PRVM_UglyValueString(prog, (etype_t)key->type, v, valuebuf, sizeof(valuebuf));
if(Cmd_Argc() == 4)
{
// clear it
if (ent != prog->edicts) // hack
- memset (ent->fields.vp, 0, prog->entityfields * 4);
+ memset (ent->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
data = PRVM_ED_ParseEdict (prog, data, ent);
parsed++;
dstatement_t *instatements;
ddef_t *infielddefs;
ddef_t *inglobaldefs;
- float *inglobals;
+ int *inglobals;
dfunction_t *infunctions;
char *instrings;
fs_offset_t filesize;
int a;
int b;
int c;
+ union
+ {
+ unsigned int i;
+ float f;
+ }
+ u;
+ unsigned int d;
char vabuf[1024];
if (prog->loaded)
prog->progs_numfunctions = LittleLong(dprograms->numfunctions);
instrings = (char *)((unsigned char *)dprograms + LittleLong(dprograms->ofs_strings));
prog->progs_numstrings = LittleLong(dprograms->numstrings);
- inglobals = (float *)((unsigned char *)dprograms + LittleLong(dprograms->ofs_globals));
+ inglobals = (int *)((unsigned char *)dprograms + LittleLong(dprograms->ofs_globals));
prog->progs_numglobals = LittleLong(dprograms->numglobals);
prog->progs_entityfields = LittleLong(dprograms->entityfields);
// we need to expand the globaldefs and fielddefs to include engine defs
prog->globaldefs = (ddef_t *)Mem_Alloc(prog->progs_mempool, (prog->progs_numglobaldefs + numrequiredglobals) * sizeof(ddef_t));
- prog->globals.generic = (float *)Mem_Alloc(prog->progs_mempool, (prog->progs_numglobals + requiredglobalspace) * sizeof(float));
+ prog->globals.fp = (prvm_vec_t *)Mem_Alloc(prog->progs_mempool, (prog->progs_numglobals + requiredglobalspace) * sizeof(prvm_vec_t));
prog->fielddefs = (ddef_t *)Mem_Alloc(prog->progs_mempool, (prog->progs_numfielddefs + numrequiredfields) * sizeof(ddef_t));
// we need to convert the statements to our memory format
prog->statements = (mstatement_t *)Mem_Alloc(prog->progs_mempool, prog->progs_numstatements * sizeof(mstatement_t));
#define remapfield(index) (index)
// copy globals
+ // FIXME: LordHavoc: this uses a crude way to identify integer constants, rather than checking for matching globaldefs and checking their type
for (i = 0;i < prog->progs_numglobals;i++)
- ((int *)prog->globals.generic)[remapglobal(i)] = LittleLong(((int *)inglobals)[i]);
+ {
+ u.i = LittleLong(inglobals[i]);
+ // most globals are 0, we only need to deal with the ones that are not
+ if (u.i)
+ {
+ d = u.i & 0xFF800000;
+ if ((d == 0xFF800000) || (d == 0))
+ {
+ // Looks like an integer (expand to int64)
+ prog->globals.ip[remapglobal(i)] = u.i;
+ }
+ else
+ {
+ // Looks like a float (expand to double)
+ prog->globals.fp[remapglobal(i)] = u.f;
+ }
+ }
+ }
// LordHavoc: TODO: support 32bit progs statement formats
// copy, remap globals in statements, bounds check
const char *name;
prvm_edict_t *ed;
ddef_t *d;
- int *v;
+ prvm_eval_t *val;
// TODO
/*
name = PRVM_GetString(prog, d->s_name);
if (name[strlen(name)-2] == '_')
continue; // skip _x, _y, _z vars
- v = (int *)(ed->fields.vp + d->ofs);
+ val = (prvm_eval_t *)(ed->fields.fp + d->ofs);
// if the value is still all 0, skip the field
for (j = 0;j < prvm_type_size[d->type & ~DEF_SAVEGLOBAL];j++)
{
- if (v[j])
+ if (val->ivector[j])
{
counts[i]++;
break;
prog->error_cmd("PRVM_ExecuteProgram: locals stack overflow in %s", prog->name);
for (i=0 ; i < c ; i++)
- prog->localstack[prog->localstack_used+i] = ((int *)prog->globals.generic)[f->parm_start + i];
+ prog->localstack[prog->localstack_used+i] = prog->globals.ip[f->parm_start + i];
prog->localstack_used += c;
// copy parameters
{
for (j=0 ; j<f->parm_size[i] ; j++)
{
- ((int *)prog->globals.generic)[o] = ((int *)prog->globals.generic)[OFS_PARM0+i*3+j];
+ prog->globals.ip[o] = prog->globals.ip[OFS_PARM0+i*3+j];
o++;
}
}
prog->error_cmd("PRVM_ExecuteProgram: locals stack underflow in %s", prog->name);
for (i=0 ; i < c ; i++)
- ((int *)prog->globals.generic)[prog->xfunction->parm_start + i] = prog->localstack[prog->localstack_used+i];
+ prog->globals.ip[prog->xfunction->parm_start + i] = prog->localstack[prog->localstack_used+i];
// up stack
prog->depth--;
// nothing here yet
}
-#define OPA ((prvm_eval_t *)&prog->globals.generic[st->operand[0]])
-#define OPB ((prvm_eval_t *)&prog->globals.generic[st->operand[1]])
-#define OPC ((prvm_eval_t *)&prog->globals.generic[st->operand[2]])
+#define OPA ((prvm_eval_t *)&prog->globals.fp[st->operand[0]])
+#define OPB ((prvm_eval_t *)&prog->globals.fp[st->operand[1]])
+#define OPC ((prvm_eval_t *)&prog->globals.fp[st->operand[2]])
extern cvar_t prvm_traceqc;
extern cvar_t prvm_statementprofiling;
extern qboolean prvm_runawaycheck;
}
break;
case OP_BITAND:
- OPC->_float = (int)OPA->_float & (int)OPB->_float;
+ OPC->_float = (prvm_int_t)OPA->_float & (prvm_int_t)OPB->_float;
break;
case OP_BITOR:
- OPC->_float = (int)OPA->_float | (int)OPB->_float;
+ OPC->_float = (prvm_int_t)OPA->_float | (prvm_int_t)OPB->_float;
break;
case OP_GE:
OPC->_float = OPA->_float >= OPB->_float;
if (OPB->_int < 0 || OPB->_int + 1 > prog->entityfieldsarea)
{
PreError();
- prog->error_cmd("%s attempted to write to an out of bounds edict (%i)", prog->name, OPB->_int);
+ prog->error_cmd("%s attempted to write to an out of bounds edict (%i)", prog->name, (int)OPB->_int);
goto cleanup;
}
if (OPB->_int < prog->entityfields && !prog->allowworldwrites)
{
prog->xstatement = st - prog->statements;
- VM_Warning(prog, "assignment to world.%s (field %i) in %s\n", PRVM_GetString(prog, PRVM_ED_FieldAtOfs(prog, OPB->_int)->s_name), OPB->_int, prog->name);
+ VM_Warning(prog, "assignment to world.%s (field %i) in %s\n", PRVM_GetString(prog, PRVM_ED_FieldAtOfs(prog, OPB->_int)->s_name), (int)OPB->_int, prog->name);
}
ptr = (prvm_eval_t *)(prog->edictsfields + OPB->_int);
ptr->_int = OPA->_int;
if (OPB->_int < 0 || OPB->_int + 3 > prog->entityfieldsarea)
{
PreError();
- prog->error_cmd("%s attempted to write to an out of bounds edict (%i)", prog->name, OPB->_int);
+ prog->error_cmd("%s attempted to write to an out of bounds edict (%i)", prog->name, (int)OPB->_int);
goto cleanup;
}
if (OPB->_int < prog->entityfields && !prog->allowworldwrites)
{
prog->xstatement = st - prog->statements;
- VM_Warning(prog, "assignment to world.%s (field %i) in %s\n", PRVM_GetString(prog, PRVM_ED_FieldAtOfs(prog, OPB->_int)->s_name), OPB->_int, prog->name);
+ VM_Warning(prog, "assignment to world.%s (field %i) in %s\n", PRVM_GetString(prog, PRVM_ED_FieldAtOfs(prog, OPB->_int)->s_name), (int)OPB->_int, prog->name);
}
ptr = (prvm_eval_t *)(prog->edictsfields + OPB->_int);
ptr->ivector[0] = OPA->ivector[0];
if ((unsigned int)(OPB->_int) >= (unsigned int)(prog->entityfields))
{
PreError();
- prog->error_cmd("%s attempted to address an invalid field (%i) in an edict", prog->name, OPB->_int);
+ prog->error_cmd("%s attempted to address an invalid field (%i) in an edict", prog->name, (int)OPB->_int);
goto cleanup;
}
#if 0
}
#endif
ed = PRVM_PROG_TO_EDICT(OPA->edict);
- OPC->_int = ed->fields.vp - prog->edictsfields + OPB->_int;
+ OPC->_int = ed->fields.fp - prog->edictsfields + OPB->_int;
break;
case OP_LOAD_F:
if ((unsigned int)(OPB->_int) >= (unsigned int)(prog->entityfields))
{
PreError();
- prog->error_cmd("%s attempted to read an invalid field in an edict (%i)", prog->name, OPB->_int);
+ prog->error_cmd("%s attempted to read an invalid field in an edict (%i)", prog->name, (int)OPB->_int);
goto cleanup;
}
ed = PRVM_PROG_TO_EDICT(OPA->edict);
- OPC->_int = ((prvm_eval_t *)((int *)ed->fields.vp + OPB->_int))->_int;
+ OPC->_int = ((prvm_eval_t *)(ed->fields.fp + OPB->_int))->_int;
break;
case OP_LOAD_V:
if (OPB->_int < 0 || OPB->_int + 2 >= prog->entityfields)
{
PreError();
- prog->error_cmd("%s attempted to read an invalid field in an edict (%i)", prog->name, OPB->_int);
+ prog->error_cmd("%s attempted to read an invalid field in an edict (%i)", prog->name, (int)OPB->_int);
goto cleanup;
}
ed = PRVM_PROG_TO_EDICT(OPA->edict);
- OPC->ivector[0] = ((prvm_eval_t *)((int *)ed->fields.vp + OPB->_int))->ivector[0];
- OPC->ivector[1] = ((prvm_eval_t *)((int *)ed->fields.vp + OPB->_int))->ivector[1];
- OPC->ivector[2] = ((prvm_eval_t *)((int *)ed->fields.vp + OPB->_int))->ivector[2];
+ OPC->ivector[0] = ((prvm_eval_t *)(ed->fields.fp + OPB->_int))->ivector[0];
+ OPC->ivector[1] = ((prvm_eval_t *)(ed->fields.fp + OPB->_int))->ivector[1];
+ OPC->ivector[2] = ((prvm_eval_t *)(ed->fields.fp + OPB->_int))->ivector[2];
break;
//==================
if (!OPA->function)
prog->error_cmd("NULL function in %s", prog->name);
- if(!OPA->function || OPA->function >= (unsigned int)prog->numfunctions)
+ if(!OPA->function || OPA->function < 0 || OPA->function >= prog->numfunctions)
{
PreError();
prog->error_cmd("%s CALL outside the program", prog->name);
prog->xfunction->profile += (st - startst);
prog->xstatement = st - prog->statements;
- prog->globals.generic[OFS_RETURN] = prog->globals.generic[st->operand[0]];
- prog->globals.generic[OFS_RETURN+1] = prog->globals.generic[st->operand[0]+1];
- prog->globals.generic[OFS_RETURN+2] = prog->globals.generic[st->operand[0]+2];
+ prog->globals.ip[OFS_RETURN ] = prog->globals.ip[st->operand[0] ];
+ prog->globals.ip[OFS_RETURN+1] = prog->globals.ip[st->operand[0]+1];
+ prog->globals.ip[OFS_RETURN+2] = prog->globals.ip[st->operand[0]+2];
st = prog->statements + PRVM_LeaveFunction(prog);
startst = st;
OPC->_int = OPA->_int + OPB->_int;
break;
case OP_ADD_IF:
- OPC->_int = OPA->_int + (int) OPB->_float;
+ OPC->_int = OPA->_int + (prvm_int_t) OPB->_float;
break;
case OP_ADD_FI:
- OPC->_float = OPA->_float + (float) OPB->_int;
+ OPC->_float = OPA->_float + (prvm_vec_t) OPB->_int;
break;
case OP_SUB_I:
OPC->_int = OPA->_int - OPB->_int;
break;
case OP_SUB_IF:
- OPC->_int = OPA->_int - (int) OPB->_float;
+ OPC->_int = OPA->_int - (prvm_int_t) OPB->_float;
break;
case OP_SUB_FI:
- OPC->_float = OPA->_float - (float) OPB->_int;
+ OPC->_float = OPA->_float - (prvm_vec_t) OPB->_int;
break;
case OP_MUL_I:
OPC->_int = OPA->_int * OPB->_int;
break;
case OP_MUL_IF:
- OPC->_int = OPA->_int * (int) OPB->_float;
+ OPC->_int = OPA->_int * (prvm_int_t) OPB->_float;
break;
case OP_MUL_FI:
- OPC->_float = OPA->_float * (float) OPB->_int;
+ OPC->_float = OPA->_float * (prvm_vec_t) OPB->_int;
break;
case OP_MUL_VI:
- OPC->vector[0] = (float) OPB->_int * OPA->vector[0];
- OPC->vector[1] = (float) OPB->_int * OPA->vector[1];
- OPC->vector[2] = (float) OPB->_int * OPA->vector[2];
+ OPC->vector[0] = (prvm_vec_t) OPB->_int * OPA->vector[0];
+ OPC->vector[1] = (prvm_vec_t) OPB->_int * OPA->vector[1];
+ OPC->vector[2] = (prvm_vec_t) OPB->_int * OPA->vector[2];
break;
case OP_DIV_VF:
{
OPC->_int = OPA->_int / OPB->_int;
break;
case OP_DIV_IF:
- OPC->_int = OPA->_int / (int) OPB->_float;
+ OPC->_int = OPA->_int / (prvm_int_t) OPB->_float;
break;
case OP_DIV_FI:
- OPC->_float = OPA->_float / (float) OPB->_int;
+ OPC->_float = OPA->_float / (prvm_vec_t) OPB->_int;
break;
case OP_CONV_IF:
OPC->_float = OPA->_int;
OPC->_int = OPA->_int | OPB->_int;
break;
case OP_BITAND_IF:
- OPC->_int = OPA->_int & (int)OPB->_float;
+ OPC->_int = OPA->_int & (prvm_int_t)OPB->_float;
break;
case OP_BITOR_IF:
- OPC->_int = OPA->_int | (int)OPB->_float;
+ OPC->_int = OPA->_int | (prvm_int_t)OPB->_float;
break;
case OP_BITAND_FI:
- OPC->_float = (int)OPA->_float & OPB->_int;
+ OPC->_float = (prvm_int_t)OPA->_float & OPB->_int;
break;
case OP_BITOR_FI:
- OPC->_float = (int)OPA->_float | OPB->_int;
+ OPC->_float = (prvm_int_t)OPA->_float | OPB->_int;
break;
case OP_GE_I:
OPC->_float = OPA->_int >= OPB->_int;
OPC->_float = OPA->_int || OPB->_int;
break;
case OP_GE_IF:
- OPC->_float = (float)OPA->_int >= OPB->_float;
+ OPC->_float = (prvm_vec_t)OPA->_int >= OPB->_float;
break;
case OP_LE_IF:
- OPC->_float = (float)OPA->_int <= OPB->_float;
+ OPC->_float = (prvm_vec_t)OPA->_int <= OPB->_float;
break;
case OP_GT_IF:
- OPC->_float = (float)OPA->_int > OPB->_float;
+ OPC->_float = (prvm_vec_t)OPA->_int > OPB->_float;
break;
case OP_LT_IF:
- OPC->_float = (float)OPA->_int < OPB->_float;
+ OPC->_float = (prvm_vec_t)OPA->_int < OPB->_float;
break;
case OP_AND_IF:
- OPC->_float = (float)OPA->_int && OPB->_float;
+ OPC->_float = (prvm_vec_t)OPA->_int && OPB->_float;
break;
case OP_OR_IF:
- OPC->_float = (float)OPA->_int || OPB->_float;
+ OPC->_float = (prvm_vec_t)OPA->_int || OPB->_float;
break;
case OP_GE_FI:
- OPC->_float = OPA->_float >= (float)OPB->_int;
+ OPC->_float = OPA->_float >= (prvm_vec_t)OPB->_int;
break;
case OP_LE_FI:
- OPC->_float = OPA->_float <= (float)OPB->_int;
+ OPC->_float = OPA->_float <= (prvm_vec_t)OPB->_int;
break;
case OP_GT_FI:
- OPC->_float = OPA->_float > (float)OPB->_int;
+ OPC->_float = OPA->_float > (prvm_vec_t)OPB->_int;
break;
case OP_LT_FI:
- OPC->_float = OPA->_float < (float)OPB->_int;
+ OPC->_float = OPA->_float < (prvm_vec_t)OPB->_int;
break;
case OP_AND_FI:
- OPC->_float = OPA->_float && (float)OPB->_int;
+ OPC->_float = OPA->_float && (prvm_vec_t)OPB->_int;
break;
case OP_OR_FI:
- OPC->_float = OPA->_float || (float)OPB->_int;
+ OPC->_float = OPA->_float || (prvm_vec_t)OPB->_int;
break;
case OP_NOT_I:
OPC->_float = !OPA->_int;
OPC->_float = OPA->_int == OPB->_int;
break;
case OP_EQ_IF:
- OPC->_float = (float)OPA->_int == OPB->_float;
+ OPC->_float = (prvm_vec_t)OPA->_int == OPB->_float;
break;
case OP_EQ_FI:
- OPC->_float = OPA->_float == (float)OPB->_int;
+ OPC->_float = OPA->_float == (prvm_vec_t)OPB->_int;
break;
case OP_NE_I:
OPC->_float = OPA->_int != OPB->_int;
break;
case OP_NE_IF:
- OPC->_float = (float)OPA->_int != OPB->_float;
+ OPC->_float = (prvm_vec_t)OPA->_int != OPB->_float;
break;
case OP_NE_FI:
- OPC->_float = OPA->_float != (float)OPB->_int;
+ OPC->_float = OPA->_float != (prvm_vec_t)OPB->_int;
break;
case OP_STORE_I:
OPB->_int = OPA->_int;
break;
case OP_GADDRESS:
- i = OPA->_int + (int) OPB->_float;
+ i = OPA->_int + (prvm_int_t) OPB->_float;
#if PRBOUNDSCHECK
if (i < 0 || i >= pr_globaldefs)
{
#define RESTRICT
#endif
+// LordHavoc: upgrade the prvm to double precision for better time values
+//#define PRVM_64
+#ifdef PRVM_64
+typedef double prvm_vec_t;
+typedef long long prvm_int_t;
+#else
+typedef float prvm_vec_t;
+typedef int prvm_int_t;
+#endif
+typedef prvm_vec_t prvm_vec3_t[3];
+
+#ifdef VEC_64
+typedef double vec_t;
+#else
+typedef float vec_t;
+#endif
+typedef vec_t vec2_t[2];
+typedef vec_t vec3_t[3];
+typedef vec_t vec4_t[4];
+typedef vec_t vec5_t[5];
+typedef vec_t vec6_t[6];
+typedef vec_t vec7_t[7];
+typedef vec_t vec8_t[8];
+
#endif
#define ISWHITESPACEORCONTROL(ch) ((signed char) (ch) <= (signed char) ' ')
+#ifdef PRVM_64
+#define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFFFFFFFFFF) // also match "negative zero" doubles of value 0x8000000000000000
+#else
#define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFF) // also match "negative zero" floats of value 0x80000000
+#endif
#endif
{
int i;
float scale, size, radius, dot1, dot2;
+ prvm_vec3_t prvmshadowdir, prvmshadowfocus;
vec3_t shadowdir, shadowforward, shadowright, shadoworigin, shadowfocus, shadowmins, shadowmaxs;
entity_render_t *ent;
scale = r_shadow_shadowmapping_precision.value * r_shadows_shadowmapscale.value;
radius = 0.5f * size / scale;
- Math_atov(r_shadows_throwdirection.string, shadowdir);
+ Math_atov(r_shadows_throwdirection.string, prvmshadowdir);
+ VectorCopy(prvmshadowdir, shadowdir);
VectorNormalize(shadowdir);
dot1 = DotProduct(r_refdef.view.forward, shadowdir);
dot2 = DotProduct(r_refdef.view.up, shadowdir);
VectorMA(r_refdef.view.up, -dot2, shadowdir, shadowforward);
VectorNormalize(shadowforward);
CrossProduct(shadowdir, shadowforward, shadowright);
- Math_atov(r_shadows_focus.string, shadowfocus);
+ Math_atov(r_shadows_focus.string, prvmshadowfocus);
+ VectorCopy(prvmshadowfocus, shadowfocus);
VectorM(shadowfocus[0], r_refdef.view.right, shadoworigin);
VectorMA(shadoworigin, shadowfocus[1], r_refdef.view.up, shadoworigin);
VectorMA(shadoworigin, -shadowfocus[2], r_refdef.view.forward, shadoworigin);
vec3_t relativelightdirection, relativeforward, relativeright;
vec3_t relativeshadowmins, relativeshadowmaxs;
vec3_t shadowdir, shadowforward, shadowright, shadoworigin, shadowfocus;
+ prvm_vec3_t prvmshadowdir, prvmshadowfocus;
float m[12];
matrix4x4_t shadowmatrix, cameramatrix, mvpmatrix, invmvpmatrix, scalematrix, texmatrix;
r_viewport_t viewport;
r_shadow_shadowmap_parameters[2] = 1.0;
r_shadow_shadowmap_parameters[3] = bound(0.0f, 1.0f - r_shadows_darken.value, 1.0f);
- Math_atov(r_shadows_throwdirection.string, shadowdir);
+ Math_atov(r_shadows_throwdirection.string, prvmshadowdir);
+ VectorCopy(prvmshadowdir, shadowdir);
VectorNormalize(shadowdir);
- Math_atov(r_shadows_focus.string, shadowfocus);
+ Math_atov(r_shadows_focus.string, prvmshadowfocus);
+ VectorCopy(prvmshadowfocus, shadowfocus);
VectorM(shadowfocus[0], r_refdef.view.right, shadoworigin);
VectorMA(shadoworigin, shadowfocus[1], r_refdef.view.up, shadoworigin);
VectorMA(shadoworigin, -shadowfocus[2], r_refdef.view.forward, shadoworigin);
vec3_t relativelightdirection;
vec3_t relativeshadowmins, relativeshadowmaxs;
vec3_t tmp, shadowdir;
+ prvm_vec3_t prvmshadowdir;
if (!r_refdef.scene.numentities || !vid.stencil || (r_shadow_shadowmode != R_SHADOW_SHADOWMODE_STENCIL && r_shadows.integer != 1))
return;
// get shadow dir
if (r_shadows.integer == 2)
{
- Math_atov(r_shadows_throwdirection.string, shadowdir);
+ Math_atov(r_shadows_throwdirection.string, prvmshadowdir);
+ VectorCopy(prvmshadowdir, shadowdir);
VectorNormalize(shadowdir);
}
=============================================================================
*/
-void R_LightPoint(vec3_t color, const vec3_t p, const int flags)
+void R_LightPoint(float *color, const vec3_t p, const int flags)
{
int i, numlights, flag;
float f, relativepoint[3], dist, dist2, lightradius2;
#define LP_LIGHTMAP 1
#define LP_RTWORLD 2
#define LP_DYNLIGHT 4
-void R_LightPoint(vec3_t color, const vec3_t p, const int flags);
-void R_CompleteLightPoint(vec3_t ambientcolor, vec3_t diffusecolor, vec3_t diffusenormal, const vec3_t p, const int flags);
+void R_LightPoint(float *color, const vec3_t p, const int flags);
+void R_CompleteLightPoint(float *ambientcolor, float *diffusecolor, float *diffusenormal, const vec3_t p, const int flags);
void R_DrawModelShadowMaps(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture);
void R_DrawModelShadows(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture);
// r_stain
void R_Stain(const vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, int cr2, int cg2, int cb2, int ca2);
-void R_CalcBeam_Vertex3f(float *vert, const vec3_t org1, const vec3_t org2, float width);
-void R_CalcSprite_Vertex3f(float *vertex3f, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2);
+void R_CalcBeam_Vertex3f(float *vert, const float *org1, const float *org2, float width);
+void R_CalcSprite_Vertex3f(float *vertex3f, const float *origin, const float *left, const float *up, float scalex1, float scalex2, float scaley1, float scaley2);
extern mempool_t *r_main_mempool;
unsigned int customizeentityforclient;
unsigned int sendentity;
float f;
- float *v;
+ prvm_vec_t *v;
vec3_t cullmins, cullmaxs;
dp_model_t *model;
{
// angle fixing was requested by global thinking code...
// so store the current angles for later use
- memcpy(host_client->fixangle_angles, PRVM_serveredictvector(ent, angles), sizeof(host_client->fixangle_angles));
+ VectorCopy(PRVM_serveredictvector(ent, angles), host_client->fixangle_angles);
host_client->fixangle_angles_set = TRUE;
// and clear fixangle for the next frame
//
// AK possible hack since num_edicts is still 0
ent = PRVM_EDICT_NUM(0);
- memset (ent->fields.vp, 0, prog->entityfields * 4);
+ memset (ent->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
ent->priv.server->free = false;
PRVM_serveredictstring(ent, model) = PRVM_SetEngineString(prog, sv.worldname);
PRVM_serveredictfloat(ent, modelindex) = 1; // world model
if (sv.paused == 1 && sv_realtime > sv.pausedstart && sv.pausedstart > 0)
{
PRVM_serverglobalfloat(time) = sv.time;
- prog->globals.generic[OFS_PARM0] = sv_realtime - sv.pausedstart;
+ prog->globals.fp[OFS_PARM0] = sv_realtime - sv.pausedstart;
prog->ExecuteProgram(prog, PRVM_serverfunction(SV_PausedTic), "QC function SV_PausedTic is missing");
}
{
prvm_prog_t *prog = SVVM_prog;
float dz;
- vec3_t oldorg, neworg, end, traceendpos;
+ vec3_t oldorg, neworg, end, traceendpos, entorigin, entmins, entmaxs;
trace_t trace;
int i;
prvm_edict_t *enemy;
// try the move
VectorCopy (PRVM_serveredictvector(ent, origin), oldorg);
VectorAdd (PRVM_serveredictvector(ent, origin), move, neworg);
+ VectorCopy(PRVM_serveredictvector(ent, mins), entmins);
+ VectorCopy(PRVM_serveredictvector(ent, maxs), entmaxs);
// flying monsters don't step up
if ( (int)PRVM_serveredictfloat(ent, flags) & (FL_SWIM | FL_FLY) )
neworg[2] += 8;
}
}
- trace = SV_TraceBox(PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), neworg, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
+ VectorCopy(PRVM_serveredictvector(ent, origin), entorigin);
+ trace = SV_TraceBox(entorigin, entmins, entmaxs, neworg, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
if (trace.fraction == 1)
{
VectorCopy (neworg, end);
end[2] -= sv_stepheight.value*2;
- trace = SV_TraceBox(neworg, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
+ trace = SV_TraceBox(neworg, entmins, entmaxs, end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
if (trace.startsolid)
{
neworg[2] -= sv_stepheight.value;
- trace = SV_TraceBox(neworg, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
+ trace = SV_TraceBox(neworg, entmins, entmaxs, end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
if (trace.startsolid)
return false;
}
float pitchsign = 1;
prvm_edict_t *traceowner, *touch;
trace_t trace;
+ // temporary storage because prvm_vec_t may differ from vec_t
+ vec3_t touchmins, touchmaxs;
// bounding box of entire move area
vec3_t clipboxmins, clipboxmaxs;
// size when clipping against monsters
VM_GenerateFrameGroupBlend(prog, touch->priv.server->framegroupblend, touch);
VM_FrameBlendFromFrameGroupBlend(touch->priv.server->frameblend, touch->priv.server->framegroupblend, model, sv.time);
VM_UpdateEdictSkeleton(prog, touch, model, touch->priv.server->frameblend);
+ VectorCopy(PRVM_serveredictvector(touch, mins), touchmins);
+ VectorCopy(PRVM_serveredictvector(touch, maxs), touchmaxs);
if (type == MOVE_MISSILE && (int)PRVM_serveredictfloat(touch, flags) & FL_MONSTER)
- Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipstart, hitsupercontentsmask);
+ Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipstart, hitsupercontentsmask);
else
- Collision_ClipPointToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, hitsupercontentsmask);
+ Collision_ClipPointToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, hitsupercontentsmask);
Collision_CombineTraces(&cliptrace, &trace, (void *)touch, PRVM_serveredictfloat(touch, solid) == SOLID_BSP);
}
float pitchsign = 1;
prvm_edict_t *traceowner, *touch;
trace_t trace;
+ // temporary storage because prvm_vec_t may differ from vec_t
+ vec3_t touchmins, touchmaxs;
// bounding box of entire move area
vec3_t clipboxmins, clipboxmaxs;
// size when clipping against monsters
VM_GenerateFrameGroupBlend(prog, touch->priv.server->framegroupblend, touch);
VM_FrameBlendFromFrameGroupBlend(touch->priv.server->frameblend, touch->priv.server->framegroupblend, model, sv.time);
VM_UpdateEdictSkeleton(prog, touch, model, touch->priv.server->frameblend);
+ VectorCopy(PRVM_serveredictvector(touch, mins), touchmins);
+ VectorCopy(PRVM_serveredictvector(touch, maxs), touchmaxs);
if (type == MOVE_MISSILE && (int)PRVM_serveredictfloat(touch, flags) & FL_MONSTER)
- Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
+ Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
else
- Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, false);
+ Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, false);
Collision_CombineTraces(&cliptrace, &trace, (void *)touch, PRVM_serveredictfloat(touch, solid) == SOLID_BSP);
}
qboolean pointtrace;
prvm_edict_t *traceowner, *touch;
trace_t trace;
+ // temporary storage because prvm_vec_t may differ from vec_t
+ vec3_t touchmins, touchmaxs;
// bounding box of entire move area
vec3_t clipboxmins, clipboxmaxs;
// size of the moving object
VM_GenerateFrameGroupBlend(prog, touch->priv.server->framegroupblend, touch);
VM_FrameBlendFromFrameGroupBlend(touch->priv.server->frameblend, touch->priv.server->framegroupblend, model, sv.time);
VM_UpdateEdictSkeleton(prog, touch, model, touch->priv.server->frameblend);
+ VectorCopy(PRVM_serveredictvector(touch, mins), touchmins);
+ VectorCopy(PRVM_serveredictvector(touch, maxs), touchmaxs);
if (type == MOVE_MISSILE && (int)PRVM_serveredictfloat(touch, flags) & FL_MONSTER)
- Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
+ Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask);
else
- Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_serveredictvector(touch, mins), PRVM_serveredictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask);
+ Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask);
Collision_CombineTraces(&cliptrace, &trace, (void *)touch, PRVM_serveredictfloat(touch, solid) == SOLID_BSP);
}
{
prvm_prog_t *prog = SVVM_prog;
dp_model_t *model;
- vec3_t mins, maxs;
+ vec3_t mins, maxs, entmins, entmaxs, entangles;
int modelindex;
if (ent == prog->edicts)
{
// TODO maybe should do this for rotating SOLID_BSP too? Would behave better with rotating doors
// TODO special handling for spheres?
- RotateBBox(PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), PRVM_serveredictvector(ent, angles), mins, maxs);
+ VectorCopy(PRVM_serveredictvector(ent, mins), entmins);
+ VectorCopy(PRVM_serveredictvector(ent, maxs), entmaxs);
+ VectorCopy(PRVM_serveredictvector(ent, angles), entangles);
+ RotateBBox(entmins, entmaxs, entangles, mins, maxs);
VectorAdd(PRVM_serveredictvector(ent, origin), mins, mins);
VectorAdd(PRVM_serveredictvector(ent, origin), maxs, maxs);
}
{
prvm_prog_t *prog = SVVM_prog;
int contents;
- vec3_t org;
+ vec3_t org, entorigin, entmins, entmaxs;
trace_t trace;
contents = SV_GenericHitSuperContentsMask(ent);
VectorAdd(PRVM_serveredictvector(ent, origin), offset, org);
- trace = SV_TraceBox(org, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), PRVM_serveredictvector(ent, origin), ((PRVM_serveredictfloat(ent, movetype) == MOVETYPE_FLY_WORLDONLY) ? MOVE_WORLDONLY : MOVE_NOMONSTERS), ent, contents);
+ VectorCopy(PRVM_serveredictvector(ent, origin), entorigin);
+ VectorCopy(PRVM_serveredictvector(ent, mins), entmins);
+ VectorCopy(PRVM_serveredictvector(ent, maxs), entmaxs);
+ trace = SV_TraceBox(org, entmins, entmaxs, entorigin, ((PRVM_serveredictfloat(ent, movetype) == MOVETYPE_FLY_WORLDONLY) ? MOVE_WORLDONLY : MOVE_NOMONSTERS), ent, contents);
if (trace.startsupercontents & contents)
return true;
else
// FIXME: this breaks entities larger than the hull size
int i;
vec3_t v, m1, m2, s;
- VectorAdd(org, PRVM_serveredictvector(ent, mins), m1);
- VectorAdd(org, PRVM_serveredictvector(ent, maxs), m2);
+ VectorAdd(org, entmins, m1);
+ VectorAdd(org, entmaxs, m2);
VectorSubtract(m2, m1, s);
#define EPSILON (1.0f / 32.0f)
if (s[0] >= EPSILON*2) {m1[0] += EPSILON;m2[0] -= EPSILON;}
#else
// verify if the endpos is REALLY outside solid
VectorCopy(trace.endpos, org);
- trace = SV_TraceBox(org, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), org, MOVE_NOMONSTERS, ent, contents);
+ trace = SV_TraceBox(org, entmins, entmaxs, org, MOVE_NOMONSTERS, ent, contents);
if(trace.startsolid)
Con_Printf("SV_TestEntityPosition: trace.endpos detected to be in solid. NOT using it.\n");
else
//
for (i=0 ; i<3 ; i++)
{
- if (IS_NAN(PRVM_serveredictvector(ent, velocity)[i]))
+ if (PRVM_IS_NAN(PRVM_serveredictvector(ent, velocity)[i]))
{
Con_Printf("Got a NaN velocity on entity #%i (%s)\n", PRVM_NUM_FOR_EDICT(ent), PRVM_GetString(prog, PRVM_serveredictstring(ent, classname)));
PRVM_serveredictvector(ent, velocity)[i] = 0;
}
- if (IS_NAN(PRVM_serveredictvector(ent, origin)[i]))
+ if (PRVM_IS_NAN(PRVM_serveredictvector(ent, origin)[i]))
{
Con_Printf("Got a NaN origin on entity #%i (%s)\n", PRVM_NUM_FOR_EDICT(ent), PRVM_GetString(prog, PRVM_serveredictstring(ent, classname)));
PRVM_serveredictvector(ent, origin)[i] = 0;
==================
*/
#define STOP_EPSILON 0.1
-static void ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce)
+static void ClipVelocity (prvm_vec3_t in, vec3_t normal, prvm_vec3_t out, prvm_vec_t overbounce)
{
int i;
float backoff;
int blocked, bumpcount;
int i, j, numplanes;
float d, time_left, gravity;
- vec3_t dir, push, planes[MAX_CLIP_PLANES], primal_velocity, original_velocity, new_velocity;
+ vec3_t dir, push, planes[MAX_CLIP_PLANES];
+ prvm_vec3_t primal_velocity, original_velocity, new_velocity;
#if 0
vec3_t end;
#endif
int checkcontents;
qboolean rotated;
float savesolid, movetime2, pushltime;
- vec3_t mins, maxs, move, move1, moveangle, pushorig, pushang, a, forward, left, up, org;
+ vec3_t mins, maxs, move, move1, moveangle, pushorig, pushang, a, forward, left, up, org, pushermins, pushermaxs, checkorigin, checkmins, checkmaxs;
int num_moved;
int numcheckentities;
static prvm_edict_t *checkentities[MAX_EDICTS];
// final position, move it
if (!((int)PRVM_serveredictfloat(check, flags) & FL_ONGROUND) || PRVM_PROG_TO_EDICT(PRVM_serveredictedict(check, groundentity)) != pusher)
{
- Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, PRVM_serveredictvector(pusher, mins), PRVM_serveredictvector(pusher, maxs), SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, PRVM_serveredictvector(check, origin), PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs), PRVM_serveredictvector(check, origin), checkcontents);
+ VectorCopy(PRVM_serveredictvector(pusher, mins), pushermins);
+ VectorCopy(PRVM_serveredictvector(pusher, maxs), pushermaxs);
+ VectorCopy(PRVM_serveredictvector(check, origin), checkorigin);
+ VectorCopy(PRVM_serveredictvector(check, mins), checkmins);
+ VectorCopy(PRVM_serveredictvector(check, maxs), checkmaxs);
+ Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, pushermins, pushermaxs, SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, checkorigin, checkmins, checkmaxs, checkorigin, checkcontents);
//trace = SV_TraceBox(PRVM_serveredictvector(check, origin), PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs), PRVM_serveredictvector(check, origin), MOVE_NOMONSTERS, check, checkcontents);
if (!trace.startsolid)
{
PRVM_serveredictfloat(check, flags) = (int)PRVM_serveredictfloat(check, flags) & ~FL_ONGROUND;
// if it is still inside the pusher, block
- Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, PRVM_serveredictvector(pusher, mins), PRVM_serveredictvector(pusher, maxs), SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, PRVM_serveredictvector(check, origin), PRVM_serveredictvector(check, mins), PRVM_serveredictvector(check, maxs), PRVM_serveredictvector(check, origin), checkcontents);
+ VectorCopy(PRVM_serveredictvector(pusher, mins), pushermins);
+ VectorCopy(PRVM_serveredictvector(pusher, maxs), pushermaxs);
+ VectorCopy(PRVM_serveredictvector(check, origin), checkorigin);
+ VectorCopy(PRVM_serveredictvector(check, mins), checkmins);
+ VectorCopy(PRVM_serveredictvector(check, maxs), checkmaxs);
+ Collision_ClipToGenericEntity(&trace, pushermodel, pusher->priv.server->frameblend, &pusher->priv.server->skeleton, pushermins, pushermaxs, SUPERCONTENTS_BODY, &pusherfinalmatrix, &pusherfinalimatrix, checkorigin, checkmins, checkmaxs, checkorigin, checkcontents);
if (trace.startsolid)
{
vec3_t move2;
{
prvm_prog_t *prog = SVVM_prog;
float d, i;
- vec3_t forward, into, side;
+ vec3_t forward, into, side, v_angle;
- AngleVectors (PRVM_serveredictvector(ent, v_angle), forward, NULL, NULL);
+ VectorCopy(PRVM_serveredictvector(ent, v_angle), v_angle);
+ AngleVectors (v_angle, forward, NULL, NULL);
if ((d = DotProduct (stepnormal, forward) + 0.5) < 0)
{
// cut the tangential velocity
int originalmove_groundentity;
int hitsupercontentsmask;
int type;
- vec3_t upmove, downmove, start_origin, start_velocity, stepnormal, originalmove_origin, originalmove_velocity;
+ vec3_t upmove, downmove, start_origin, start_velocity, stepnormal, originalmove_origin, originalmove_velocity, entmins, entmaxs;
trace_t downtrace, trace;
qboolean applygravity;
type = MOVE_NOMONSTERS; // only clip against bmodels
else
type = MOVE_NORMAL;
- trace = SV_TraceBox(upmove, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), downmove, type, ent, SV_GenericHitSuperContentsMask(ent));
+ VectorCopy(PRVM_serveredictvector(ent, mins), entmins);
+ VectorCopy(PRVM_serveredictvector(ent, maxs), entmaxs);
+ trace = SV_TraceBox(upmove, entmins, entmaxs, downmove, type, ent, SV_GenericHitSuperContentsMask(ent));
if(trace.fraction < 1 && trace.plane.normal[2] > 0.7)
clip |= 1; // but we HAVE found a floor
}
*/
static void SV_CheckWaterTransition (prvm_edict_t *ent)
{
+ vec3_t entorigin;
prvm_prog_t *prog = SVVM_prog;
// LordHavoc: bugfixes in this function are keyed to the sv_gameplayfix_bugfixedcheckwatertransition cvar - if this cvar is 0 then all the original bugs should be reenabled for compatibility
int cont;
- cont = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, SV_PointSuperContents(PRVM_serveredictvector(ent, origin)));
+ VectorCopy(PRVM_serveredictvector(ent, origin), entorigin);
+ cont = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, SV_PointSuperContents(entorigin));
if (!PRVM_serveredictfloat(ent, watertype))
{
// just spawned here
{
// angle fixing was requested by physics code...
// so store the current angles for later use
- memcpy(host_client->fixangle_angles, PRVM_serveredictvector(ent, angles), sizeof(host_client->fixangle_angles));
+ VectorCopy(PRVM_serveredictvector(ent, angles), host_client->fixangle_angles);
host_client->fixangle_angles_set = TRUE;
// and clear fixangle for the next frame
{
// angle fixing was requested by physics code...
// so store the current angles for later use
- memcpy(host_client->fixangle_angles, PRVM_serveredictvector(ent, angles), sizeof(host_client->fixangle_angles));
+ VectorCopy(PRVM_serveredictvector(ent, angles), host_client->fixangle_angles);
host_client->fixangle_angles_set = TRUE;
// and clear fixangle for the next frame
static void DropPunchAngle (void)
{
prvm_prog_t *prog = SVVM_prog;
- float len;
- vec3_t v;
+ vec_t len;
+ vec3_t punchangle, punchvector;
- len = VectorNormalizeLength (PRVM_serveredictvector(host_client->edict, punchangle));
+ VectorCopy(PRVM_serveredictvector(host_client->edict, punchangle), punchangle);
+ VectorCopy(PRVM_serveredictvector(host_client->edict, punchvector), punchvector);
- len -= 10*sv.frametime;
- if (len < 0)
- len = 0;
- VectorScale (PRVM_serveredictvector(host_client->edict, punchangle), len, PRVM_serveredictvector(host_client->edict, punchangle));
+ len = VectorNormalizeLength(punchangle);
+ if (len > 0)
+ {
+ len -= 10*sv.frametime;
+ if (len < 0)
+ len = 0;
+ VectorScale(punchangle, len, punchangle);
+ }
- VectorCopy(PRVM_serveredictvector(host_client->edict, punchvector), v);
- len = VectorNormalizeLength(v);
+ len = VectorNormalizeLength(punchvector);
if (len > 0)
{
len -= 20*sv.frametime;
if (len < 0)
len = 0;
- VectorScale(v, len, v);
+ VectorScale(punchvector, len, punchvector);
}
- VectorCopy(v, PRVM_serveredictvector(host_client->edict, punchvector));
+
+ VectorCopy(punchangle, PRVM_serveredictvector(host_client->edict, punchangle));
+ VectorCopy(punchvector, PRVM_serveredictvector(host_client->edict, punchvector));
}
/*
{
prvm_prog_t *prog = SVVM_prog;
int i;
- vec3_t wishvel;
- float speed, newspeed, wishspeed, addspeed, accelspeed, temp;
+ vec3_t wishvel, v_angle;
+ vec_t speed, newspeed, wishspeed, addspeed, accelspeed, temp;
// user intentions
- AngleVectors (PRVM_serveredictvector(host_client->edict, v_angle), forward, right, up);
+ VectorCopy(PRVM_serveredictvector(host_client->edict, v_angle), v_angle);
+ AngleVectors(v_angle, forward, right, up);
for (i=0 ; i<3 ; i++)
wishvel[i] = forward[i]*cmd.forwardmove + right[i]*cmd.sidemove;
void SV_ClientThink (void)
{
prvm_prog_t *prog = SVVM_prog;
- vec3_t v_angle;
+ vec3_t v_angle, angles, velocity;
//Con_Printf("clientthink for %ims\n", (int) (sv.frametime * 1000));
// angles
// show 1/3 the pitch angle and all the roll angle
VectorAdd (PRVM_serveredictvector(host_client->edict, v_angle), PRVM_serveredictvector(host_client->edict, punchangle), v_angle);
- PRVM_serveredictvector(host_client->edict, angles)[ROLL] = V_CalcRoll (PRVM_serveredictvector(host_client->edict, angles), PRVM_serveredictvector(host_client->edict, velocity))*4;
+ VectorCopy(PRVM_serveredictvector(host_client->edict, angles), angles);
+ VectorCopy(PRVM_serveredictvector(host_client->edict, velocity), velocity);
+ PRVM_serveredictvector(host_client->edict, angles)[ROLL] = V_CalcRoll (angles, velocity)*4;
if (!PRVM_serveredictfloat(host_client->edict, fixangle))
{
PRVM_serveredictvector(host_client->edict, angles)[PITCH] = -v_angle[PITCH]/3;
static void VM_SV_setorigin(prvm_prog_t *prog)
{
prvm_edict_t *e;
- float *org;
VM_SAFEPARMCOUNT(2, VM_setorigin);
VM_Warning(prog, "setorigin: can not modify free entity\n");
return;
}
- org = PRVM_G_VECTOR(OFS_PARM1);
- VectorCopy (org, PRVM_serveredictvector(e, origin));
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), PRVM_serveredictvector(e, origin));
if(e->priv.required->mark == PRVM_EDICT_MARK_WAIT_FOR_SETORIGIN)
e->priv.required->mark = PRVM_EDICT_MARK_SETORIGIN_CAUGHT;
SV_LinkEdict(e);
static void VM_SV_setsize(prvm_prog_t *prog)
{
prvm_edict_t *e;
- float *min, *max;
+ vec3_t mins, maxs;
VM_SAFEPARMCOUNT(3, VM_setsize);
VM_Warning(prog, "setsize: can not modify free entity\n");
return;
}
- min = PRVM_G_VECTOR(OFS_PARM1);
- max = PRVM_G_VECTOR(OFS_PARM2);
- SetMinMaxSize(prog, e, min, max, false);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), mins);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), maxs);
+ SetMinMaxSize(prog, e, mins, maxs, false);
}
*/
static void VM_SV_particle(prvm_prog_t *prog)
{
- float *org, *dir;
+ vec3_t org, dir;
float color;
float count;
VM_SAFEPARMCOUNT(4, VM_SV_particle);
- org = PRVM_G_VECTOR(OFS_PARM0);
- dir = PRVM_G_VECTOR(OFS_PARM1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), dir);
color = PRVM_G_FLOAT(OFS_PARM2);
count = PRVM_G_FLOAT(OFS_PARM3);
SV_StartParticle (org, dir, (int)color, (int)count);
static void VM_SV_ambientsound(prvm_prog_t *prog)
{
const char *samp;
- float *pos;
+ vec3_t pos;
float vol, attenuation;
int soundnum, large;
VM_SAFEPARMCOUNT(4, VM_SV_ambientsound);
- pos = PRVM_G_VECTOR (OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), pos);
samp = PRVM_G_STRING(OFS_PARM1);
vol = PRVM_G_FLOAT(OFS_PARM2);
attenuation = PRVM_G_FLOAT(OFS_PARM3);
*/
static void VM_SV_traceline(prvm_prog_t *prog)
{
- float *v1, *v2;
+ vec3_t v1, v2;
trace_t trace;
int move;
prvm_edict_t *ent;
prog->xfunction->builtinsprofile += 30;
- v1 = PRVM_G_VECTOR(OFS_PARM0);
- v2 = PRVM_G_VECTOR(OFS_PARM1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), v1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), v2);
move = (int)PRVM_G_FLOAT(OFS_PARM2);
ent = PRVM_G_EDICT(OFS_PARM3);
- if (IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || IS_NAN(v2[0]) || IS_NAN(v2[1]) || IS_NAN(v2[2]))
+ if (VEC_IS_NAN(v1[0]) || VEC_IS_NAN(v1[1]) || VEC_IS_NAN(v1[2]) || VEC_IS_NAN(v2[0]) || VEC_IS_NAN(v2[1]) || VEC_IS_NAN(v2[2]))
prog->error_cmd("%s: NAN errors detected in traceline('%f %f %f', '%f %f %f', %i, entity %i)\n", prog->name, v1[0], v1[1], v1[2], v2[0], v2[1], v2[2], move, PRVM_EDICT_TO_PROG(ent));
trace = SV_TraceLine(v1, v2, move, ent, SV_GenericHitSuperContentsMask(ent));
// LordHavoc: added this for my own use, VERY useful, similar to traceline
static void VM_SV_tracebox(prvm_prog_t *prog)
{
- float *v1, *v2, *m1, *m2;
+ vec3_t v1, v2, m1, m2;
trace_t trace;
int move;
prvm_edict_t *ent;
prog->xfunction->builtinsprofile += 30;
- v1 = PRVM_G_VECTOR(OFS_PARM0);
- m1 = PRVM_G_VECTOR(OFS_PARM1);
- m2 = PRVM_G_VECTOR(OFS_PARM2);
- v2 = PRVM_G_VECTOR(OFS_PARM3);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), v1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM1), m1);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), m2);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM3), v2);
move = (int)PRVM_G_FLOAT(OFS_PARM4);
ent = PRVM_G_EDICT(OFS_PARM5);
- if (IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || IS_NAN(v2[0]) || IS_NAN(v2[1]) || IS_NAN(v2[2]))
+ if (VEC_IS_NAN(v1[0]) || VEC_IS_NAN(v1[1]) || VEC_IS_NAN(v1[2]) || VEC_IS_NAN(v2[0]) || VEC_IS_NAN(v2[1]) || VEC_IS_NAN(v2[2]))
prog->error_cmd("%s: NAN errors detected in tracebox('%f %f %f', '%f %f %f', '%f %f %f', '%f %f %f', %i, entity %i)\n", prog->name, v1[0], v1[1], v1[2], m1[0], m1[1], m1[2], m2[0], m2[1], m2[2], v2[0], v2[1], v2[2], move, PRVM_EDICT_TO_PROG(ent));
trace = SV_TraceBox(v1, m1, m2, v2, move, ent, SV_GenericHitSuperContentsMask(ent));
{
int i;
float gravity;
- vec3_t move, end;
+ vec3_t move, end, tossentorigin, tossentmins, tossentmaxs;
vec3_t original_origin;
vec3_t original_velocity;
vec3_t original_angles;
VectorMA (PRVM_serveredictvector(tossent, angles), 0.05, PRVM_serveredictvector(tossent, avelocity), PRVM_serveredictvector(tossent, angles));
VectorScale (PRVM_serveredictvector(tossent, velocity), 0.05, move);
VectorAdd (PRVM_serveredictvector(tossent, origin), move, end);
- trace = SV_TraceBox(PRVM_serveredictvector(tossent, origin), PRVM_serveredictvector(tossent, mins), PRVM_serveredictvector(tossent, maxs), end, MOVE_NORMAL, tossent, SV_GenericHitSuperContentsMask(tossent));
+ VectorCopy(PRVM_serveredictvector(tossent, origin), tossentorigin);
+ VectorCopy(PRVM_serveredictvector(tossent, mins), tossentmins);
+ VectorCopy(PRVM_serveredictvector(tossent, maxs), tossentmaxs);
+ trace = SV_TraceBox(tossentorigin, tossentmins, tossentmaxs, end, MOVE_NORMAL, tossent, SV_GenericHitSuperContentsMask(tossent));
VectorCopy (trace.endpos, PRVM_serveredictvector(tossent, origin));
PRVM_serveredictvector(tossent, velocity)[2] -= gravity;
*/
static void VM_SV_checkpvs(prvm_prog_t *prog)
{
- vec3_t viewpos;
+ vec3_t viewpos, absmin, absmax;
prvm_edict_t *viewee;
#if 1
unsigned char *pvs;
PRVM_G_FLOAT(OFS_RETURN) = 2;
return;
}
- PRVM_G_FLOAT(OFS_RETURN) = sv.worldmodel->brush.BoxTouchingPVS(sv.worldmodel, pvs, PRVM_serveredictvector(viewee, absmin), PRVM_serveredictvector(viewee, absmax));
+ VectorCopy(PRVM_serveredictvector(viewee, absmin), absmin);
+ VectorCopy(PRVM_serveredictvector(viewee, absmax), absmax);
+ PRVM_G_FLOAT(OFS_RETURN) = sv.worldmodel->brush.BoxTouchingPVS(sv.worldmodel, pvs, absmin, absmax);
#else
// using fat PVS like FTEQW does (slow)
if(!sv.worldmodel || !sv.worldmodel->brush.FatPVS || !sv.worldmodel->brush.BoxTouchingPVS)
PRVM_G_FLOAT(OFS_RETURN) = 2;
return;
}
- PRVM_G_FLOAT(OFS_RETURN) = sv.worldmodel->brush.BoxTouchingPVS(sv.worldmodel, fatpvs, PRVM_serveredictvector(viewee, absmin), PRVM_serveredictvector(viewee, absmax));
+ VectorCopy(PRVM_serveredictvector(viewee, absmin), absmin);
+ VectorCopy(PRVM_serveredictvector(viewee, absmax), absmax);
+ PRVM_G_FLOAT(OFS_RETURN) = sv.worldmodel->brush.BoxTouchingPVS(sv.worldmodel, fatpvs, absmin, absmax);
#endif
}
static void VM_SV_droptofloor(prvm_prog_t *prog)
{
prvm_edict_t *ent;
- vec3_t end;
+ vec3_t end, entorigin, entmins, entmaxs;
trace_t trace;
VM_SAFEPARMCOUNTRANGE(0, 2, VM_SV_droptofloor); // allow 2 parameters because the id1 defs.qc had an incorrect prototype
if (sv_gameplayfix_unstickentities.integer)
SV_UnstickEntity(ent);
- trace = SV_TraceBox(PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
+ VectorCopy(PRVM_serveredictvector(ent, origin), entorigin);
+ VectorCopy(PRVM_serveredictvector(ent, mins), entmins);
+ VectorCopy(PRVM_serveredictvector(ent, maxs), entmaxs);
+ trace = SV_TraceBox(entorigin, entmins, entmaxs, end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent));
if (trace.startsolid && sv_gameplayfix_droptofloorstartsolid.integer)
{
vec3_t offset, org;
*/
static void VM_SV_pointcontents(prvm_prog_t *prog)
{
+ vec3_t point;
VM_SAFEPARMCOUNT(1, VM_SV_pointcontents);
- PRVM_G_FLOAT(OFS_RETURN) = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, SV_PointSuperContents(PRVM_G_VECTOR(OFS_PARM0)));
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), point);
+ PRVM_G_FLOAT(OFS_RETURN) = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, SV_PointSuperContents(point));
}
/*
static void VM_SV_getlight(prvm_prog_t *prog)
{
vec3_t ambientcolor, diffusecolor, diffusenormal;
- vec_t *p;
+ vec3_t p;
VM_SAFEPARMCOUNT(1, VM_SV_getlight);
- p = PRVM_G_VECTOR(OFS_PARM0);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), p);
VectorClear(ambientcolor);
VectorClear(diffusecolor);
VectorClear(diffusenormal);
VM_Warning(prog, "copyentity: can not modify free entity\n");
return;
}
- memcpy(out->fields.vp, in->fields.vp, prog->entityfields * 4);
+ memcpy(out->fields.fp, in->fields.fp, prog->entityfields * sizeof(prvm_vec_t));
SV_LinkEdict(out);
}
{
int i;
const char *s;
+ vec3_t org;
VM_SAFEPARMCOUNT(5, VM_SV_effect);
s = PRVM_G_STRING(OFS_PARM1);
if (!s[0])
return;
}
- SV_StartEffect(PRVM_G_VECTOR(OFS_PARM0), i, (int)PRVM_G_FLOAT(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4));
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
+ SV_StartEffect(org, i, (int)PRVM_G_FLOAT(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4));
}
static void VM_SV_te_blood(prvm_prog_t *prog)
int parentindex;
const char *tagname;
int returncode;
- vec3_t fo, le, up, trans;
+ vec3_t forward, left, up, origin;
const dp_model_t *model;
VM_SAFEPARMCOUNT(2, VM_SV_gettaginfo);
tagindex = (int)PRVM_G_FLOAT(OFS_PARM1);
returncode = SV_GetTagMatrix(prog, &tag_matrix, e, tagindex);
- Matrix4x4_ToVectors(&tag_matrix, PRVM_serverglobalvector(v_forward), le, PRVM_serverglobalvector(v_up), PRVM_G_VECTOR(OFS_RETURN));
- VectorScale(le, -1, PRVM_serverglobalvector(v_right));
+ Matrix4x4_ToVectors(&tag_matrix, forward, left, up, origin);
+ VectorCopy(forward, PRVM_serverglobalvector(v_forward));
+ VectorNegate(left, PRVM_serverglobalvector(v_right));
+ VectorCopy(up, PRVM_serverglobalvector(v_up));
+ VectorCopy(origin, PRVM_G_VECTOR(OFS_RETURN));
model = SV_GetModelFromEdict(e);
VM_GenerateFrameGroupBlend(prog, e->priv.server->framegroupblend, e);
VM_FrameBlendFromFrameGroupBlend(e->priv.server->frameblend, e->priv.server->framegroupblend, model, sv.time);
VM_UpdateEdictSkeleton(prog, e, model, e->priv.server->frameblend);
SV_GetExtendedTagInfo(prog, e, tagindex, &parentindex, &tagname, &tag_localmatrix);
- Matrix4x4_ToVectors(&tag_localmatrix, fo, le, up, trans);
+ Matrix4x4_ToVectors(&tag_localmatrix, forward, left, up, origin);
PRVM_serverglobalfloat(gettaginfo_parent) = parentindex;
PRVM_serverglobalstring(gettaginfo_name) = tagname ? PRVM_SetTempString(prog, tagname) : 0;
- VectorCopy(trans, PRVM_serverglobalvector(gettaginfo_offset));
- VectorCopy(fo, PRVM_serverglobalvector(gettaginfo_forward));
- VectorScale(le, -1, PRVM_serverglobalvector(gettaginfo_right));
+ VectorCopy(forward, PRVM_serverglobalvector(gettaginfo_forward));
+ VectorNegate(left, PRVM_serverglobalvector(gettaginfo_right));
VectorCopy(up, PRVM_serverglobalvector(gettaginfo_up));
+ VectorCopy(origin, PRVM_serverglobalvector(gettaginfo_offset));
switch(returncode)
{
// #336 void(entity ent, float effectnum, vector start, vector end) trailparticles (EXT_CSQC)
static void VM_SV_trailparticles(prvm_prog_t *prog)
{
+ vec3_t start, end;
VM_SAFEPARMCOUNT(4, VM_SV_trailparticles);
if ((int)PRVM_G_FLOAT(OFS_PARM0) < 0)
MSG_WriteByte(&sv.datagram, svc_trailparticles);
MSG_WriteShort(&sv.datagram, PRVM_G_EDICTNUM(OFS_PARM0));
MSG_WriteShort(&sv.datagram, (int)PRVM_G_FLOAT(OFS_PARM1));
- MSG_WriteVector(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2), sv.protocol);
- MSG_WriteVector(&sv.datagram, PRVM_G_VECTOR(OFS_PARM3), sv.protocol);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM2), start);
+ VectorCopy(PRVM_G_VECTOR(OFS_PARM3), end);
+ MSG_WriteVector(&sv.datagram, start, sv.protocol);
+ MSG_WriteVector(&sv.datagram, end, sv.protocol);
SV_FlushBroadcastMessages();
}
scr_numtouchscreenareas = 0;
if (vid_touchscreen.integer)
{
- vec3_t move, aim, click;
+ float move[3], aim[3], click[3];
static qboolean buttons[16];
static keydest_t oldkeydest;
keydest_t keydest = (key_consoleactive & KEY_CONSOLEACTIVE_USER) ? key_console : key_dest;
const int *ie;
dBodyID body = (dBodyID)ed->priv.server->ode_body;
dMass mass;
- dReal test;
const dReal *ovelocity, *ospinvelocity;
void *dataID;
dp_model_t *model;
vec_t radius;
vec3_t scale;
vec_t spinlimit;
+ vec_t test;
qboolean gravity;
qboolean geom_modified = false;
edict_odefunc_t *func, *nextf;
if (physics_ode_trick_fixnan.integer)
{
test = VectorLength2(origin) + VectorLength2(forward) + VectorLength2(left) + VectorLength2(up) + VectorLength2(velocity) + VectorLength2(spinvelocity);
- if (IS_NAN(test))
+ if (VEC_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_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(prog, 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))
+ if (VEC_IS_NAN(test))
VectorClear(origin);
test = VectorLength2(forward) * VectorLength2(left) * VectorLength2(up);
- if (IS_NAN(test))
+ if (VEC_IS_NAN(test))
{
VectorSet(angles, 0, 0, 0);
VectorSet(forward, 1, 0, 0);
VectorSet(up, 0, 0, 1);
}
test = VectorLength2(velocity);
- if (IS_NAN(test))
+ if (VEC_IS_NAN(test))
VectorClear(velocity);
test = VectorLength2(spinvelocity);
- if (IS_NAN(test))
+ if (VEC_IS_NAN(test))
{
VectorClear(avelocity);
VectorClear(spinvelocity);