+#include "quakedef.h"
+
#include "prvm_cmds.h"
#include "csprogs.h"
#include "cl_collision.h"
void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius);
void CSQC_RelinkAllEntities (int drawmask);
void CSQC_RelinkCSQCEntities (void);
-char *Key_GetBind (int key);
+const char *Key_GetBind (int key);
S_StartSound(32768 + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), entity->fields.client->origin, volume, attenuation);
}
+// #483 void(vector origin, string sample, float volume, float attenuation) pointsound
+static void VM_CL_pointsound(void)
+{
+ const char *sample;
+ float volume;
+ float attenuation;
+ vec3_t org;
+
+ VM_SAFEPARMCOUNT(4, VM_CL_pointsound);
+
+ VectorCopy( PRVM_G_VECTOR(OFS_PARM0), org);
+ sample = PRVM_G_STRING(OFS_PARM1);
+ volume = PRVM_G_FLOAT(OFS_PARM2);
+ attenuation = PRVM_G_FLOAT(OFS_PARM3);
+
+ if (volume < 0 || volume > 1)
+ {
+ VM_Warning("VM_CL_pointsound: volume must be in range 0-1\n");
+ return;
+ }
+
+ if (attenuation < 0 || attenuation > 4)
+ {
+ VM_Warning("VM_CL_pointsound: attenuation must be in range 0-4\n");
+ return;
+ }
+
+ // Send World Entity as Entity to Play Sound (for CSQC, that is 32768)
+ S_StartSound(32768, 0, S_FindName(sample), org, volume, attenuation);
+}
+
// #14 entity() spawn
static void VM_CL_spawn (void)
{
prvm_edict_t *ed;
ed = PRVM_ED_Alloc();
+ // FIXME: WTF.. this should be removed imo.. entnum points to the server.. [12/17/2007 Black]
ed->fields.client->entnum = PRVM_NUM_FOR_EDICT(ed); //[515]: not needed any more ?
VM_RETURN_EDICT(ed);
}
int move;
prvm_edict_t *ent;
- VM_SAFEPARMCOUNTRANGE(4, 8, VM_CL_traceline); // allow more parameters for future expansion
+ VM_SAFEPARMCOUNTRANGE(4, 4, VM_CL_traceline);
prog->xfunction->builtinsprofile += 30;
VM_SAFEPARMCOUNT(1, VM_CL_precache_model);
name = PRVM_G_STRING(OFS_PARM0);
- for (i = 1;i < MAX_MODELS && cl.csqc_model_precache[i];i++)
+ for (i = 0;i < MAX_MODELS && cl.csqc_model_precache[i];i++)
{
if(!strcmp(cl.csqc_model_precache[i]->name, name))
{
m = Mod_ForName(name, false, false, false);
if(m && m->loaded)
{
- for (i = 1;i < MAX_MODELS;i++)
+ for (i = 0;i < MAX_MODELS;i++)
{
if (!cl.csqc_model_precache[i])
{
switch(c)
{
- case VF_MIN: r_view.x = (int)(f[0] * vid.width / vid_conwidth.value);
- r_view.y = (int)(f[1] * vid.height / vid_conheight.value);
- break;
- case VF_MIN_X: r_view.x = (int)(k * vid.width / vid_conwidth.value);
- break;
- case VF_MIN_Y: r_view.y = (int)(k * vid.height / vid_conheight.value);
- break;
- case VF_SIZE: r_view.width = (int)(f[0] * vid.width / vid_conwidth.value);
- r_view.height = (int)(f[1] * vid.height / vid_conheight.value);
- break;
- case VF_SIZE_Y: r_view.width = (int)(k * vid.width / vid_conwidth.value);
- break;
- case VF_SIZE_X: r_view.height = (int)(k * vid.height / vid_conheight.value);
- break;
- case VF_VIEWPORT: r_view.x = (int)(f[0] * vid.width / vid_conwidth.value);
- r_view.y = (int)(f[1] * vid.height / vid_conheight.value);
- f = PRVM_G_VECTOR(OFS_PARM2);
- r_view.width = (int)(f[0] * vid.width / vid_conwidth.value);
- r_view.height = (int)(f[1] * vid.height / vid_conheight.value);
- break;
- case VF_FOV: r_view.frustum_x = tan(f[0] * M_PI / 360.0);r_view.ortho_x = f[0];
- r_view.frustum_y = tan(f[1] * M_PI / 360.0);r_view.ortho_y = f[1];
- break;
- case VF_FOVX: r_view.frustum_x = tan(k * M_PI / 360.0);r_view.ortho_x = k;
- break;
- case VF_FOVY: r_view.frustum_y = tan(k * M_PI / 360.0);r_view.ortho_y = k;
- break;
- case VF_ORIGIN: VectorCopy(f, cl.csqc_origin);
- CSQC_R_RecalcView();
- break;
- case VF_ORIGIN_X: cl.csqc_origin[0] = k;
- CSQC_R_RecalcView();
- break;
- case VF_ORIGIN_Y: cl.csqc_origin[1] = k;
- CSQC_R_RecalcView();
- break;
- case VF_ORIGIN_Z: cl.csqc_origin[2] = k;
- CSQC_R_RecalcView();
- break;
- case VF_ANGLES: VectorCopy(f, cl.csqc_angles);
- CSQC_R_RecalcView();
- break;
- case VF_ANGLES_X: cl.csqc_angles[0] = k;
- CSQC_R_RecalcView();
- break;
- case VF_ANGLES_Y: cl.csqc_angles[1] = k;
- CSQC_R_RecalcView();
- break;
- case VF_ANGLES_Z: cl.csqc_angles[2] = k;
- CSQC_R_RecalcView();
- break;
- case VF_DRAWWORLD: cl.csqc_vidvars.drawworld = k;
- break;
- case VF_DRAWENGINESBAR: cl.csqc_vidvars.drawenginesbar = k;
- break;
- case VF_DRAWCROSSHAIR: cl.csqc_vidvars.drawcrosshair = k;
- break;
-
- case VF_CL_VIEWANGLES: VectorCopy(f, cl.viewangles);
- break;
- case VF_CL_VIEWANGLES_X:cl.viewangles[0] = k;
- break;
- case VF_CL_VIEWANGLES_Y:cl.viewangles[1] = k;
- break;
- case VF_CL_VIEWANGLES_Z:cl.viewangles[2] = k;
- break;
-
- case VF_PERSPECTIVE: r_view.useperspective = k != 0;
- break;
-
- default: PRVM_G_FLOAT(OFS_RETURN) = 0;
- VM_Warning("VM_CL_R_SetView : unknown parm %i\n", c);
- return;
+ case VF_MIN:
+ r_view.x = (int)(f[0] * vid.width / vid_conwidth.value);
+ r_view.y = (int)(f[1] * vid.height / vid_conheight.value);
+ break;
+ case VF_MIN_X:
+ r_view.x = (int)(k * vid.width / vid_conwidth.value);
+ break;
+ case VF_MIN_Y:
+ r_view.y = (int)(k * vid.height / vid_conheight.value);
+ break;
+ case VF_SIZE:
+ r_view.width = (int)(f[0] * vid.width / vid_conwidth.value);
+ r_view.height = (int)(f[1] * vid.height / vid_conheight.value);
+ break;
+ case VF_SIZE_Y:
+ r_view.width = (int)(k * vid.width / vid_conwidth.value);
+ break;
+ case VF_SIZE_X:
+ r_view.height = (int)(k * vid.height / vid_conheight.value);
+ break;
+ case VF_VIEWPORT:
+ r_view.x = (int)(f[0] * vid.width / vid_conwidth.value);
+ r_view.y = (int)(f[1] * vid.height / vid_conheight.value);
+ f = PRVM_G_VECTOR(OFS_PARM2);
+ r_view.width = (int)(f[0] * vid.width / vid_conwidth.value);
+ r_view.height = (int)(f[1] * vid.height / vid_conheight.value);
+ break;
+ case VF_FOV:
+ r_view.frustum_x = tan(f[0] * M_PI / 360.0);r_view.ortho_x = f[0];
+ r_view.frustum_y = tan(f[1] * M_PI / 360.0);r_view.ortho_y = f[1];
+ break;
+ case VF_FOVX:
+ r_view.frustum_x = tan(k * M_PI / 360.0);r_view.ortho_x = k;
+ break;
+ case VF_FOVY:
+ r_view.frustum_y = tan(k * M_PI / 360.0);r_view.ortho_y = k;
+ break;
+ case VF_ORIGIN:
+ VectorCopy(f, cl.csqc_origin);
+ CSQC_R_RecalcView();
+ break;
+ case VF_ORIGIN_X:
+ cl.csqc_origin[0] = k;
+ CSQC_R_RecalcView();
+ break;
+ case VF_ORIGIN_Y:
+ cl.csqc_origin[1] = k;
+ CSQC_R_RecalcView();
+ break;
+ case VF_ORIGIN_Z:
+ cl.csqc_origin[2] = k;
+ CSQC_R_RecalcView();
+ break;
+ case VF_ANGLES:
+ VectorCopy(f, cl.csqc_angles);
+ CSQC_R_RecalcView();
+ break;
+ case VF_ANGLES_X:
+ cl.csqc_angles[0] = k;
+ CSQC_R_RecalcView();
+ break;
+ case VF_ANGLES_Y:
+ cl.csqc_angles[1] = k;
+ CSQC_R_RecalcView();
+ break;
+ case VF_ANGLES_Z:
+ cl.csqc_angles[2] = k;
+ CSQC_R_RecalcView();
+ break;
+ case VF_DRAWWORLD:
+ cl.csqc_vidvars.drawworld = k;
+ break;
+ case VF_DRAWENGINESBAR:
+ cl.csqc_vidvars.drawenginesbar = k;
+ break;
+ case VF_DRAWCROSSHAIR:
+ cl.csqc_vidvars.drawcrosshair = k;
+ break;
+ case VF_CL_VIEWANGLES:
+ VectorCopy(f, cl.viewangles);
+ break;
+ case VF_CL_VIEWANGLES_X:
+ cl.viewangles[0] = k;
+ break;
+ case VF_CL_VIEWANGLES_Y:
+ cl.viewangles[1] = k;
+ break;
+ case VF_CL_VIEWANGLES_Z:
+ cl.viewangles[2] = k;
+ break;
+ case VF_PERSPECTIVE:
+ r_view.useperspective = k != 0;
+ break;
+ default:
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ VM_Warning("VM_CL_R_SetView : unknown parm %i\n", c);
+ return;
}
PRVM_G_FLOAT(OFS_RETURN) = 1;
}
{
float *pos, *col;
matrix4x4_t matrix;
- VM_SAFEPARMCOUNTRANGE(3, 8, VM_CL_R_AddDynamicLight); // allow more than 3 because we may extend this in the future
+ VM_SAFEPARMCOUNTRANGE(3, 3, VM_CL_R_AddDynamicLight);
// if we've run out of dlights, just return
if (r_refdef.numlights >= MAX_DLIGHTS)
entity_t *staticent = &cl.static_entities[cl.num_static_entities++];
// copy it to the current state
+ memset(staticent, 0, sizeof(*staticent));
staticent->render.model = CL_GetModelByIndex((int)ent->fields.client->modelindex);
staticent->render.frame1 = staticent->render.frame2 = (int)ent->fields.client->frame;
staticent->render.framelerp = 0;
// make torchs play out of sync
staticent->render.frame1time = staticent->render.frame2time = lhrandom(-10, -1);
- staticent->render.colormap = (int)ent->fields.client->colormap; // no special coloring
staticent->render.skinnum = (int)ent->fields.client->skin;
staticent->render.effects = (int)ent->fields.client->effects;
staticent->render.alpha = 1;
}
else
Matrix4x4_CreateFromQuakeEntity(&staticent->render.matrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], staticent->render.scale);
- CL_UpdateRenderEntity(&staticent->render);
// either fullbright or lit
if (!(staticent->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
// turn off shadows from transparent objects
if (!(staticent->render.effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST)) && (staticent->render.alpha >= 1))
staticent->render.flags |= RENDER_SHADOW;
+
+ CL_UpdateRenderEntity(&staticent->render);
}
else
Con_Printf("Too many static entities");
colorLength = (int)PRVM_G_FLOAT(OFS_PARM2);
CL_FindNonSolidLocation(pos, pos2, 10);
CL_ParticleExplosion2(pos2, colorStart, colorLength);
- tempcolor = (unsigned char *)&palette_complete[(rand()%colorLength) + colorStart];
+ tempcolor = palette_rgb[(rand()%colorLength) + colorStart];
color[0] = tempcolor[0] * (2.0f / 255.0f);
color[1] = tempcolor[1] * (2.0f / 255.0f);
color[2] = tempcolor[2] * (2.0f / 255.0f);
// FIXME: implement rotation/scaling
VectorAdd(&(model->surfmesh.data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed->fields.client->origin, PRVM_G_VECTOR(OFS_RETURN));
}
+//PF_getsurfacepointattribute, // #486 vector(entity e, float s, float n, float a) getsurfacepointattribute = #486;
+// float SPA_POSITION = 0;
+// float SPA_S_AXIS = 1;
+// float SPA_R_AXIS = 2;
+// float SPA_T_AXIS = 3; // same as SPA_NORMAL
+// float SPA_TEXCOORDS0 = 4;
+// float SPA_LIGHTMAP0_TEXCOORDS = 5;
+// float SPA_LIGHTMAP0_COLOR = 6;
+// TODO: add some wrapper code and merge VM_CL/SV_getsurface* [12/16/2007 Black]
+static void VM_CL_getsurfacepointattribute(void)
+{
+ prvm_edict_t *ed;
+ model_t *model;
+ msurface_t *surface;
+ int pointnum;
+ int attributetype;
+ VM_SAFEPARMCOUNT(3, VM_CL_getsurfacenumpoints);
+ VectorClear(PRVM_G_VECTOR(OFS_RETURN));
+ ed = PRVM_G_EDICT(OFS_PARM0);
+ if (!(model = CL_GetModelFromEdict(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);
+ if (pointnum < 0 || pointnum >= surface->num_vertices)
+ return;
+
+ // FIXME: implement rotation/scaling
+ attributetype = (int) PRVM_G_FLOAT(OFS_PARM3);
+
+ switch( attributetype ) {
+ // float SPA_POSITION = 0;
+ case 0:
+ VectorAdd(&(model->surfmesh.data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed->fields.server->origin, PRVM_G_VECTOR(OFS_RETURN));
+ break;
+ // float SPA_S_AXIS = 1;
+ case 1:
+ VectorCopy(&(model->surfmesh.data_svector3f + 3 * surface->num_firstvertex)[pointnum * 3], PRVM_G_VECTOR(OFS_RETURN));
+ break;
+ // float SPA_R_AXIS = 2;
+ case 2:
+ VectorCopy(&(model->surfmesh.data_tvector3f + 3 * surface->num_firstvertex)[pointnum * 3], PRVM_G_VECTOR(OFS_RETURN));
+ break;
+ // float SPA_T_AXIS = 3; // same as SPA_NORMAL
+ case 3:
+ VectorCopy(&(model->surfmesh.data_normal3f + 3 * surface->num_firstvertex)[pointnum * 3], PRVM_G_VECTOR(OFS_RETURN));
+ break;
+ // float SPA_TEXCOORDS0 = 4;
+ case 4: {
+ float *ret = PRVM_G_VECTOR(OFS_RETURN);
+ float *texcoord = &(model->surfmesh.data_texcoordtexture2f + 2 * surface->num_firstvertex)[pointnum * 2];
+ ret[0] = texcoord[0];
+ ret[1] = texcoord[1];
+ ret[2] = 0.0f;
+ break;
+ }
+ // float SPA_LIGHTMAP0_TEXCOORDS = 5;
+ case 5: {
+ float *ret = PRVM_G_VECTOR(OFS_RETURN);
+ float *texcoord = &(model->surfmesh.data_texcoordlightmap2f + 2 * surface->num_firstvertex)[pointnum * 2];
+ ret[0] = texcoord[0];
+ ret[1] = texcoord[1];
+ ret[2] = 0.0f;
+ break;
+ }
+ // float SPA_LIGHTMAP0_COLOR = 6;
+ case 6:
+ // ignore alpha for now..
+ VectorCopy( &(model->surfmesh.data_normal3f + 4 * surface->num_firstvertex)[pointnum * 4], PRVM_G_VECTOR(OFS_RETURN));
+ break;
+ default:
+ VectorSet( PRVM_G_VECTOR(OFS_RETURN), 0.0f, 0.0f, 0.0f );
+ break;
+ }
+}
// #436 vector(entity e, float s) getsurfacenormal
static void VM_CL_getsurfacenormal(void)
{
VM_drawfill, // #323 float(vector position, vector size, vector rgb, float alpha, float flag) drawfill (EXT_CSQC)
VM_drawsetcliparea, // #324 void(float x, float y, float width, float height) drawsetcliparea
VM_drawresetcliparea, // #325 void(void) drawresetcliparea
-NULL, // #326
-NULL, // #327
-NULL, // #328
+VM_drawcolorcodedstring, // #326 float drawcolorcodedstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) (EXT_CSQC)
+NULL, // #327 // FIXME add stringwidth() here?
+NULL, // #328 // FIXME add drawsubpic() here?
NULL, // #329
VM_CL_getstatf, // #330 float(float stnum) getstatf (EXT_CSQC)
VM_CL_getstati, // #331 float(float stnum) getstati (EXT_CSQC)
VM_strtolower, // #480 string(string s) VM_strtolower (DP_QC_STRING_CASE_FUNCTIONS)
VM_strtoupper, // #481 string(string s) VM_strtoupper (DP_QC_STRING_CASE_FUNCTIONS)
VM_cvar_defstring, // #482 string(string s) cvar_defstring (DP_QC_CVAR_DEFSTRING)
-NULL, // #483
-NULL, // #484
-NULL, // #485
-NULL, // #486
-NULL, // #487
-NULL, // #488
-NULL, // #489
-NULL, // #490
-NULL, // #491
+VM_CL_pointsound, // #483 void(vector origin, string sample, float volume, float attenuation) (DP_SV_POINTSOUND)
+VM_strreplace, // #484 string(string search, string replace, string subject) strreplace (DP_QC_STRREPLACE)
+VM_strireplace, // #485 string(string search, string replace, string subject) strireplace (DP_QC_STRREPLACE)
+VM_CL_getsurfacepointattribute,// #486 vector(entity e, float s, float n, float a) getsurfacepointattribute = #486;
+#ifdef SUPPORT_GECKO
+VM_gecko_create, // #487
+VM_gecko_destroy, // #488
+VM_gecko_navigate, // #489
+VM_gecko_keyevent, // #490
+VM_gecko_movemouse, // #491
+#else
+NULL, // #487
+NULL, // #488
+NULL, // #489
+NULL, // #490
+NULL, // #491
+#endif
NULL, // #492
NULL, // #493
NULL, // #494
void VM_CL_Cmd_Init(void)
{
+ VM_Cmd_Init();
// TODO: replace vm_polygons stuff with a more general debugging polygon system, and make vm_polygons functions use that system
if(vm_polygons_initialized)
{
void VM_CL_Cmd_Reset(void)
{
+ VM_Cmd_Reset();
if(vm_polygons_initialized)
{
Mem_FreePool(&vm_polygons_pool);