#include "csprogs.h"
#include "cl_collision.h"
#include "r_shadow.h"
+#include "jpeg.h"
+#include "image.h"
//============================================================================
// Client
start = PRVM_G_VECTOR(OFS_PARM2);
end = PRVM_G_VECTOR(OFS_PARM3);
+ if (i < 0)
+ return;
CL_ParticleEffect(i, VectorDistance(start, end), start, end, t->fields.client->velocity, t->fields.client->velocity, NULL, prog->argc >= 5 ? (int)PRVM_G_FLOAT(OFS_PARM4) : 0);
}
f = PRVM_G_VECTOR(OFS_PARM1);
v = PRVM_G_VECTOR(OFS_PARM2);
n = (int)PRVM_G_FLOAT(OFS_PARM3);
+ if (i < 0)
+ return;
CL_ParticleEffect(i, n, f, f, v, v, NULL, prog->argc >= 5 ? (int)PRVM_G_FLOAT(OFS_PARM4) : 0);
}
{
VM_SAFEPARMCOUNT(0,VM_CL_getmousepos);
- if (cl.csqc_wantsmousemove)
+ if (key_consoleactive || key_dest != key_game)
+ VectorSet(PRVM_G_VECTOR(OFS_RETURN), 0, 0, 0);
+ else if (cl.csqc_wantsmousemove)
VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_windowmouse_x * vid_conwidth.integer / vid.width, in_windowmouse_y * vid_conheight.integer / vid.height, 0);
else
VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_mouse_x * vid_conwidth.integer / vid.width, in_mouse_y * vid_conheight.integer / vid.height, 0);
strlcpy(t, cl.scores[i].name, sizeof(t));
else
if(!strcasecmp(c, "frags"))
- sprintf(t, "%i", cl.scores[i].frags);
+ dpsnprintf(t, sizeof(t), "%i", cl.scores[i].frags);
else
if(!strcasecmp(c, "ping"))
- sprintf(t, "%i", cl.scores[i].qw_ping);
+ dpsnprintf(t, sizeof(t), "%i", cl.scores[i].qw_ping);
else
if(!strcasecmp(c, "pl"))
- sprintf(t, "%i", cl.scores[i].qw_packetloss);
+ dpsnprintf(t, sizeof(t), "%i", cl.scores[i].qw_packetloss);
else
if(!strcasecmp(c, "entertime"))
- sprintf(t, "%f", cl.scores[i].qw_entertime);
+ dpsnprintf(t, sizeof(t), "%f", cl.scores[i].qw_entertime);
else
if(!strcasecmp(c, "colors"))
- sprintf(t, "%i", cl.scores[i].colors);
+ dpsnprintf(t, sizeof(t), "%i", cl.scores[i].colors);
else
if(!strcasecmp(c, "topcolor"))
- sprintf(t, "%i", cl.scores[i].colors & 0xf0);
+ dpsnprintf(t, sizeof(t), "%i", cl.scores[i].colors & 0xf0);
else
if(!strcasecmp(c, "bottomcolor"))
- sprintf(t, "%i", (cl.scores[i].colors &15)<<4);
+ dpsnprintf(t, sizeof(t), "%i", (cl.scores[i].colors &15)<<4);
else
if(!strcasecmp(c, "viewentity"))
- sprintf(t, "%i", i+1);
+ dpsnprintf(t, sizeof(t), "%i", i+1);
if(!t[0])
return;
PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(t);
PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadFloat();
}
+//#501 string() readpicture (DP_CSQC_READWRITEPICTURE)
+extern cvar_t cl_readpicture_force;
+static void VM_CL_ReadPicture (void)
+{
+ const char *name;
+ unsigned char *data;
+ unsigned char *buf;
+ int size;
+ int i;
+ cachepic_t *pic;
+
+ VM_SAFEPARMCOUNT(0, VM_CL_ReadPicture);
+
+ name = MSG_ReadString();
+ size = MSG_ReadShort();
+
+ // check if a texture of that name exists
+ // if yes, it is used and the data is discarded
+ // if not, the (low quality) data is used to build a new texture, whose name will get returned
+
+ pic = Draw_CachePic_Flags (name, CACHEPICFLAG_NOTPERSISTENT);
+
+ if(size)
+ {
+ if(pic->tex == r_texture_notexture)
+ pic->tex = NULL; // don't overwrite the notexture by Draw_NewPic
+ if(pic->tex && !cl_readpicture_force.integer)
+ {
+ // texture found and loaded
+ // skip over the jpeg as we don't need it
+ for(i = 0; i < size; ++i)
+ MSG_ReadByte();
+ }
+ else
+ {
+ // texture not found
+ // use the attached jpeg as texture
+ buf = Mem_Alloc(tempmempool, size);
+ MSG_ReadBytes(size, buf);
+ data = JPEG_LoadImage_BGRA(buf, size);
+ Mem_Free(buf);
+ Draw_NewPic(name, image_width, image_height, false, data);
+ Mem_Free(data);
+ }
+ }
+
+ PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(name);
+}
+
//////////////////////////////////////////////////////////
static void VM_CL_makestatic (void)
{
int surfacelistindex;
vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
+ R_Mesh_ResetTextureState();
R_Mesh_Matrix(&identitymatrix);
GL_CullFace(GL_NONE);
R_Mesh_VertexPointer(polys->data_vertex3f, 0, 0);
R_Mesh_ColorPointer(polys->data_color4f, 0, 0);
R_Mesh_TexCoordPointer(0, 2, polys->data_texcoord2f, 0, 0);
R_SetupGenericShader(true);
+
for (surfacelistindex = 0;surfacelistindex < numsurfaces;)
{
int numtriangles = 0;
return;
}
picname = PRVM_G_STRING(OFS_PARM0);
- polys->begin_texture = picname[0] ? Draw_CachePic (picname)->tex : r_texture_white;
+ polys->begin_texture = picname[0] ? Draw_CachePic_Flags (picname, CACHEPICFLAG_NOCLAMP)->tex : r_texture_white;
polys->begin_drawflag = (int)PRVM_G_FLOAT(OFS_PARM1);
polys->begin_vertices = 0;
polys->begin_active = true;
VM_drawsetcliparea, // #324 void(float x, float y, float width, float height) drawsetcliparea
VM_drawresetcliparea, // #325 void(void) drawresetcliparea
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?
+VM_stringwidth, // #327 // FIXME is this okay?
+VM_drawsubpic, // #328 // FIXME is this okay?
NULL, // #329
VM_CL_getstatf, // #330 float(float stnum) getstatf (EXT_CSQC)
VM_CL_getstati, // #331 float(float stnum) getstati (EXT_CSQC)
VM_gecko_get_texture_extent, // #493 vector gecko_get_texture_extent( string name )
VM_crc16, // #494 float(float caseinsensitive, string s, ...) crc16 = #494 (DP_QC_CRC16)
VM_cvar_type, // #495 float(string name) cvar_type = #495; (DP_QC_CVAR_TYPE)
-NULL, // #496
-NULL, // #497
-NULL, // #498
-NULL, // #499
-NULL, // #500
-NULL, // #501
+VM_numentityfields, // #496 float() numentityfields = #496; (QP_QC_ENTITYDATA)
+VM_entityfieldname, // #497 string(float fieldnum) entityfieldname = #497; (DP_QC_ENTITYDATA)
+VM_entityfieldtype, // #498 float(float fieldnum) entityfieldtype = #498; (DP_QC_ENTITYDATA)
+VM_getentityfieldstring, // #499 string(float fieldnum, entity ent) getentityfieldstring = #499; (DP_QC_ENTITYDATA)
+VM_putentityfieldstring, // #500 float(float fieldnum, entity ent, string s) putentityfieldstring = #500; (DP_QC_ENTITYDATA)
+VM_CL_ReadPicture, // #501 string() ReadPicture = #501;
NULL, // #502
-NULL, // #503
+VM_whichpack, // #503 string(string) whichpack = #503;
NULL, // #504
NULL, // #505
NULL, // #506