}
else
// objerror has to display the object fields -> else call
- PRVM_ERROR ("VM_objecterror: self not defined !\n");
+ PRVM_ERROR ("VM_objecterror: self not defined !");
}
/*
{
float *value1;
vec3_t newvalue;
- float new;
+ double f;
VM_SAFEPARMCOUNT(1,VM_normalize);
value1 = PRVM_G_VECTOR(OFS_PARM0);
- new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
- new = sqrt(new);
-
- if (new == 0)
- newvalue[0] = newvalue[1] = newvalue[2] = 0;
- else
+ f = VectorLength2(value1);
+ if (f)
{
- new = 1/new;
- newvalue[0] = value1[0] * new;
- newvalue[1] = value1[1] * new;
- newvalue[2] = value1[2] * new;
+ f = 1.0 / sqrt(f);
+ VectorScale(value1, f, newvalue);
}
+ else
+ VectorClear(newvalue);
VectorCopy (newvalue, PRVM_G_VECTOR(OFS_RETURN));
}
*/
void VM_vlen (void)
{
- float *value1;
- float new;
-
VM_SAFEPARMCOUNT(1,VM_vlen);
-
- value1 = PRVM_G_VECTOR(OFS_PARM0);
-
- new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
- new = sqrt(new);
-
- PRVM_G_FLOAT(OFS_RETURN) = new;
+ PRVM_G_FLOAT(OFS_RETURN) = VectorLength(PRVM_G_VECTOR(OFS_PARM0));
}
/*
name = PRVM_G_STRING(OFS_PARM0);
if(!name)
- PRVM_ERROR("VM_cvar_string: %s: null string\n", PRVM_NAME);
+ PRVM_ERROR("VM_cvar_string: %s: null string", PRVM_NAME);
VM_CheckEmptyString(name);
name = PRVM_G_STRING(OFS_PARM0);
if(!name)
- PRVM_ERROR("VM_cvar_defstring: %s: null string\n", PRVM_NAME);
+ PRVM_ERROR("VM_cvar_defstring: %s: null string", PRVM_NAME);
VM_CheckEmptyString(name);
ent = PRVM_G_FLOAT(OFS_PARM0);
if(PRVM_PROG_TO_EDICT(ent)->priv.required->free)
- PRVM_ERROR ("VM_ftoe: %s tried to access a freed entity (entity %i)!\n", PRVM_NAME, ent);
+ PRVM_ERROR ("VM_ftoe: %s tried to access a freed entity (entity %i)!", PRVM_NAME, ent);
PRVM_G_INT(OFS_RETURN) = ent;
}
PRVM_ED_Free (ed);
}
// if (ed == prog->edicts)
-// PRVM_ERROR ("remove: tried to remove world\n");
+// PRVM_ERROR ("remove: tried to remove world");
// if (PRVM_NUM_FOR_EDICT(ed) <= sv.maxclients)
-// Host_Error("remove: tried to remove a client\n");
+// Host_Error("remove: tried to remove a client");
}
/*
// is the same like !(prog->flag & PRVM_FE_CHAIN) - even if the operator precedence is another
if(!prog->flag & PRVM_FE_CHAIN)
- PRVM_ERROR("VM_findchain: %s doesnt have a chain field !\n", PRVM_NAME);
+ PRVM_ERROR("VM_findchain: %s doesnt have a chain field !", PRVM_NAME);
chain_of = PRVM_ED_FindField("chain")->ofs;
VM_SAFEPARMCOUNT(2, VM_findchainfloat);
if(!prog->flag & PRVM_FE_CHAIN)
- PRVM_ERROR("VM_findchainfloat: %s doesnt have a chain field !\n", PRVM_NAME);
+ PRVM_ERROR("VM_findchainfloat: %s doesnt have a chain field !", PRVM_NAME);
chain_of = PRVM_ED_FindField("chain")->ofs;
VM_SAFEPARMCOUNT(2, VM_findchainflags);
if(!prog->flag & PRVM_FE_CHAIN)
- PRVM_ERROR("VM_findchainflags: %s doesnt have a chain field !\n", PRVM_NAME);
+ PRVM_ERROR("VM_findchainflags: %s doesnt have a chain field !", PRVM_NAME);
chain_of = PRVM_ED_FindField("chain")->ofs;
{
VM_SAFEPARMCOUNT(0, VM_crash);
- PRVM_ERROR("Crash called by %s\n",PRVM_NAME);
+ PRVM_ERROR("Crash called by %s",PRVM_NAME);
}
/*
PRVM_G_FLOAT(OFS_RETURN) = f;
}
else
- PRVM_ERROR("VM_min: %s must supply at least 2 floats\n", PRVM_NAME);
+ PRVM_ERROR("VM_min: %s must supply at least 2 floats", PRVM_NAME);
}
/*
PRVM_G_FLOAT(OFS_RETURN) = f;
}
else
- PRVM_ERROR("VM_max: %s must supply at least 2 floats\n", PRVM_NAME);
+ PRVM_ERROR("VM_max: %s must supply at least 2 floats", PRVM_NAME);
}
/*
char *s;
if(prog->argc < 1)
- PRVM_ERROR("VM_strcat wrong parameter count (min. 1 expected ) !\n");
+ PRVM_ERROR("VM_strcat wrong parameter count (min. 1 expected ) !");
s = VM_GetTempString();
VM_VarString(0, s, VM_STRINGTEMP_LENGTH);
// get edict and test it
ent = PRVM_G_EDICT(OFS_PARM0);
if (ent->priv.required->free)
- PRVM_ERROR ("VM_parseentitydata: %s: Can only set already spawned entities (entity %i is free)!\n", PRVM_NAME, PRVM_NUM_FOR_EDICT(ent));
+ PRVM_ERROR ("VM_parseentitydata: %s: Can only set already spawned entities (entity %i is free)!", PRVM_NAME, PRVM_NUM_FOR_EDICT(ent));
data = PRVM_G_STRING(OFS_PARM1);
// parse the opening brace
if (!COM_ParseToken(&data, false) || com_token[0] != '{' )
- PRVM_ERROR ("VM_parseentitydata: %s: Couldn't parse entity data:\n%s\n", PRVM_NAME, data );
+ PRVM_ERROR ("VM_parseentitydata: %s: Couldn't parse entity data:\n%s", PRVM_NAME, data );
PRVM_ED_ParseEdict (data, ent);
}
void VM_loadfromfile(void)
{
const char *filename;
- qbyte *data;
+ char *data;
VM_SAFEPARMCOUNT(1,VM_loadfromfile);
}
// not conform with VM_fopen
- data = FS_LoadFile(filename, tempmempool, false);
+ data = (char *)FS_LoadFile(filename, tempmempool, false, NULL);
if (data == NULL)
PRVM_G_FLOAT(OFS_RETURN) = -1;
PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
if(!s)
- PRVM_ERROR ("VM_precache_pic: %s: NULL\n", PRVM_NAME);
+ PRVM_ERROR ("VM_precache_pic: %s: NULL", PRVM_NAME);
VM_CheckEmptyString (s);
s = PRVM_G_STRING(OFS_PARM0);
if(!s)
- PRVM_ERROR ("VM_freepic: %s: NULL\n");
+ PRVM_ERROR ("VM_freepic: %s: NULL");
VM_CheckEmptyString (s);
p = PRVM_G_STRING(OFS_PARM0);
if(!p)
- PRVM_ERROR("VM_getimagepos: %s passed null picture name !\n", PRVM_NAME);
+ PRVM_ERROR("VM_getimagepos: %s passed null picture name !", PRVM_NAME);
VM_CheckEmptyString (p);
name = PRVM_G_STRING( OFS_PARM0 );
VM_CheckEmptyString( name );
- state = PRVM_G_FLOAT( OFS_PARM1 );
+ state = (clvideostate_t)((int)PRVM_G_FLOAT( OFS_PARM1 ));
video = CL_GetVideo( name );
if( video && state > CLVIDEO_UNUSED && state < CLVIDEO_STATECOUNT )