#include "csprogs.h"
#include "cl_collision.h"
#include "r_shadow.h"
+#include "jpeg.h"
+#include "image.h"
//============================================================================
// Client
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_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)
-NULL, // #501
+VM_CL_ReadPicture, // #501 string() ReadPicture = #501;
NULL, // #502
-NULL, // #503
+VM_whichpack, // #503 string(string) whichpack = #503;
NULL, // #504
NULL, // #505
NULL, // #506
VM_uri_escape, // #510 string(string in) uri_escape = #510;
VM_uri_unescape, // #511 string(string in) uri_unescape = #511;
VM_etof, // #512 float(entity ent) num_for_edict = #512 (DP_QC_NUM_FOR_EDICT)
-NULL, // #513
+VM_uri_get, // #513 float(string uril, float id) uri_get = #512; (DP_QC_URI_GET)
NULL, // #514
NULL, // #515
NULL, // #516
NULL, // #517
NULL, // #518
NULL, // #519
+VM_keynumtostring, // #520 string keynumtostring(float keynum)
+VM_findkeysforcommand, // #521 string findkeysforcommand(string command)
};
const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t);