"DP_QC_RANDOMVEC "
"DP_QC_SINCOSSQRTPOW "
//"DP_QC_STRINGBUFFERS " //[515]: not needed ?
+"DP_QC_STRINGCOLORFUNCTIONS "
"DP_QC_TRACEBOX "
//"DP_QC_TRACETOSS "
"DP_QC_TRACE_MOVETYPE_HITMODEL "
int Sbar_GetPlayer (int index);
void Sbar_SortFrags (void);
void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius);
-void CL_ExpandCSQCEntities(int num);
void CSQC_RelinkAllEntities (int drawmask);
void CSQC_RelinkCSQCEntities (void);
char *Key_GetBind (int key);
+model_t *CSQC_GetModelByIndex(int modelindex);
+model_t *CSQC_GetModelFromEntity(prvm_edict_t *ed);
+
e = PRVM_G_EDICT(OFS_PARM0);
m = PRVM_G_STRING(OFS_PARM1);
- for(i=0;i<MAX_MODELS;i++)
- if(!cl.csqc_model_precache[i])
- break;
- else
- if(!strcmp(cl.csqc_model_precache[i]->name, m))
+ for (i = 0;i < MAX_MODELS && cl.csqc_model_precache[i];i++)
+ {
+ if (!strcmp(cl.csqc_model_precache[i]->name, m))
{
e->fields.client->model = PRVM_SetEngineString(cl.csqc_model_precache[i]->name);
e->fields.client->modelindex = -(i+1);
return;
}
+ }
- for (i=0, mod = cl.model_precache[0] ; i < MAX_MODELS ; i++, mod = cl.model_precache[i])
- if(mod)
- if(!strcmp(mod->name, m))
+ for (i = 0;i < MAX_MODELS;i++)
+ {
+ mod = cl.model_precache[i];
+ if (mod && !strcmp(mod->name, m))
{
e->fields.client->model = PRVM_SetEngineString(mod->name);
e->fields.client->modelindex = i;
return;
}
+ }
+
e->fields.client->modelindex = 0;
e->fields.client->model = 0;
}
VM_SAFEPARMCOUNT(1, VM_CL_precache_model);
name = PRVM_G_STRING(OFS_PARM0);
- for(i=1;i<MAX_MODELS;i++)
- if(!cl.csqc_model_precache[i])
- {
- i = 0;
- break;
- }
- else
+ for (i = 1;i < MAX_MODELS && cl.csqc_model_precache[i];i++)
+ {
if(!strcmp(cl.csqc_model_precache[i]->name, name))
{
- i = -(i+1);
- break;
+ PRVM_G_FLOAT(OFS_RETURN) = -(i+1);
+ return;
}
- if(i)
- {
- PRVM_G_FLOAT(OFS_RETURN) = i;
- return;
}
PRVM_G_FLOAT(OFS_RETURN) = 0;
m = Mod_ForName(name, false, false, false);
if(m && m->loaded)
{
- for(i=1;i<MAX_MODELS;i++)
- if(!cl.csqc_model_precache[i])
- break;
- if(i == MAX_MODELS)
+ for (i = 1;i < MAX_MODELS;i++)
{
- VM_Warning("VM_CL_precache_model: no free models\n");
- return;
+ if (!cl.csqc_model_precache[i])
+ {
+ cl.csqc_model_precache[i] = (model_t*)m;
+ PRVM_G_FLOAT(OFS_RETURN) = -(i+1);
+ return;
+ }
}
- cl.csqc_model_precache[i] = (model_t*)m;
- PRVM_G_FLOAT(OFS_RETURN) = -(i+1);
+ VM_Warning("VM_CL_precache_model: no free models\n");
return;
}
VM_Warning("VM_CL_precache_model: model \"%s\" not found\n", name);
//============================================================================
//[515]: SCENE MANAGER builtins
-extern void V_CalcRefdef (void);//view.c
extern qboolean CSQC_AddRenderEdict (prvm_edict_t *ed);//csprogs.c
-extern void CSQC_ClearCSQCEntities (void);//csprogs.c
matrix4x4_t csqc_listenermatrix;
-qboolean csqc_usecsqclistener = false, csqc_frame = false;//[515]: per-frame
+qboolean csqc_usecsqclistener = false;//[515]: per-frame
static void CSQC_R_RecalcView (void)
{
void VM_R_ClearScene (void)
{
VM_SAFEPARMCOUNT(0, VM_R_ClearScene);
-// CSQC_R_RecalcView();
- CSQC_ClearCSQCEntities();
+ r_refdef.numentities = 0;
}
//#301 void(float mask) addentities (EXT_CSQC)
void VM_R_RenderScene (void) //#134
{
VM_SAFEPARMCOUNT(0, VM_R_RenderScene);
+ // update all renderable network entities
+ CL_UpdateEntities();
R_RenderView();
}
{
int i;
prvm_edict_t *t;
- struct model_s *m;
+ struct model_s *model;
VM_SAFEPARMCOUNT(2, VM_CL_setmodelindex);
t = PRVM_G_EDICT(OFS_PARM0);
+
i = (int)PRVM_G_FLOAT(OFS_PARM1);
t->fields.client->model = 0;
t->fields.client->modelindex = 0;
- if(!i)
+ if (!i)
return;
- if(i<0)
- {
- i = -(i+1);
- if(i >= MAX_MODELS)
- {
- VM_Warning("VM_CL_setmodelindex >= MAX_MODELS\n");
- return;
- }
- m = cl.csqc_model_precache[i];
- }
- else
- if(i >= MAX_MODELS)
- {
- VM_Warning("VM_CL_setmodelindex >= MAX_MODELS\n");
- return;
- }
- else
- m = cl.model_precache[i];
- if(!m)
+
+ model = CSQC_GetModelByIndex(i);
+ if (!model)
{
VM_Warning("VM_CL_setmodelindex: null model\n");
return;
}
- t->fields.client->model = PRVM_SetEngineString(m->name);
+ t->fields.client->model = PRVM_SetEngineString(model->name);
t->fields.client->modelindex = i;
}
//#334 string(float mdlindex) modelnameforindex (EXT_CSQC)
void VM_CL_modelnameforindex (void)
{
- int i;
+ model_t *model;
VM_SAFEPARMCOUNT(1, VM_CL_modelnameforindex);
PRVM_G_INT(OFS_RETURN) = 0;
- i = (int)PRVM_G_FLOAT(OFS_PARM0);
- if(i<0)
- {
- i = -(i+1);
- if(i >= MAX_MODELS)
- {
- VM_Warning("VM_CL_modelnameforindex >= MAX_MODELS\n");
- return;
- }
- if(cl.csqc_model_precache[i])
- PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(cl.csqc_model_precache[i]->name);
- return;
- }
- if(i >= MAX_MODELS)
- {
- VM_Warning("VM_CL_modelnameforindex >= MAX_MODELS\n");
- return;
- }
- if(cl.model_precache[i])
- PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(cl.model_precache[i]->name);
+ model = CSQC_GetModelByIndex((int)PRVM_G_FLOAT(OFS_PARM0));
+ PRVM_G_INT(OFS_RETURN) = model ? PRVM_SetEngineString(model->name) : 0;
}
//#335 float(string effectname) particleeffectnum (EXT_CSQC)
// #336 void(entity ent, float effectnum, vector start, vector end[, float color]) trailparticles (EXT_CSQC)
void VM_CL_trailparticles (void)
{
- int i, entnum;
+ int i;
float *start, *end;
prvm_edict_t *t;
VM_SAFEPARMCOUNT(4, VM_CL_trailparticles);
t = PRVM_G_EDICT(OFS_PARM0);
- entnum = PRVM_NUM_FOR_EDICT(t);
i = (int)PRVM_G_FLOAT(OFS_PARM1);
start = PRVM_G_VECTOR(OFS_PARM2);
end = PRVM_G_VECTOR(OFS_PARM3);
- if (entnum >= MAX_EDICTS)
- {
- VM_Warning("CSQC_ParseBeam: invalid entity number %i\n", entnum);
- return;
- }
- if (entnum >= cl.max_csqcentities)
- CL_ExpandCSQCEntities(entnum);
-
- CL_ParticleEffect(i, VectorDistance(start, end), start, end, t->fields.client->velocity, t->fields.client->velocity, &cl.csqcentities[entnum], (int)PRVM_G_FLOAT(OFS_PARM4));
+ CL_ParticleEffect(i, VectorDistance(start, end), start, end, t->fields.client->velocity, t->fields.client->velocity, NULL, (int)PRVM_G_FLOAT(OFS_PARM4));
}
//#337 void(float effectnum, vector origin, vector dir, float count) pointparticles (EXT_CSQC)
//DP_QC_GETSURFACE
extern void clippointtosurface(model_t *model, msurface_t *surface, vec3_t p, vec3_t out);
-static model_t *cl_getmodel(prvm_edict_t *ed)
-{
- int modelindex;
- model_t *model = NULL;
- if (!ed || ed->priv.server->free)
- return NULL;
- modelindex = (int)ed->fields.client->modelindex;
- if(!modelindex)
- return NULL;
- 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];
- }
- return model;
-}
static msurface_t *cl_getsurface(model_t *model, int surfacenum)
{
// #434 float(entity e, float s) getsurfacenumpoints
void VM_CL_getsurfacenumpoints(void)
{
- model_t *model = cl_getmodel(PRVM_G_EDICT(OFS_PARM0));
+ model_t *model = CSQC_GetModelFromEntity(PRVM_G_EDICT(OFS_PARM0));
msurface_t *surface;
// return 0 if no such surface
if (!model || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
int pointnum;
VectorClear(PRVM_G_VECTOR(OFS_RETURN));
ed = PRVM_G_EDICT(OFS_PARM0);
- if (!(model = cl_getmodel(ed)) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
+ if (!(model = CSQC_GetModelFromEntity(ed)) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
return;
// note: this (incorrectly) assumes it is a simple polygon
pointnum = (int)PRVM_G_FLOAT(OFS_PARM2);
msurface_t *surface;
vec3_t normal;
VectorClear(PRVM_G_VECTOR(OFS_RETURN));
- if (!(model = cl_getmodel(PRVM_G_EDICT(OFS_PARM0))) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
+ if (!(model = CSQC_GetModelFromEntity(PRVM_G_EDICT(OFS_PARM0))) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
return;
// FIXME: implement rotation/scaling
// note: this (incorrectly) assumes it is a simple polygon
model_t *model;
msurface_t *surface;
PRVM_G_INT(OFS_RETURN) = 0;
- if (!(model = cl_getmodel(PRVM_G_EDICT(OFS_PARM0))) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
+ if (!(model = CSQC_GetModelFromEntity(PRVM_G_EDICT(OFS_PARM0))) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
return;
PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(surface->texture->name);
}
vec_t *point;
PRVM_G_FLOAT(OFS_RETURN) = -1;
ed = PRVM_G_EDICT(OFS_PARM0);
- if(!(model = cl_getmodel(ed)) || !model->num_surfaces)
+ if(!(model = CSQC_GetModelFromEntity(ed)) || !model->num_surfaces)
return;
// FIXME: implement rotation/scaling
vec3_t p, out;
VectorClear(PRVM_G_VECTOR(OFS_RETURN));
ed = PRVM_G_EDICT(OFS_PARM0);
- if (!(model = cl_getmodel(ed)) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
+ if (!(model = CSQC_GetModelFromEntity(ed)) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
return;
// FIXME: implement rotation/scaling
VectorSubtract(PRVM_G_VECTOR(OFS_PARM2), ed->fields.client->origin, p);
if (tagentity != NULL && tagentity != prog->edicts && tagname && tagname[0])
{
modelindex = (int)tagentity->fields.client->modelindex;
- model = NULL;
-
- if(modelindex)
- {
- 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];
- }
-
+ model = CSQC_GetModelByIndex(modelindex);
if (model)
{
v->_float = Mod_Alias_GetTagIndexForName(model, (int)tagentity->fields.client->skin, tagname);
int CL_GetTagIndex (prvm_edict_t *e, const char *tagname)
{
- int i;
- model_t *m;
-
- i = (int)e->fields.client->modelindex;
-
- if(!i)
- return -1;
- if(i<0)
- {
- i = -(i+1);
- if(i >= MAX_MODELS)
- return -1;
- m = cl.csqc_model_precache[i];
- }
+ model_t *model = CSQC_GetModelFromEntity(e);
+ if (model)
+ return Mod_Alias_GetTagIndexForName(model, (int)e->fields.client->skin, tagname);
else
- if(i >= MAX_MODELS)
- return -1;
- else
- m = cl.model_precache[i];
-
- return Mod_Alias_GetTagIndexForName(m, (int)e->fields.client->skin, tagname);
+ return -1;
};
// Warnings/errors code:
int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
{
prvm_eval_t *val;
- int modelindex, reqframe, attachloop, i;
+ int reqframe, attachloop;
matrix4x4_t entitymatrix, tagmatrix, attachmatrix;
prvm_edict_t *attachent;
model_t *model;
if (ent->priv.server->free)
return 2;
- modelindex = (int)ent->fields.client->modelindex;
+ model = CSQC_GetModelFromEntity(ent);
- if(!modelindex)
+ if(!model)
return 3;
- if(modelindex<0)
- {
- modelindex = -(modelindex+1);
- if(modelindex >= MAX_MODELS)
- return 3;
- model = cl.csqc_model_precache[modelindex];
- }
- else
- if(modelindex >= MAX_MODELS)
- return 3;
- else
- model = cl.model_precache[modelindex];
if (ent->fields.client->frame >= 0 && ent->fields.client->frame < model->numframes && model->animscenes)
reqframe = model->animscenes[(int)ent->fields.client->frame].firstframe;
attachent = PRVM_EDICT_NUM(val->edict); // to this it entity our entity is attached
val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_tag_index);
- model = NULL;
- i = (int)attachent->fields.client->modelindex;
- if(i<0)
- {
- i = -(i+1);
- if(i < MAX_MODELS)
- model = cl.csqc_model_precache[i];
- }
- else
- if(i < MAX_MODELS)
- model = cl.model_precache[i];
+ model = CSQC_GetModelFromEntity(attachent);
if (model && val->_float >= 1 && model->animscenes && attachent->fields.client->frame >= 0 && attachent->fields.client->frame < model->numframes)
Mod_Alias_GetTagMatrix(model, model->animscenes[(int)attachent->fields.client->frame].firstframe, (int)val->_float - 1, &attachmatrix);
csqcents = (int)PRVM_G_FLOAT(OFS_PARM3);
ent = 0;
- if((csqcents && ignore > cl.num_csqcentities) || (!csqcents && ignore > cl.num_entities))
+ if (csqcents)
{
- VM_Warning("VM_CL_selecttraceline: out of entities\n");
+ VM_Warning("VM_CL_selecttraceline: csqcents flag not supported anymore, and this function is deprecated\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);
- 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);
PRVM_G_FLOAT(OFS_RETURN) = ent;
}
VM_atan, // #473 float(float t) VM_atan (DP_QC_ASINACOSATANATAN2TAN)
VM_atan2, // #474 float(float c, float s) VM_atan2 (DP_QC_ASINACOSATANATAN2TAN)
VM_tan, // #475 float(float a) VM_tan (DP_QC_ASINACOSATANATAN2TAN)
-NULL, // #476
-NULL, // #477
+VM_strlennocol, // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
+VM_strdecolorize, // #477 string(string s) : DRESK - Decolorized String (DP_QC_STRINGCOLORFUNCTIONS)
NULL, // #478
NULL, // #479
e10, e10 // #480-499 (LordHavoc)