i = PRVM_G_FLOAT(OFS_PARM0);
c = PRVM_G_STRING(OFS_PARM1);
- if (i >= cl_max_lightstyle)
+ if (i >= cl.max_lightstyle)
PF_WARNING("VM_CL_lightstyle >= MAX_LIGHTSTYLES\n");
- strlcpy (cl_lightstyle[i].map, MSG_ReadString(), sizeof (cl_lightstyle[i].map));
- cl_lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
- cl_lightstyle[i].length = (int)strlen(cl_lightstyle[i].map);
+ strlcpy (cl.lightstyle[i].map, MSG_ReadString(), sizeof (cl.lightstyle[i].map));
+ cl.lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
+ cl.lightstyle[i].length = (int)strlen(cl.lightstyle[i].map);
}
// #40 float(entity e) checkbottom
{
start[0] = x ? maxs[0] : mins[0];
start[1] = y ? maxs[1] : mins[1];
- if (!(CL_PointSuperContents(start) & SUPERCONTENTS_SOLID))
+ if (!(CL_PointSuperContents(start) & (SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY)))
goto realcheck;
}
beam_t *b;
// override any beam with the same entity
- for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+ for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
{
if (b->entity == ent && ent)
{
//b->entity = ent;
b->lightning = lightning;
- b->relativestartvalid = (ent && cl_csqcentities[ent].state_current.active) ? 2 : 0;
+ b->relativestartvalid = (ent && cl.csqcentities[ent].state_current.active) ? 2 : 0;
b->model = m;
b->endtime = cl.time + 0.2;
VectorCopy (start, b->start);
}
// find a free beam
- for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+ for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
{
if (!b->model || b->endtime < cl.time)
{
b->entity = ent;
b->lightning = lightning;
- b->relativestartvalid = (ent && cl_csqcentities[ent].state_current.active) ? 2 : 0;
+ b->relativestartvalid = (ent && cl.csqcentities[ent].state_current.active) ? 2 : 0;
b->model = m;
b->endtime = cl.time + 0.2;
VectorCopy (start, b->start);
Con_Printf("CSQC_ParseBeam: invalid entity number %i\n", entnum);
return;
}
- if (entnum >= cl_max_csqcentities)
+ if (entnum >= cl.max_csqcentities)
CL_ExpandCSQCEntities(entnum);
- ent = &cl_csqcentities[entnum];
+ ent = &cl.csqcentities[entnum];
if(prog->argc > 4)
col = PRVM_G_FLOAT(OFS_PARM4);
prog->globals.client->input_timelength = cl.movement_queue[i].frametime;
if(cl.movement_queue[i].crouch)
{
- VectorCopy(cl_playercrouchmins, prog->globals.client->pmove_mins);
- VectorCopy(cl_playercrouchmaxs, prog->globals.client->pmove_maxs);
+ VectorCopy(cl.playercrouchmins, prog->globals.client->pmove_mins);
+ VectorCopy(cl.playercrouchmaxs, prog->globals.client->pmove_maxs);
}
else
{
- VectorCopy(cl_playerstandmins, prog->globals.client->pmove_mins);
- VectorCopy(cl_playerstandmaxs, prog->globals.client->pmove_maxs);
+ VectorCopy(cl.playerstandmins, prog->globals.client->pmove_mins);
+ VectorCopy(cl.playerstandmaxs, prog->globals.client->pmove_maxs);
}
}
}
{
beam_t *b;
int i;
- extern entity_t *cl_csqcentities;
- extern int cl_max_csqcentities;
- if (ent >= cl_max_csqcentities)
+ if (ent >= cl.max_csqcentities)
CL_ExpandCSQCEntities(ent);
// override any beam with the same entity
- for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+ for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
{
if (b->entity == ent && ent)
{
//b->entity = ent;
b->lightning = lightning;
- b->relativestartvalid = (ent && cl_csqcentities[ent].state_current.active) ? 2 : 0;
+ b->relativestartvalid = (ent && cl.csqcentities[ent].state_current.active) ? 2 : 0;
b->model = m;
b->endtime = cl.time + 0.2;
VectorCopy (start, b->start);
}
// find a free beam
- for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+ for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
{
if (!b->model || b->endtime < cl.time)
{
b->entity = ent;
b->lightning = lightning;
- b->relativestartvalid = (ent && cl_csqcentities[ent].state_current.active) ? 2 : 0;
+ b->relativestartvalid = (ent && cl.csqcentities[ent].state_current.active) ? 2 : 0;
b->model = m;
b->endtime = cl.time + 0.2;
VectorCopy (start, b->start);
//DP_QC_GETSURFACE
void clippointtosurface(msurface_t *surface, vec3_t p, vec3_t out);
-static msurface_t *cl_getsurface(prvm_edict_t *ed, int surfacenum)
+static model_t *cl_getmodel(prvm_edict_t *ed)
{
int modelindex;
model_t *model = NULL;
if(modelindex < MAX_MODELS)
model = cl.model_precache[modelindex];
}
- if(!model)
- return NULL;
+ return model;
+}
+
+static msurface_t *cl_getsurface(model_t *model, int surfacenum)
+{
if (surfacenum < 0 || surfacenum >= model->nummodelsurfaces)
return NULL;
return model->data_surfaces + surfacenum + model->firstmodelsurface;
// #434 float(entity e, float s) getsurfacenumpoints
void VM_CL_getsurfacenumpoints(void)
{
+ model_t *model = cl_getmodel(PRVM_G_EDICT(OFS_PARM0));
msurface_t *surface;
// return 0 if no such surface
- if (!(surface = cl_getsurface(PRVM_G_EDICT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1))))
+ if (!model || !(surface = cl_getsurface(model, PRVM_G_FLOAT(OFS_PARM1))))
{
PRVM_G_FLOAT(OFS_RETURN) = 0;
return;
void VM_CL_getsurfacepoint(void)
{
prvm_edict_t *ed;
+ model_t *model;
msurface_t *surface;
int pointnum;
VectorClear(PRVM_G_VECTOR(OFS_RETURN));
ed = PRVM_G_EDICT(OFS_PARM0);
- if (!ed || ed->priv.server->free)
- return;
- if (!(surface = cl_getsurface(ed, PRVM_G_FLOAT(OFS_PARM1))))
+ if (!(model = cl_getmodel(ed)) || !(surface = cl_getsurface(model, PRVM_G_FLOAT(OFS_PARM1))))
return;
// note: this (incorrectly) assumes it is a simple polygon
pointnum = PRVM_G_FLOAT(OFS_PARM2);
if (pointnum < 0 || pointnum >= surface->num_vertices)
return;
// FIXME: implement rotation/scaling
- VectorAdd(&(surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed->fields.client->origin, PRVM_G_VECTOR(OFS_RETURN));
+ VectorAdd(&(model->surfmesh.data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed->fields.client->origin, PRVM_G_VECTOR(OFS_RETURN));
}
// #436 vector(entity e, float s) getsurfacenormal
void VM_CL_getsurfacenormal(void)
{
+ model_t *model;
msurface_t *surface;
vec3_t normal;
VectorClear(PRVM_G_VECTOR(OFS_RETURN));
- if (!(surface = cl_getsurface(PRVM_G_EDICT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1))))
+ if (!(model = cl_getmodel(PRVM_G_EDICT(OFS_PARM0))) || !(surface = cl_getsurface(model, PRVM_G_FLOAT(OFS_PARM1))))
return;
// FIXME: implement rotation/scaling
// note: this (incorrectly) assumes it is a simple polygon
// note: this only returns the first triangle, so it doesn't work very
// well for curved surfaces or arbitrary meshes
- TriangleNormal((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex), (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + 3, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + 6, normal);
+ TriangleNormal((model->surfmesh.data_vertex3f + 3 * surface->num_firstvertex), (model->surfmesh.data_vertex3f + 3 * surface->num_firstvertex) + 3, (model->surfmesh.data_vertex3f + 3 * surface->num_firstvertex) + 6, normal);
VectorNormalize(normal);
VectorCopy(normal, PRVM_G_VECTOR(OFS_RETURN));
}
// #437 string(entity e, float s) getsurfacetexture
void VM_CL_getsurfacetexture(void)
{
+ model_t *model;
msurface_t *surface;
PRVM_G_INT(OFS_RETURN) = 0;
- if (!(surface = cl_getsurface(PRVM_G_EDICT(OFS_PARM0), PRVM_G_FLOAT(OFS_PARM1))))
+ if (!(model = cl_getmodel(PRVM_G_EDICT(OFS_PARM0))) || !(surface = cl_getsurface(model, PRVM_G_FLOAT(OFS_PARM1))))
return;
PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(surface->texture->name);
}
// #438 float(entity e, vector p) getsurfacenearpoint
void VM_CL_getsurfacenearpoint(void)
{
- int surfacenum, best, modelindex;
+ int surfacenum, best;
vec3_t clipped, p;
vec_t dist, bestdist;
prvm_edict_t *ed;
vec_t *point;
PRVM_G_FLOAT(OFS_RETURN) = -1;
ed = PRVM_G_EDICT(OFS_PARM0);
- point = PRVM_G_VECTOR(OFS_PARM1);
-
- if (!ed || ed->priv.server->free)
- return;
- modelindex = ed->fields.client->modelindex;
- if(!modelindex)
- return;
- if(modelindex<0)
- {
- modelindex = -(modelindex+1);
- if(modelindex < MAX_MODELS)
- model = cl.csqc_model_precache[modelindex];
- }
- else
- if(modelindex < MAX_MODELS)
- model = cl.model_precache[modelindex];
- if(!model)
- return;
- if (!model->num_surfaces)
+ if(!(model = cl_getmodel(ed)) || !model->num_surfaces)
return;
// FIXME: implement rotation/scaling
+ point = PRVM_G_VECTOR(OFS_PARM1);
VectorSubtract(point, ed->fields.client->origin, p);
best = -1;
bestdist = 1000000000;
void VM_CL_getsurfaceclippedpoint(void)
{
prvm_edict_t *ed;
+ model_t *model;
msurface_t *surface;
vec3_t p, out;
VectorClear(PRVM_G_VECTOR(OFS_RETURN));
ed = PRVM_G_EDICT(OFS_PARM0);
- if (!ed || ed->priv.server->free)
- return;
- if (!(surface = cl_getsurface(ed, PRVM_G_FLOAT(OFS_PARM1))))
+ if (!(model = cl_getmodel(ed)) || !(surface = cl_getsurface(model, PRVM_G_FLOAT(OFS_PARM1))))
return;
// FIXME: implement rotation/scaling
VectorSubtract(PRVM_G_VECTOR(OFS_PARM2), ed->fields.client->origin, p);
csqcents = PRVM_G_FLOAT(OFS_PARM3);
ent = 0;
- if((csqcents && ignore > cl_num_csqcentities) || (!csqcents && ignore > cl_num_entities))
+ if((csqcents && ignore > cl.num_csqcentities) || (!csqcents && ignore > cl.num_entities))
{
Con_Printf("VM_CL_selecttraceline: out of entities\n");
return;
}
else
if(csqcents)
- prog->globals.client->trace_fraction = CL_SelectTraceLine(v1, v2, prog->globals.client->trace_endpos, prog->globals.client->trace_plane_normal, &prog->globals.client->trace_ent, &cl_csqcentities[ignore].render, csqcents);
+ prog->globals.client->trace_fraction = CL_SelectTraceLine(v1, v2, prog->globals.client->trace_endpos, prog->globals.client->trace_plane_normal, &prog->globals.client->trace_ent, &cl.csqcentities[ignore].render, csqcents);
else
- prog->globals.client->trace_fraction = CL_SelectTraceLine(v1, v2, prog->globals.client->trace_endpos, prog->globals.client->trace_plane_normal, &ent, &cl_entities[ignore].render, csqcents);
+ prog->globals.client->trace_fraction = CL_SelectTraceLine(v1, v2, prog->globals.client->trace_endpos, prog->globals.client->trace_plane_normal, &ent, &cl.entities[ignore].render, csqcents);
PRVM_G_FLOAT(OFS_RETURN) = ent;
}