VM_SAFEPARMCOUNT(2, VM_CL_setmodel);
e = PRVM_G_EDICT(OFS_PARM0);
+ e->fields.client->modelindex = 0;
+ e->fields.client->model = 0;
+
m = PRVM_G_STRING(OFS_PARM1);
+ mod = NULL;
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);
+ mod = cl.csqc_model_precache[i];
+ e->fields.client->model = PRVM_SetEngineString(mod->name);
e->fields.client->modelindex = -(i+1);
- return;
+ break;
}
}
- for (i = 0;i < MAX_MODELS;i++)
- {
- mod = cl.model_precache[i];
- if (mod && !strcmp(mod->name, m))
+ if( !mod ) {
+ for (i = 0;i < MAX_MODELS;i++)
{
- e->fields.client->model = PRVM_SetEngineString(mod->name);
- e->fields.client->modelindex = i;
- return;
+ mod = cl.model_precache[i];
+ if (mod && !strcmp(mod->name, m))
+ {
+ e->fields.client->model = PRVM_SetEngineString(mod->name);
+ e->fields.client->modelindex = i;
+ break;
+ }
}
}
- e->fields.client->modelindex = 0;
- e->fields.client->model = 0;
- VM_Warning ("setmodel: model '%s' not precached\n", m);
-
- // TODO: check if this breaks needed consistency and maybe add a cvar for it too?? [1/10/2008 Black]
- if (mod)
- {
+ 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);
- }
+ }
else
+ {
SetMinMaxSize (e, vec3_origin, vec3_origin);
+ VM_Warning ("setmodel: model '%s' not precached\n", m);
+ }
}
// #4 void(entity e, vector min, vector max) setsize
cl.csqc_server2csqcentitynumber[realentnum] = 0;
}
else
- Con_Printf("Smth bad happens in csqc...\n"); //[515]: never happens ?
+ Con_Printf("Bad csqc_server2csqcentitynumber map\n"); //[515]: never happens ?
}
else
{
if(!prog->globals.client->self)
{
- prvm_edict_t *ed;
- ed = PRVM_ED_Alloc();
- ed->fields.client->entnum = realentnum;
- prog->globals.client->self = cl.csqc_server2csqcentitynumber[realentnum] = PRVM_EDICT_TO_PROG(ed);
- PRVM_G_FLOAT(OFS_PARM0) = 1;
+ if(!prog->funcoffsets.CSQC_Ent_Spawn)
+ {
+ prvm_edict_t *ed;
+ ed = PRVM_ED_Alloc();
+ ed->fields.client->entnum = realentnum;
+ prog->globals.client->self = cl.csqc_server2csqcentitynumber[realentnum] = PRVM_EDICT_TO_PROG(ed);
+ PRVM_G_FLOAT(OFS_PARM0) = 1;
+ PRVM_ExecuteProgram(prog->funcoffsets.CSQC_Ent_Update, "QC function CSQC_Ent_Update is missing");
+ }
+ else
+ {
+ // entity( float entnum ) CSQC_Ent_Spawn;
+ // the qc function should set entnum, too (this way it also can return world [2/1/2008 Andreas]
+ PRVM_G_FLOAT(OFS_PARM0) = (float) realentnum;
+ // make sure no one gets wrong ideas
+ prog->globals.client->self = 0;
+ PRVM_ExecuteProgram(prog->funcoffsets.CSQC_Ent_Spawn, "QC function CSQC_Ent_Spawn is missing");
+ cl.csqc_server2csqcentitynumber[realentnum] = PRVM_EDICT( PRVM_G_INT( OFS_RETURN ) );
+ }
}
- else
+ else {
PRVM_G_FLOAT(OFS_PARM0) = 0;
- PRVM_ExecuteProgram(prog->funcoffsets.CSQC_Ent_Update, "QC function CSQC_Ent_Update is missing");
+ PRVM_ExecuteProgram(prog->funcoffsets.CSQC_Ent_Update, "QC function CSQC_Ent_Update is missing");
+ }
}
}
prog->globals.client->self = oldself;
{
func_t CSQC_ConsoleCommand; // csqc
func_t CSQC_Ent_Remove; // csqc
+ func_t CSQC_Ent_Spawn; // csqc DP_CSQC_ENT_SPAWN extension (BlackHC - TODO: needs to be added to dpextensions.qc)
func_t CSQC_Ent_Update; // csqc
func_t CSQC_Event; // csqc [515]: engine call this for its own needs so csqc can do some things according to what engine it's running on. example: to say about edicts increase, whatever...
func_t CSQC_Event_Sound; // csqc : called by engine when an incoming sound packet arrives so CSQC can act on it
void PRVM_ED_LoadFromFile (const char *data);
-prvm_edict_t *PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline);
-#define PRVM_EDICT_NUM(n) (((unsigned)(n) < (unsigned int)prog->max_edicts) ? prog->edicts + (n) : PRVM_EDICT_NUM_ERROR(n, __FILE__, __LINE__))
+unsigned PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline);
+#define PRVM_EDICT(n) (((unsigned)(n) < (unsigned int)prog->max_edicts) ? n : PRVM_EDICT_NUM_ERROR(n, __FILE__, __LINE__))
+#define PRVM_EDICT_NUM(n) (prog->edicts + PRVM_EDICT(n))
//int NUM_FOR_EDICT_ERROR(prvm_edict_t *e);
#define PRVM_NUM_FOR_EDICT(e) ((int)((prvm_edict_t *)(e) - prog->edicts))
prog->funcoffsets.CSQC_ConsoleCommand = PRVM_ED_FindFunctionOffset("CSQC_ConsoleCommand");
prog->funcoffsets.CSQC_Ent_Remove = PRVM_ED_FindFunctionOffset("CSQC_Ent_Remove");
prog->funcoffsets.CSQC_Ent_Update = PRVM_ED_FindFunctionOffset("CSQC_Ent_Update");
+ prog->funcoffsets.CSQC_Ent_Spawn = PRVM_ED_FindFunctionOffset("CSQC_Ent_Spawn");
prog->funcoffsets.CSQC_Event = PRVM_ED_FindFunctionOffset("CSQC_Event");
prog->funcoffsets.CSQC_Event_Sound = PRVM_ED_FindFunctionOffset("CSQC_Event_Sound");
prog->funcoffsets.CSQC_Init = PRVM_ED_FindFunctionOffset("CSQC_Init");
}
// LordHavoc: turned PRVM_EDICT_NUM into a #define for speed reasons
-prvm_edict_t *PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline)
+unsigned PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline)
{
PRVM_ERROR ("PRVM_EDICT_NUM: %s: bad number %i (called at %s:%i)", PRVM_NAME, n, filename, fileline);
- return NULL;
+ return 0;
}
/*