#include "progsvm.h"
#include "clprogdefs.h"
#include "csprogs.h"
+#include "cl_collision.h"
//============================================================================
// Client prog handling
Host_Error(va("CL_VM_Error: %s", errorstring));
}
-model_t *CSQC_GetModelByIndex(int modelindex)
-{
- if(!modelindex)
- return NULL;
- if (modelindex < 0)
- {
- modelindex = -(modelindex+1);
- if (modelindex < MAX_MODELS)
- return cl.csqc_model_precache[modelindex];
- }
- else
- {
- if(modelindex < MAX_MODELS)
- return cl.model_precache[modelindex];
- }
- return NULL;
-}
-
-model_t *CSQC_GetModelFromEntity(prvm_edict_t *ed)
-{
- if (!ed || ed->priv.server->free)
- return NULL;
- return CSQC_GetModelByIndex((int)ed->fields.client->modelindex);
-}
-
//[515]: set globals before calling R_UpdateView, WEIRD CRAP
static void CSQC_SetGlobals (void)
{
model_t *model;
matrix4x4_t tagmatrix, matrix2;
- model = CSQC_GetModelFromEntity(ed);
+ model = CL_GetModelFromEdict(ed);
if (!model)
return false;
e->render.skinnum = (int)ed->fields.client->skin;
e->render.effects |= e->render.model->flags2 & (EF_FULLBRIGHT | EF_ADDITIVE);
scale = 1;
- // FIXME: renderflags should be in the cl_entvars_t
-#if 1
renderflags = 0;
if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.renderflags)) && val->_float) renderflags = (int)val->_float;
-#else
- renderflags = (int)ed->fields.client->renderflags;
-#endif
-
if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.alpha)) && val->_float) e->render.alpha = val->_float;
if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.scale)) && val->_float) e->render.scale = scale = val->_float;
if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.colormod)) && VectorLength2(val->vector)) VectorCopy(val->vector, e->render.colormod);
vec3_t left;
VectorNegate(prog->globals.client->v_right, left);
Matrix4x4_FromVectors(&matrix2, prog->globals.client->v_forward, left, prog->globals.client->v_up, ed->fields.client->origin);
+ Matrix4x4_Scale(&matrix2, scale, 1);
}
else
{
CSQC_END
}
-void CL_LinkEdict(prvm_edict_t *ent)
-{
- if (ent == prog->edicts)
- return; // don't add the world
-
- if (ent->priv.server->free)
- return;
-
- VectorAdd(ent->fields.client->origin, ent->fields.client->mins, ent->fields.client->absmin);
- VectorAdd(ent->fields.client->origin, ent->fields.client->maxs, ent->fields.client->absmax);
-
- World_LinkEdict(&cl.world, ent, ent->fields.client->absmin, ent->fields.client->absmax);
-}
-
void CL_VM_CB_BeginIncreaseEdicts(void)
{
int i;
PRVM_LoadProgs(csqc_progname.string, cl_numrequiredfunc, cl_required_func, 0, NULL, 0, NULL);
- if(prog->loaded)
- Con_Printf("CSQC ^5loaded (crc=%i, size=%i)\n", csprogsdatacrc, (int)csprogsdatasize);
- else
+ if (!prog->loaded)
{
CL_VM_Error("CSQC ^2failed to load\n");
if(!sv.active)
return;
}
+ Con_Printf("CSQC ^5loaded (crc=%i, size=%i)\n", csprogsdatacrc, (int)csprogsdatasize);
+
+ // check if OP_STATE animation is possible in this dat file
+ if (prog->fieldoffsets.nextthink >= 0 && prog->fieldoffsets.frame >= 0 && prog->fieldoffsets.think >= 0 && prog->globaloffsets.self >= 0)
+ prog->flag |= PRVM_OP_STATE;
+
//[515]: optional fields & funcs
if(prog->funcoffsets.CSQC_Parse_Print)
{