DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
csprogs.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CL_MAX_EDICTS   MAX_EDICTS
 
#define ENTMASK_ENGINE   1
 
#define ENTMASK_ENGINEVIEWMODELS   2
 
#define ENTMASK_NORMAL   4
 
#define RF_ADDITIVE   8
 
#define RF_DEPTHHACK   4
 
#define RF_DYNAMICMODELLIGHT   8192
 
#define RF_EXTERNALMODEL   2
 
#define RF_FULLBRIGHT   256
 
#define RF_MODELLIGHT   4096
 
#define RF_NOSHADOW   512
 
#define RF_USEAXIS   16
 
#define RF_USETRANSPARENTOFFSET   64
 
#define RF_VIEWMODEL   1
 
#define RF_WORLDOBJECT   128
 
#define VF_ANGLES   15
 
#define VF_ANGLES_X   16
 
#define VF_ANGLES_Y   17
 
#define VF_ANGLES_Z   18
 
#define VF_CL_VIEWANGLES   33
 
#define VF_CL_VIEWANGLES_X   34
 
#define VF_CL_VIEWANGLES_Y   35
 
#define VF_CL_VIEWANGLES_Z   36
 
#define VF_CLEARSCREEN   201
 
#define VF_DRAWCROSSHAIR   21
 
#define VF_DRAWENGINESBAR   20
 
#define VF_DRAWWORLD   19
 
#define VF_FOG_ALPHA   207
 
#define VF_FOG_COLOR   203
 
#define VF_FOG_COLOR_B   206
 
#define VF_FOG_COLOR_G   205
 
#define VF_FOG_COLOR_R   204
 
#define VF_FOG_DENSITY   202
 
#define VF_FOG_END   209
 
#define VF_FOG_FADEDEPTH   211
 
#define VF_FOG_HEIGHT   210
 
#define VF_FOG_START   208
 
#define VF_FOV   8
 
#define VF_FOVX   9
 
#define VF_FOVY   10
 
#define VF_MAINVIEW   400
 
#define VF_MIN   1
 
#define VF_MIN_X   2
 
#define VF_MIN_Y   3
 
#define VF_MINFPS_QUALITY   401
 
#define VF_ORIGIN   11
 
#define VF_ORIGIN_X   12
 
#define VF_ORIGIN_Y   13
 
#define VF_ORIGIN_Z   14
 
#define VF_PERSPECTIVE   200
 
#define VF_SIZE   4
 
#define VF_SIZE_X   5
 
#define VF_SIZE_Y   6
 
#define VF_VIEWPORT   7
 

Functions

void CL_GetEntityMatrix (prvm_prog_t *prog, prvm_edict_t *ent, matrix4x4_t *out, qbool viewmatrix)
 
model_tCL_GetModelByIndex (int modelindex)
 
int CL_GetPitchSign (prvm_prog_t *prog, prvm_edict_t *ent)
 
int CL_GetTagMatrix (prvm_prog_t *prog, matrix4x4_t *out, prvm_edict_t *ent, int tagindex, prvm_vec_t *shadingorigin)
 
qbool CL_VM_ConsoleCommand (const char *text, size_t textlen)
 
qbool CL_VM_Event_Sound (int sound_num, float volume, int channel, float attenuation, int ent, vec3_t pos, int flags, float speed)
 
qbool CL_VM_GetEntitySoundOrigin (int entnum, vec3_t out)
 
int CL_VM_GetViewEntity (void)
 
void CL_VM_Init (void)
 
qbool CL_VM_InputEvent (int eventtype, float x, float y)
 
void CL_VM_Parse_CenterPrint (const char *msg, size_t msg_len)
 
void CL_VM_Parse_StuffCmd (const char *msg, size_t msg_len)
 
qbool CL_VM_Parse_TempEntity (void)
 
void CL_VM_PreventInformationLeaks (void)
 
void CL_VM_ShutDown (void)
 
qbool CL_VM_TransformView (int entnum, matrix4x4_t *viewmatrix, mplane_t *clipplane, vec3_t visorigin)
 
void CL_VM_UpdateDmgGlobals (int dmg_take, int dmg_save, vec3_t dmg_origin)
 
void CL_VM_UpdateIntermissionState (int intermission)
 
void CL_VM_UpdateShowingScoresState (int showingscores)
 
void CSQC_AddPrintText (const char *msg, size_t msg_len)
 
qbool CSQC_AddRenderEdict (prvm_edict_t *ed, int edictnum)
 
void CSQC_Predraw (prvm_edict_t *ed)
 
void CSQC_R_RecalcView (void)
 
void CSQC_ReadEntities (void)
 
void CSQC_RelinkAllEntities (int drawmask)
 
void CSQC_RelinkCSQCEntities (void)
 
void CSQC_Think (prvm_edict_t *ed)
 
void CSQC_UpdateNetworkTimes (double newtime, double oldtime)
 
qbool MakeDownloadPacket (const char *filename, unsigned char *data, size_t len, int crc, int cnt, sizebuf_t *buf, int protocol)
 
void QW_CL_StartUpload (unsigned char *data, int size)
 

Variables

cvar_t csqc_lowres
 
cvar_t csqc_polygons_defaultmaterial_nocullface
 
cvar_t csqc_progcrc
 
cvar_t csqc_progname
 
cvar_t csqc_progsize
 

Macro Definition Documentation

◆ CL_MAX_EDICTS

#define CL_MAX_EDICTS   MAX_EDICTS

Definition at line 25 of file csprogs.h.

Referenced by CL_VM_Init().

◆ ENTMASK_ENGINE

#define ENTMASK_ENGINE   1

Definition at line 27 of file csprogs.h.

Referenced by CL_UpdateWorld(), and CSQC_RelinkAllEntities().

◆ ENTMASK_ENGINEVIEWMODELS

#define ENTMASK_ENGINEVIEWMODELS   2

Definition at line 28 of file csprogs.h.

Referenced by CL_UpdateWorld(), and CSQC_RelinkAllEntities().

◆ ENTMASK_NORMAL

#define ENTMASK_NORMAL   4

Definition at line 29 of file csprogs.h.

◆ RF_ADDITIVE

#define RF_ADDITIVE   8

Definition at line 84 of file csprogs.h.

Referenced by CSQC_AddRenderEdict().

◆ RF_DEPTHHACK

#define RF_DEPTHHACK   4

Definition at line 83 of file csprogs.h.

Referenced by CSQC_AddRenderEdict().

◆ RF_DYNAMICMODELLIGHT

#define RF_DYNAMICMODELLIGHT   8192

Definition at line 91 of file csprogs.h.

Referenced by CSQC_AddRenderEdict().

◆ RF_EXTERNALMODEL

#define RF_EXTERNALMODEL   2

Definition at line 82 of file csprogs.h.

Referenced by CSQC_AddRenderEdict().

◆ RF_FULLBRIGHT

#define RF_FULLBRIGHT   256

Definition at line 93 of file csprogs.h.

Referenced by CSQC_AddRenderEdict().

◆ RF_MODELLIGHT

#define RF_MODELLIGHT   4096

Definition at line 90 of file csprogs.h.

Referenced by CSQC_AddRenderEdict().

◆ RF_NOSHADOW

#define RF_NOSHADOW   512

Definition at line 94 of file csprogs.h.

Referenced by CSQC_AddRenderEdict().

◆ RF_USEAXIS

#define RF_USEAXIS   16

Definition at line 85 of file csprogs.h.

Referenced by CL_GetEntityMatrix(), and VM_CL_makestatic().

◆ RF_USETRANSPARENTOFFSET

#define RF_USETRANSPARENTOFFSET   64

Definition at line 88 of file csprogs.h.

Referenced by CSQC_AddRenderEdict().

◆ RF_VIEWMODEL

#define RF_VIEWMODEL   1

Definition at line 81 of file csprogs.h.

Referenced by CL_GetTagMatrix(), and CSQC_AddRenderEdict().

◆ RF_WORLDOBJECT

#define RF_WORLDOBJECT   128

Definition at line 89 of file csprogs.h.

Referenced by CSQC_AddRenderEdict().

◆ VF_ANGLES

#define VF_ANGLES   15

Definition at line 45 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_ANGLES_X

#define VF_ANGLES_X   16

Definition at line 46 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_ANGLES_Y

#define VF_ANGLES_Y   17

Definition at line 47 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_ANGLES_Z

#define VF_ANGLES_Z   18

Definition at line 48 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_CL_VIEWANGLES

#define VF_CL_VIEWANGLES   33

Definition at line 54 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_CL_VIEWANGLES_X

#define VF_CL_VIEWANGLES_X   34

Definition at line 55 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_CL_VIEWANGLES_Y

#define VF_CL_VIEWANGLES_Y   35

Definition at line 56 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_CL_VIEWANGLES_Z

#define VF_CL_VIEWANGLES_Z   36

Definition at line 57 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_CLEARSCREEN

#define VF_CLEARSCREEN   201

Definition at line 63 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_DRAWCROSSHAIR

#define VF_DRAWCROSSHAIR   21

Definition at line 52 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_DRAWENGINESBAR

#define VF_DRAWENGINESBAR   20

Definition at line 51 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_DRAWWORLD

#define VF_DRAWWORLD   19

Definition at line 50 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOG_ALPHA

#define VF_FOG_ALPHA   207

Definition at line 71 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOG_COLOR

#define VF_FOG_COLOR   203

Definition at line 67 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOG_COLOR_B

#define VF_FOG_COLOR_B   206

Definition at line 70 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOG_COLOR_G

#define VF_FOG_COLOR_G   205

Definition at line 69 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOG_COLOR_R

#define VF_FOG_COLOR_R   204

Definition at line 68 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOG_DENSITY

#define VF_FOG_DENSITY   202

Definition at line 66 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOG_END

#define VF_FOG_END   209

Definition at line 73 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOG_FADEDEPTH

#define VF_FOG_FADEDEPTH   211

Definition at line 75 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOG_HEIGHT

#define VF_FOG_HEIGHT   210

Definition at line 74 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOG_START

#define VF_FOG_START   208

Definition at line 72 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOV

#define VF_FOV   8

Definition at line 38 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOVX

#define VF_FOVX   9

Definition at line 39 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_FOVY

#define VF_FOVY   10

Definition at line 40 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_MAINVIEW

#define VF_MAINVIEW   400

Definition at line 78 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_MIN

#define VF_MIN   1

Definition at line 31 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_MIN_X

#define VF_MIN_X   2

Definition at line 32 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_MIN_Y

#define VF_MIN_Y   3

Definition at line 33 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_MINFPS_QUALITY

#define VF_MINFPS_QUALITY   401

Definition at line 79 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_ORIGIN

#define VF_ORIGIN   11

Definition at line 41 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_ORIGIN_X

#define VF_ORIGIN_X   12

Definition at line 42 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_ORIGIN_Y

#define VF_ORIGIN_Y   13

Definition at line 43 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_ORIGIN_Z

#define VF_ORIGIN_Z   14

Definition at line 44 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_PERSPECTIVE

#define VF_PERSPECTIVE   200

Definition at line 60 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_SIZE

#define VF_SIZE   4

Definition at line 34 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_SIZE_X

#define VF_SIZE_X   5

Definition at line 35 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_SIZE_Y

#define VF_SIZE_Y   6

Definition at line 36 of file csprogs.h.

Referenced by VM_CL_R_SetView().

◆ VF_VIEWPORT

#define VF_VIEWPORT   7

Definition at line 37 of file csprogs.h.

Referenced by VM_CL_R_SetView().

Function Documentation

◆ CL_GetEntityMatrix()

void CL_GetEntityMatrix ( prvm_prog_t * prog,
prvm_edict_t * ent,
matrix4x4_t * out,
qbool viewmatrix )

Definition at line 3230 of file clvm_cmds.c.

3231{
3232 float scale;
3233 float pitchsign = 1;
3234
3236 if (!scale)
3237 scale = 1.0f;
3238
3239 if(viewmatrix)
3240 *out = r_refdef.view.matrix;
3241 else if ((int)PRVM_clientedictfloat(ent, renderflags) & RF_USEAXIS)
3242 {
3244 vec3_t left;
3245 vec3_t up;
3246 vec3_t origin;
3251 Matrix4x4_FromVectors(out, forward, left, up, origin);
3252 }
3253 else
3254 {
3255 pitchsign = CL_GetPitchSign(prog, ent);
3257 }
3258}
int CL_GetPitchSign(prvm_prog_t *prog, prvm_edict_t *ent)
Definition clvm_cmds.c:3222
#define RF_USEAXIS
Definition csprogs.h:85
vector v_up
vector v_right
vector angles
vector v_forward
vector origin
float scale
r_refdef_t r_refdef
Definition gl_rmain.c:57
#define VectorCopy(in, out)
Definition mathlib.h:101
#define VectorScale(in, scale, out)
Definition mathlib.h:111
void Matrix4x4_CreateFromQuakeEntity(matrix4x4_t *out, double x, double y, double z, double pitch, double yaw, double roll, double scale)
Definition matrixlib.c:715
void Matrix4x4_FromVectors(matrix4x4_t *out, const float vx[3], const float vy[3], const float vz[3], const float t[3])
Definition matrixlib.c:970
#define PRVM_clientedictvector(ed, fieldname)
Definition progsvm.h:185
#define PRVM_clientglobalvector(fieldname)
Definition progsvm.h:190
#define PRVM_clientedictfloat(ed, fieldname)
Definition progsvm.h:184
vec_t vec3_t[3]
Definition qtypes.h:71
r_refdef_view_t view
Definition render.h:406
matrix4x4_t matrix
Definition render.h:266
static vec3_t forward
Definition sv_user.c:305
static vec3_t up
Definition sv_user.c:305

References angles, CL_GetPitchSign(), forward, r_refdef_view_t::matrix, Matrix4x4_CreateFromQuakeEntity(), Matrix4x4_FromVectors(), origin, PRVM_clientedictfloat, PRVM_clientedictvector, PRVM_clientglobalvector, r_refdef, RF_USEAXIS, scale, up, v_forward, v_right, v_up, VectorCopy, VectorScale, and r_refdef_t::view.

Referenced by CL_GetTagMatrix(), and getmatrix().

◆ CL_GetModelByIndex()

model_t * CL_GetModelByIndex ( int modelindex)

◆ CL_GetPitchSign()

int CL_GetPitchSign ( prvm_prog_t * prog,
prvm_edict_t * ent )

Definition at line 3222 of file clvm_cmds.c.

3223{
3224 model_t *model;
3225 if ((model = CL_GetModelFromEdict(ent)) && model->type == mod_alias)
3226 return -1;
3227 return 1;
3228}
model_t * CL_GetModelFromEdict(prvm_edict_t *ed)
string model
@ mod_alias

References CL_GetModelFromEdict(), mod_alias, and model.

Referenced by CL_GetEntityMatrix().

◆ CL_GetTagMatrix()

int CL_GetTagMatrix ( prvm_prog_t * prog,
matrix4x4_t * out,
prvm_edict_t * ent,
int tagindex,
prvm_vec_t * shadingorigin )

Definition at line 3286 of file clvm_cmds.c.

3287{
3288 int ret;
3289 int attachloop;
3290 matrix4x4_t entitymatrix, tagmatrix, attachmatrix;
3291 model_t *model;
3292 vec3_t shadingorigin;
3293
3294 *out = identitymatrix; // warnings and errors return identical matrix
3295
3296 if (ent == prog->edicts)
3297 return 1;
3298 if (ent->free)
3299 return 2;
3300
3302 if(!model)
3303 return 3;
3304
3305 tagmatrix = identitymatrix;
3306 attachloop = 0;
3307 for(;;)
3308 {
3309 if(attachloop >= 256)
3310 return 5;
3311 // apply transformation by child's tagindex on parent entity and then
3312 // by parent entity itself
3313 ret = CL_GetEntityLocalTagMatrix(prog, ent, tagindex - 1, &attachmatrix);
3314 if(ret && attachloop == 0)
3315 return ret;
3316 CL_GetEntityMatrix(prog, ent, &entitymatrix, false);
3317 Matrix4x4_Concat(&tagmatrix, &attachmatrix, out);
3318 Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
3319 // next iteration we process the parent entity
3321 {
3322 tagindex = (int)PRVM_clientedictfloat(ent, tag_index);
3324 }
3325 else
3326 break;
3327 attachloop++;
3328 }
3329
3330 // RENDER_VIEWMODEL magic
3331 if ((int)PRVM_clientedictfloat(ent, renderflags) & RF_VIEWMODEL)
3332 {
3333 Matrix4x4_Copy(&tagmatrix, out);
3334
3335 CL_GetEntityMatrix(prog, prog->edicts, &entitymatrix, true);
3336 Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
3337
3338 /*
3339 // Cl_bob, ported from rendering code
3340 if (PRVM_clientedictfloat(ent, health) > 0 && cl_bob.value && cl_bobcycle.value)
3341 {
3342 double bob, cycle;
3343 // LadyHavoc: this code is *weird*, but not replacable (I think it
3344 // should be done in QC on the server, but oh well, quake is quake)
3345 // LadyHavoc: figured out bobup: the time at which the sin is at 180
3346 // degrees (which allows lengthening or squishing the peak or valley)
3347 cycle = cl.time/cl_bobcycle.value;
3348 cycle -= (int)cycle;
3349 if (cycle < cl_bobup.value)
3350 cycle = sin(M_PI * cycle / cl_bobup.value);
3351 else
3352 cycle = sin(M_PI + M_PI * (cycle-cl_bobup.value)/(1.0 - cl_bobup.value));
3353 // bob is proportional to velocity in the xy plane
3354 // (don't count Z, or jumping messes it up)
3355 bob = sqrt(PRVM_clientedictvector(ent, velocity)[0]*PRVM_clientedictvector(ent, velocity)[0] + PRVM_clientedictvector(ent, velocity)[1]*PRVM_clientedictvector(ent, velocity)[1])*cl_bob.value;
3356 bob = bob*0.3 + bob*0.7*cycle;
3357 Matrix4x4_AdjustOrigin(out, 0, 0, bound(-7, bob, 4));
3358 }
3359 */
3360
3361 // return the origin of the view
3363 }
3364 else
3365 {
3366 // return the origin of the root entity in the chain
3367 Matrix4x4_OriginFromMatrix(out, shadingorigin);
3368 }
3369 if (returnshadingorigin)
3370 VectorCopy(shadingorigin, returnshadingorigin);
3371 return 0;
3372}
static int CL_GetEntityLocalTagMatrix(prvm_prog_t *prog, prvm_edict_t *ent, int tagindex, matrix4x4_t *out)
Definition clvm_cmds.c:3260
void CL_GetEntityMatrix(prvm_prog_t *prog, prvm_edict_t *ent, matrix4x4_t *out, qbool viewmatrix)
Definition clvm_cmds.c:3230
#define RF_VIEWMODEL
Definition csprogs.h:81
entity tag_entity
float tag_index
static int(ZEXPORT *qz_inflate)(z_stream *strm
void Matrix4x4_Concat(matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2)
Definition matrixlib.c:83
const matrix4x4_t identitymatrix
Definition matrixlib.c:9
void Matrix4x4_Copy(matrix4x4_t *out, const matrix4x4_t *in)
Definition matrixlib.c:19
void Matrix4x4_OriginFromMatrix(const matrix4x4_t *in, float *out)
Definition matrixlib.c:1792
#define PRVM_clientedictedict(ed, fieldname)
Definition progsvm.h:187
#define PRVM_EDICT_NUM(n)
Definition progsvm.h:867
return ret
qbool free
true if this edict is unused
Definition progsvm.h:93
prvm_edict_t * edicts
Definition progsvm.h:680

References CL_GetEntityLocalTagMatrix(), CL_GetEntityMatrix(), CL_GetModelFromEdict(), prvm_prog_t::edicts, prvm_edict_t::free, identitymatrix, int(), r_refdef_view_t::matrix, Matrix4x4_Concat(), Matrix4x4_Copy(), Matrix4x4_OriginFromMatrix(), model, PRVM_clientedictedict, PRVM_clientedictfloat, PRVM_EDICT_NUM, r_refdef, ret, RF_VIEWMODEL, tag_entity, tag_index, VectorCopy, and r_refdef_t::view.

Referenced by CL_VM_GetEntitySoundOrigin(), CSQC_AddRenderEdict(), VM_CL_gettaginfo(), and VM_CL_V_CalcRefdef().

◆ CL_VM_ConsoleCommand()

qbool CL_VM_ConsoleCommand ( const char * text,
size_t textlen )

Definition at line 573 of file csprogs.c.

574{
575 prvm_prog_t *prog = CLVM_prog;
576 return PRVM_ConsoleCommand(prog, text, textlen, &prog->funcoffsets.CSQC_ConsoleCommand, false, cl.csqc_server2csqcentitynumber[cl.playerentity], cl.time, "QC function CSQC_ConsoleCommand is missing");
577}
#define CLVM_prog
Definition progsvm.h:767
qbool PRVM_ConsoleCommand(prvm_prog_t *prog, const char *text, size_t textlen, int *func, qbool preserve_self, int curself, double ptime, const char *error_message)
Definition prvm_cmds.c:68
unsigned short csqc_server2csqcentitynumber[MAX_EDICTS]
Definition client.h:1110
double time
Definition client.h:868
int playerentity
Definition client.h:910
prvm_prog_funcoffsets_t funcoffsets
Definition progsvm.h:693

References cl, CLVM_prog, client_state_t::csqc_server2csqcentitynumber, prvm_prog_t::funcoffsets, client_state_t::playerentity, PRVM_ConsoleCommand(), and client_state_t::time.

Referenced by Cmd_CL_Callback().

◆ CL_VM_Event_Sound()

qbool CL_VM_Event_Sound ( int sound_num,
float volume,
int channel,
float attenuation,
int ent,
vec3_t pos,
int flags,
float speed )

Definition at line 721 of file csprogs.c.

722{
723 prvm_prog_t *prog = CLVM_prog;
724 qbool r = false;
725
726 if(prog->loaded)
727 {
728 if(PRVM_clientfunction(CSQC_Event_Sound))
729 {
732 PRVM_G_FLOAT(OFS_PARM0) = ent;
734 PRVM_G_INT(OFS_PARM2) = PRVM_SetTempString(prog, cl.sound_name[sound_num], strlen(cl.sound_name[sound_num]));
735 PRVM_G_FLOAT(OFS_PARM3) = fvolume;
736 PRVM_G_FLOAT(OFS_PARM4) = attenuation;
738 PRVM_G_FLOAT(OFS_PARM6) = speed * 100.0f;
739 PRVM_G_FLOAT(OFS_PARM7) = flags; // flags
740 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Event_Sound), "QC function CSQC_Event_Sound is missing");
741 r = CSQC_RETURNVAL != 0;
742 }
743 }
744
745 return r;
746}
#define CSQC_RETURNVAL
Definition csprogs.c:34
float flags
entity self
float time
float strlen(string s)
#define OFS_PARM4
Definition pr_comp.h:38
#define OFS_PARM2
Definition pr_comp.h:36
#define OFS_PARM3
Definition pr_comp.h:37
#define OFS_PARM5
Definition pr_comp.h:39
#define OFS_PARM6
Definition pr_comp.h:40
#define OFS_PARM0
Definition pr_comp.h:34
#define OFS_PARM1
Definition pr_comp.h:35
#define OFS_PARM7
Definition pr_comp.h:41
#define PRVM_clientfunction(funcname)
Definition progsvm.h:194
int PRVM_SetTempString(prvm_prog_t *prog, const char *s, size_t slen)
Takes an strlen (not a buffer size).
#define PRVM_clientglobaledict(fieldname)
Definition progsvm.h:192
#define PRVM_clientglobalfloat(fieldname)
Definition progsvm.h:189
#define PRVM_G_FLOAT(o)
Definition progsvm.h:882
#define PRVM_G_VECTOR(o)
Definition progsvm.h:886
#define PRVM_G_INT(o)
Definition progsvm.h:883
bool qbool
Definition qtypes.h:9
dp_FragColor r
#define CHAN_ENGINE2USER(c)
Definition sound.h:91
char sound_name[MAX_SOUNDS][MAX_QPATH]
Definition client.h:893
qbool loaded
used to indicate whether a prog is loaded
Definition progsvm.h:710
void(* ExecuteProgram)(struct prvm_prog_s *prog, func_t fnum, const char *errormessage)
pointer to one of the *VM_ExecuteProgram functions
Definition progsvm.h:749

References CHAN_ENGINE2USER, cl, CLVM_prog, CSQC_RETURNVAL, client_state_t::csqc_server2csqcentitynumber, prvm_prog_t::ExecuteProgram, flags, prvm_prog_t::loaded, OFS_PARM0, OFS_PARM1, OFS_PARM2, OFS_PARM3, OFS_PARM4, OFS_PARM5, OFS_PARM6, OFS_PARM7, client_state_t::playerentity, PRVM_clientfunction, PRVM_clientglobaledict, PRVM_clientglobalfloat, PRVM_G_FLOAT, PRVM_G_INT, PRVM_G_VECTOR, PRVM_SetTempString(), r, self, client_state_t::sound_name, strlen(), client_state_t::time, time, and VectorCopy.

Referenced by CL_ParseStartSoundPacket().

◆ CL_VM_GetEntitySoundOrigin()

qbool CL_VM_GetEntitySoundOrigin ( int entnum,
vec3_t out )

Definition at line 1172 of file csprogs.c.

1173{
1174 prvm_prog_t *prog = CLVM_prog;
1175 prvm_edict_t *ed;
1176 model_t *mod;
1177 matrix4x4_t matrix;
1178 qbool r = 0;
1179
1181
1182 if(!ed->free)
1183 {
1186 if(CL_GetTagMatrix(prog, &matrix, ed, 0, NULL) == 0)
1187 Matrix4x4_OriginFromMatrix(&matrix, out);
1188 if (mod && mod->soundfromcenter)
1189 VectorMAMAM(1.0f, out, 0.5f, mod->normalmins, 0.5f, mod->normalmaxs, out);
1190 r = 1;
1191 }
1192
1193 return r;
1194}
int CL_GetTagMatrix(prvm_prog_t *prog, matrix4x4_t *out, prvm_edict_t *ent, int tagindex, prvm_vec_t *returnshadingorigin)
Definition clvm_cmds.c:3286
float mod(float dividend, float divisor)
float entnum
#define VectorMAMAM(scale1, b1, scale2, b2, scale3, b3, out)
Definition mathlib.h:117
#define MAX_EDICTS
max number of objects in game world at once (32768 protocol limit)
Definition qdefs.h:105

References CL_GetModelFromEdict(), CL_GetTagMatrix(), CLVM_prog, entnum, prvm_edict_t::free, Matrix4x4_OriginFromMatrix(), MAX_EDICTS, mod(), NULL, origin, PRVM_clientedictvector, PRVM_EDICT_NUM, r, VectorCopy, and VectorMAMAM.

Referenced by SND_Spatialize_WithSfx(), and VM_CL_sound().

◆ CL_VM_GetViewEntity()

◆ CL_VM_Init()

void CL_VM_Init ( void )

Definition at line 980 of file csprogs.c.

981{
982 prvm_prog_t *prog = CLVM_prog;
983 const char* csprogsfn = NULL;
984 unsigned char *csprogsdata = NULL;
985 fs_offset_t csprogsdatasize = 0;
986 int csprogsdatacrc, requiredcrc;
987 int requiredsize;
988 char vabuf[1024];
989
990 // reset csqc_progcrc after reading it, so that changing servers doesn't
991 // expect csqc on the next server
992 requiredcrc = csqc_progcrc.integer;
993 requiredsize = csqc_progsize.integer;
996
997 // if the server is not requesting a csprogs, then we're done here
998 if (requiredcrc < 0)
999 return;
1000
1001 // see if the requested csprogs.dat file matches the requested crc
1003 {
1004 csprogsfn = va(vabuf, sizeof(vabuf), "dlcache/%s.%i.%i", csqc_progname.string, requiredsize, requiredcrc);
1005 if(cls.caughtcsprogsdata && cls.caughtcsprogsdatasize == requiredsize && CRC_Block(cls.caughtcsprogsdata, (size_t)cls.caughtcsprogsdatasize) == requiredcrc)
1006 {
1007 Con_DPrintf("Using buffered \"%s\"\n", csprogsfn);
1008 csprogsdata = cls.caughtcsprogsdata;
1009 csprogsdatasize = cls.caughtcsprogsdatasize;
1012 }
1013 else
1014 {
1015 Con_DPrintf("Not using buffered \"%s\" (buffered: %p, %d)\n", csprogsfn, (void *)cls.caughtcsprogsdata, (int) cls.caughtcsprogsdatasize);
1016 csprogsdata = FS_LoadFile(csprogsfn, tempmempool, true, &csprogsdatasize);
1017 }
1018 }
1019 if (!csprogsdata)
1020 {
1021 csprogsfn = csqc_progname.string;
1022 csprogsdata = FS_LoadFile(csprogsfn, tempmempool, true, &csprogsdatasize);
1023 }
1024 if (csprogsdata)
1025 {
1026 csprogsdatacrc = CRC_Block(csprogsdata, (size_t)csprogsdatasize);
1027 if (csprogsdatacrc != requiredcrc || csprogsdatasize != requiredsize)
1028 {
1029 if (cls.demoplayback)
1030 {
1031 Con_Printf(CON_WARN "Warning: Your %s is not the same version as the demo was recorded with (CRC/size are %i/%i but should be %i/%i)\n", csqc_progname.string, csprogsdatacrc, (int)csprogsdatasize, requiredcrc, requiredsize);
1032 // Mem_Free(csprogsdata);
1033 // return;
1034 // We WANT to continue here, and play the demo with different csprogs!
1035 // After all, this is just a warning. Sure things may go wrong from here.
1036 }
1037 else
1038 {
1039 Mem_Free(csprogsdata);
1040 CL_DisconnectEx(false, "Your %s is not the same version as the server (CRC is %i/%i but should be %i/%i)\n", csqc_progname.string, csprogsdatacrc, (int)csprogsdatasize, requiredcrc, requiredsize);
1041 return;
1042 }
1043 }
1044 }
1045 else
1046 {
1047 if (requiredcrc >= 0)
1048 CL_DisconnectEx(false, CON_ERROR "CL_VM_Init: %s requires CSQC, but \"%s\" wasn't found\n", cls.demoplayback ? "demo" : "server", csqc_progname.string);
1049 return;
1050 }
1051
1053
1054 // allocate the mempools
1056 prog->edictprivate_size = 0; // no private struct used
1057 prog->name = "client";
1058 prog->num_edicts = 1;
1059 prog->max_edicts = 512;
1061 prog->reserved_edicts = 0;
1063 // TODO: add a shared extension string #define and add real support for csqc extension strings [12/5/2007 Black]
1065 prog->builtins = vm_cl_builtins;
1067
1068 // all callbacks must be defined (pointers are not checked before calling)
1075 prog->init_cmd = CLVM_init_cmd;
1076 prog->reset_cmd = CLVM_reset_cmd;
1077 prog->error_cmd = Host_Error;
1079
1080 PRVM_Prog_Load(prog, csprogsfn, csprogsdata, csprogsdatasize, CL_CheckRequiredFuncs, CL_REQFIELDS, cl_reqfields, CL_REQGLOBALS, cl_reqglobals);
1081
1082 if (!prog->loaded)
1083 {
1084 Mem_Free(csprogsdata);
1085 Host_Error("CSQC %s failed to load\n", csprogsfn);
1086 }
1087
1088 if(cls.demorecording)
1089 {
1090 if(cls.demo_lastcsprogssize != csprogsdatasize || cls.demo_lastcsprogscrc != csprogsdatacrc)
1091 {
1092 int i;
1093 static char buf[NET_MAXMESSAGE];
1094 sizebuf_t sb;
1095 unsigned char *demobuf; fs_offset_t demofilesize;
1096
1097 sb.data = (unsigned char *) buf;
1098 sb.maxsize = sizeof(buf);
1099 i = 0;
1100
1101 CL_CutDemo(&demobuf, &demofilesize);
1102 while(MakeDownloadPacket(csqc_progname.string, csprogsdata, (size_t)csprogsdatasize, csprogsdatacrc, i++, &sb, cls.protocol))
1104 CL_PasteDemo(&demobuf, &demofilesize);
1105
1106 cls.demo_lastcsprogssize = csprogsdatasize;
1107 cls.demo_lastcsprogscrc = csprogsdatacrc;
1108 }
1109 }
1110 Mem_Free(csprogsdata);
1111
1112 // check if OP_STATE animation is possible in this dat file
1113 if (prog->fieldoffsets.nextthink >= 0 && prog->fieldoffsets.frame >= 0 && prog->fieldoffsets.think >= 0 && prog->globaloffsets.self >= 0)
1114 prog->flag |= PRVM_OP_STATE;
1115
1116 // set time
1119
1123
1124 // set map description (use world entity 0)
1133
1134 // call the prog init if it exists
1136 {
1137 PRVM_G_FLOAT(OFS_PARM0) = 1.0f; // CSQC_SIMPLE engines always pass 0, FTE always passes 1
1138 // always include "DarkPlaces" so it can be recognised when gamename doesn't include it
1139 PRVM_G_INT(OFS_PARM1) = PRVM_SetEngineString(prog, va(vabuf, sizeof(vabuf), "DarkPlaces %s", gamename));
1140 PRVM_G_FLOAT(OFS_PARM2) = 1.0f; // TODO DP versions...
1141 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Init), "QC function CSQC_Init is missing");
1142 }
1143
1144 // Once CSQC_Init was called, we consider csqc code fully initialized.
1145 prog->inittime = host.realtime;
1146
1149
1150 // Update Coop and Deathmatch Globals (at this point the client knows them from ServerInfo)
1152}
void CL_PasteDemo(unsigned char **buf, fs_offset_t *filesize)
Definition cl_demo.c:160
void CL_CutDemo(unsigned char **buf, fs_offset_t *filesize)
Definition cl_demo.c:137
void CL_WriteDemoMessage(sizebuf_t *message)
Definition cl_demo.c:110
void CL_DisconnectEx(qbool kicked, const char *fmt,...)
Definition cl_main.c:370
cvar_t csqc_progcrc
Definition cl_main.c:36
cvar_t csqc_progsize
Definition cl_main.c:37
cvar_t csqc_progname
Definition cl_main.c:35
client_static_t cls
Definition cl_main.c:116
void CLVM_init_cmd(prvm_prog_t *prog)
Definition clvm_cmds.c:5656
prvm_builtin_t vm_cl_builtins[]
Definition clvm_cmds.c:5003
void CLVM_reset_cmd(prvm_prog_t *prog)
Definition clvm_cmds.c:5663
const int vm_cl_numbuiltins
Definition clvm_cmds.c:5654
cmd_state_t * cmd_local
command interpreter for local commands injected by SVQC, CSQC, MQC, server or client engine code uses...
Definition cmd.c:25
unsigned short CRC_Block(const unsigned char *data, size_t size)
Definition com_crc16.c:75
const char * gamename
Definition com_game.c:27
char * va(char *buf, size_t buflen, const char *format,...)
Definition common.c:972
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
Definition console.c:1544
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
#define CON_WARN
Definition console.h:101
#define CON_ERROR
Definition console.h:102
prvm_required_field_t cl_reqglobals[]
Definition csprogs.c:145
qbool MakeDownloadPacket(const char *filename, unsigned char *data, size_t len, int crc, int cnt, sizebuf_t *buf, int protocol)
Definition csprogs.c:940
cvar_t csqc_usedemoprogs
Definition cl_main.c:38
static qbool CLVM_load_edict(prvm_prog_t *prog, prvm_edict_t *ent)
Definition csprogs.c:933
static void CLVM_init_edict(prvm_prog_t *prog, prvm_edict_t *e)
Definition csprogs.c:884
static void CL_VM_UpdateCoopDeathmatchGlobals(int gametype)
Definition csprogs.c:747
static void CLVM_begin_increase_edicts(prvm_prog_t *prog)
Definition csprogs.c:867
static void CL_CheckRequiredFuncs(prvm_prog_t *prog, const char *filename)
Previous DP versions declined to load csprogs if it lacked any of: CSQC_Init, CSQC_InputEvent,...
Definition csprogs.c:54
static void CLVM_end_increase_edicts(prvm_prog_t *prog)
Definition csprogs.c:873
static void CLVM_free_edict(prvm_prog_t *prog, prvm_edict_t *ed)
Definition csprogs.c:895
static void CLVM_count_edicts(prvm_prog_t *prog)
Definition csprogs.c:909
#define CL_REQGLOBALS
Definition csprogs.c:143
prvm_required_field_t cl_reqfields[]
Definition csprogs.c:66
#define CL_REQFIELDS
Definition csprogs.c:64
#define CL_MAX_EDICTS
Definition csprogs.h:25
string mapname
float player_localnum
vector mins
vector maxs
float player_localentnum
vector absmax
void CSQC_Init(float apilevel, string enginename, float engineversion)
float solid
vector absmin
void Cvar_SetValueQuick(cvar_t *var, float value)
Definition cvar.c:473
unsigned char * FS_LoadFile(const char *path, mempool_t *pool, qbool quiet, fs_offset_t *filesizepointer)
Definition fs.c:3540
int64_t fs_offset_t
Definition fs.h:37
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition glquake.h:657
host_static_t host
Definition host.c:41
void Host_Error(const char *error,...)
Definition host.c:85
string message
Definition progsdefs.qc:205
#define PRVM_OP_STATE
Definition progsvm.h:238
void PRVM_Prog_Load(prvm_prog_t *prog, const char *filename, unsigned char *data, fs_offset_t size, void CheckRequiredFuncs(prvm_prog_t *prog, const char *filename), int numrequiredfields, prvm_required_field_t *required_field, int numrequiredglobals, prvm_required_field_t *required_global)
void PRVM_Prog_Init(prvm_prog_t *prog, struct cmd_state_s *cmd)
Initializing a vm: Call InitProg with the num Set up the fields marked with [INIT] in the prog struct...
int PRVM_SetEngineString(prvm_prog_t *prog, const char *s)
const char * vm_sv_extensions[]
client also uses this
Definition svvm_cmds.c:11
#define PRVM_clientedictstring(ed, fieldname)
Definition progsvm.h:186
void CLVM_ExecuteProgram(prvm_prog_t *prog, func_t fnum, const char *errormessage)
Definition prvm_exec.c:1086
#define PRVM_clientglobalstring(fieldname)
Definition progsvm.h:191
int i
#define NET_MAXMESSAGE
max reliable packet size (sent as multiple fragments of MAX_PACKETFRAGMENT)
Definition qdefs.h:103
#define SOLID_BSP
bsp clip, touch on edge, block
Definition server.h:336
int realplayerentity
Definition client.h:905
char worldbasename[MAX_QPATH]
Definition client.h:898
struct model_s * worldmodel
Definition client.h:934
world_t world
Definition client.h:1122
char worldmessage[MAX_QPATH]
Definition client.h:896
csqc_vidvars_t csqc_vidvars
Definition client.h:834
unsigned char * caughtcsprogsdata
Definition client.h:688
qbool demoplayback
Definition client.h:587
int demo_lastcsprogscrc
Definition client.h:586
fs_offset_t demo_lastcsprogssize
Definition client.h:585
qbool demorecording
Definition client.h:584
fs_offset_t caughtcsprogsdatasize
Definition client.h:689
protocolversion_t protocol
Definition client.h:617
qbool drawenginesbar
Definition client.h:707
qbool drawcrosshair
Definition client.h:708
int integer
Definition cvar.h:73
const char * string
Definition cvar.h:71
double realtime
the accumulated mainloop time since application started (with filtering), without any slowmo or clamp...
Definition host.h:46
void(* reset_cmd)(struct prvm_prog_s *prog)
[INIT] used by PRVM_ResetProg
Definition progsvm.h:745
int numbuiltins
Definition progsvm.h:605
prvm_builtin_t * builtins
Definition progsvm.h:604
int edictprivate_size
size of the engine private struct
Definition progsvm.h:689
const char * name
name of the prog, e.g. "Server", "Client" or "Menu" (used for text output)
Definition progsvm.h:700
void(* begin_increase_edicts)(struct prvm_prog_s *prog)
[INIT] used by PRVM_MEM_Increase_Edicts
Definition progsvm.h:734
void(* free_edict)(struct prvm_prog_s *prog, prvm_edict_t *ed)
[INIT] used by PRVM_ED_Free
Definition progsvm.h:738
void(* error_cmd)(const char *format,...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN
[INIT]
Definition progsvm.h:747
int num_edicts
copies of some vars that were former read from sv
Definition progsvm.h:671
prvm_prog_fieldoffsets_t fieldoffsets
Definition progsvm.h:691
void(* count_edicts)(struct prvm_prog_s *prog)
[INIT] used by PRVM_ED_Count_f
Definition progsvm.h:740
double inittime
system time when QC initialization code finished (any entity created before is not a leak)
Definition progsvm.h:539
int limit_edicts
used instead of the constant MAX_EDICTS
Definition progsvm.h:675
prvm_prog_globaloffsets_t globaloffsets
Definition progsvm.h:692
unsigned flag
flag - used to store general flags like PRVM_GE_SELF, etc.
Definition progsvm.h:703
void(* init_edict)(struct prvm_prog_s *prog, prvm_edict_t *edict)
[INIT] used by PRVM_ED_ClearEdict
Definition progsvm.h:737
mempool_t * progs_mempool
all memory allocations related to this vm_prog (code, edicts, strings)
Definition progsvm.h:602
int max_edicts
number of edicts for which space has been (should be) allocated
Definition progsvm.h:673
qbool(* load_edict)(struct prvm_prog_s *prog, prvm_edict_t *ent)
[INIT] used by PRVM_ED_LoadFromFile
Definition progsvm.h:742
void(* init_cmd)(struct prvm_prog_s *prog)
[INIT] used by PRVM_InitProg
Definition progsvm.h:744
const char ** extensionstring
Definition progsvm.h:705
void(* end_increase_edicts)(struct prvm_prog_s *prog)
[INIT]
Definition progsvm.h:735
int reserved_edicts
number of reserved edicts (allocated from 1)
Definition progsvm.h:678
unsigned char * data
Definition common.h:52
int maxsize
Definition common.h:53
vec3_t maxs
Definition world.h:72
vec3_t mins
Definition world.h:71
mempool_t * tempmempool
Definition zone.c:794
#define Mem_Free(mem)
Definition zone.h:96
#define Mem_AllocPool(name, flags, parent)
Definition zone.h:104

References absmax, absmin, prvm_prog_t::begin_increase_edicts, buf, prvm_prog_t::builtins, client_static_t::caughtcsprogsdata, client_static_t::caughtcsprogsdatasize, cl, CL_CheckRequiredFuncs(), CL_CutDemo(), CL_DisconnectEx(), CL_MAX_EDICTS, CL_PasteDemo(), CL_REQFIELDS, cl_reqfields, CL_REQGLOBALS, cl_reqglobals, CL_VM_UpdateCoopDeathmatchGlobals(), CL_WriteDemoMessage(), cls, CLVM_begin_increase_edicts(), CLVM_count_edicts(), CLVM_end_increase_edicts(), CLVM_ExecuteProgram(), CLVM_free_edict(), CLVM_init_cmd(), CLVM_init_edict(), CLVM_load_edict(), CLVM_prog, CLVM_reset_cmd(), cmd_local, Con_DPrintf(), CON_ERROR, Con_Printf(), CON_WARN, prvm_prog_t::count_edicts, CRC_Block(), CSQC_Init(), csqc_progcrc, csqc_progname, csqc_progsize, csqc_usedemoprogs, client_state_t::csqc_vidvars, Cvar_SetValueQuick(), sizebuf_t::data, client_static_t::demo_lastcsprogscrc, client_static_t::demo_lastcsprogssize, client_static_t::demoplayback, client_static_t::demorecording, csqc_vidvars_t::drawcrosshair, csqc_vidvars_t::drawenginesbar, prvm_prog_t::edictprivate_size, prvm_prog_t::edicts, prvm_prog_t::end_increase_edicts, prvm_prog_t::error_cmd, prvm_prog_t::ExecuteProgram, prvm_prog_t::extensionstring, prvm_prog_t::fieldoffsets, prvm_prog_t::flag, prvm_prog_t::free_edict, FS_LoadFile(), gamename, client_state_t::gametype, prvm_prog_t::globaloffsets, host, Host_Error(), i, prvm_prog_t::init_cmd, prvm_prog_t::init_edict, prvm_prog_t::inittime, cvar_t::integer, prvm_prog_t::limit_edicts, prvm_prog_t::load_edict, prvm_prog_t::loaded, MakeDownloadPacket(), mapname, prvm_prog_t::max_edicts, maxs, world_t::maxs, sizebuf_t::maxsize, Mem_AllocPool, Mem_Free, message, mins, world_t::mins, model, modelindex, prvm_prog_t::name, NET_MAXMESSAGE, NULL, prvm_prog_t::num_edicts, prvm_prog_t::numbuiltins, OFS_PARM0, OFS_PARM1, OFS_PARM2, player_localentnum, player_localnum, prvm_prog_t::progs_mempool, client_static_t::protocol, PRVM_clientedictfloat, PRVM_clientedictstring, PRVM_clientedictvector, PRVM_clientfunction, PRVM_clientglobaledict, PRVM_clientglobalfloat, PRVM_clientglobalstring, PRVM_G_FLOAT, PRVM_G_INT, PRVM_OP_STATE, PRVM_Prog_Init(), PRVM_Prog_Load(), PRVM_SetEngineString(), client_state_t::realplayerentity, host_static_t::realtime, prvm_prog_t::reserved_edicts, prvm_prog_t::reset_cmd, self, solid, SOLID_BSP, cvar_t::string, tempmempool, client_state_t::time, time, va(), VectorCopy, client_state_t::viewentity, vm_cl_builtins, vm_cl_numbuiltins, vm_sv_extensions, client_state_t::world, client_state_t::worldbasename, client_state_t::worldmessage, and client_state_t::worldmodel.

Referenced by CL_SetupWorldModel().

◆ CL_VM_InputEvent()

qbool CL_VM_InputEvent ( int eventtype,
float x,
float y )

Definition at line 459 of file csprogs.c.

460{
461 prvm_prog_t *prog = CLVM_prog;
462 qbool r;
463
464 if(!prog->loaded)
465 return false;
466
468 r = false;
469 else
470 {
473 PRVM_G_FLOAT(OFS_PARM0) = eventtype;
474 PRVM_G_FLOAT(OFS_PARM1) = x; // key or x
475 PRVM_G_FLOAT(OFS_PARM2) = y; // ascii or y
476 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_InputEvent), "QC function CSQC_InputEvent is missing");
477 r = CSQC_RETURNVAL != 0;
478 }
479 return r;
480}
float CSQC_InputEvent(float evtype, float scanx, float chary)
GLint GLenum GLint GLint y
Definition glquake.h:651
GLint GLenum GLint x
Definition glquake.h:651

References cl, CLVM_prog, CSQC_InputEvent(), CSQC_RETURNVAL, client_state_t::csqc_server2csqcentitynumber, prvm_prog_t::ExecuteProgram, prvm_prog_t::loaded, OFS_PARM0, OFS_PARM1, OFS_PARM2, client_state_t::playerentity, PRVM_clientfunction, PRVM_clientglobaledict, PRVM_clientglobalfloat, PRVM_G_FLOAT, r, self, client_state_t::time, time, x, and y.

Referenced by CL_Input(), and Key_Event().

◆ CL_VM_Parse_CenterPrint()

void CL_VM_Parse_CenterPrint ( const char * msg,
size_t msg_len )

Definition at line 689 of file csprogs.c.

690{
691 prvm_prog_t *prog = CLVM_prog;
692 int restorevm_tempstringsbuf_cursize;
693
694 if(prog->loaded && PRVM_clientfunction(CSQC_Parse_CenterPrint))
695 {
698 restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize;
699 PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, msg, msg_len);
700 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Parse_CenterPrint), "QC function CSQC_Parse_CenterPrint is missing");
701 prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
702 }
703 else
704 SCR_CenterPrint(msg);
705}
void SCR_CenterPrint(const char *str)
Definition cl_screen.c:144
sizebuf_t tempstringsbuf
buffer for storing all tempstrings created during one invocation of ExecuteProgram
Definition progsvm.h:644
int cursize
Definition common.h:54

References cl, CLVM_prog, client_state_t::csqc_server2csqcentitynumber, sizebuf_t::cursize, prvm_prog_t::ExecuteProgram, prvm_prog_t::loaded, OFS_PARM0, client_state_t::playerentity, PRVM_clientfunction, PRVM_clientglobaledict, PRVM_clientglobalfloat, PRVM_G_INT, PRVM_SetTempString(), SCR_CenterPrint(), self, prvm_prog_t::tempstringsbuf, client_state_t::time, and time.

Referenced by CL_ParseServerMessage().

◆ CL_VM_Parse_StuffCmd()

void CL_VM_Parse_StuffCmd ( const char * msg,
size_t msg_len )

Definition at line 604 of file csprogs.c.

605{
606 prvm_prog_t *prog = CLVM_prog;
607 int restorevm_tempstringsbuf_cursize;
608
609 if(msg[0] == 'c')
610 if(msg[1] == 's')
611 if(msg[2] == 'q')
612 if(msg[3] == 'c')
613 {
614 // if this is setting a csqc variable, deprotect csqc_progcrc
615 // temporarily so that it can be set by the cvar command,
616 // and then reprotect it afterwards
617 int crcflags = csqc_progcrc.flags;
618 csqc_progcrc.flags &= ~CF_READONLY;
619 csqc_progsize.flags &= ~CF_READONLY;
620 Cmd_ExecuteString(cmd_local, msg, msg_len, src_local, true);
622 return;
623 }
624
625 if(!prog->loaded)
626 {
628 return;
629 }
630
631 if(PRVM_clientfunction(CSQC_Parse_StuffCmd))
632 {
635 restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize;
636 PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, msg, msg_len);
637 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Parse_StuffCmd), "QC function CSQC_Parse_StuffCmd is missing");
638 prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
639 }
640 else
642}
void Cbuf_AddText(cmd_state_t *cmd, const char *text)
Definition cmd.c:264
void Cmd_ExecuteString(cmd_state_t *cmd, const char *text, size_t textlen, cmd_source_t src, qbool lockmutex)
Parses a single line of text into arguments and tries to execute it.
Definition cmd.c:2068
@ src_local
from the command buffer
Definition cmd.h:75
unsigned flags
Definition cvar.h:67

References Cbuf_AddText(), cl, CLVM_prog, Cmd_ExecuteString(), cmd_local, csqc_progcrc, csqc_progsize, client_state_t::csqc_server2csqcentitynumber, sizebuf_t::cursize, prvm_prog_t::ExecuteProgram, cvar_t::flags, prvm_prog_t::loaded, OFS_PARM0, client_state_t::playerentity, PRVM_clientfunction, PRVM_clientglobaledict, PRVM_clientglobalfloat, PRVM_G_INT, PRVM_SetTempString(), self, src_local, prvm_prog_t::tempstringsbuf, client_state_t::time, and time.

Referenced by CL_ParseServerMessage().

◆ CL_VM_Parse_TempEntity()

qbool CL_VM_Parse_TempEntity ( void )

Definition at line 579 of file csprogs.c.

580{
581 prvm_prog_t *prog = CLVM_prog;
582 int t;
583 qbool r = false;
584
585 if(!prog->loaded)
586 return false;
587
588 if(PRVM_clientfunction(CSQC_Parse_TempEntity))
589 {
593 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Parse_TempEntity), "QC function CSQC_Parse_TempEntity is missing");
594 r = CSQC_RETURNVAL != 0;
595 if(!r)
596 {
598 cl_message.badread = false;
599 }
600 }
601 return r;
602}
sizebuf_t cl_message
Definition netconn.c:71
qbool badread
Definition common.h:56
int readcount
Definition common.h:55

References sizebuf_t::badread, cl, cl_message, CLVM_prog, CSQC_RETURNVAL, client_state_t::csqc_server2csqcentitynumber, prvm_prog_t::ExecuteProgram, prvm_prog_t::loaded, client_state_t::playerentity, PRVM_clientfunction, PRVM_clientglobaledict, PRVM_clientglobalfloat, r, sizebuf_t::readcount, self, client_state_t::time, and time.

Referenced by CL_ParseServerMessage().

◆ CL_VM_PreventInformationLeaks()

void CL_VM_PreventInformationLeaks ( void )

Definition at line 36 of file csprogs.c.

37{
38 prvm_prog_t *prog = CLVM_prog;
39
40 if(!prog->loaded)
41 return;
42
45}
float trace_networkentity
void VM_ClearTraceGlobals(prvm_prog_t *prog)
Definition prvm_cmds.c:5245

References CLVM_prog, prvm_prog_t::loaded, PRVM_clientglobalfloat, trace_networkentity, and VM_ClearTraceGlobals().

Referenced by CL_Frame().

◆ CL_VM_ShutDown()

void CL_VM_ShutDown ( void )

Definition at line 1154 of file csprogs.c.

1155{
1156 prvm_prog_t *prog = CLVM_prog;
1158
1159 //Cvar_SetValueQuick(&csqc_progcrc, -1);
1160 //Cvar_SetValueQuick(&csqc_progsize, -1);
1161 if (prog->loaded)
1162 {
1166 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Shutdown), "QC function CSQC_Shutdown is missing");
1167 }
1168 PRVM_Prog_Reset(prog);
1169 Con_DPrint("CSQC ^1unloaded\n");
1170}
void Cmd_ClearCSQCCommands(cmd_state_t *cmd)
Definition cmd.c:1981
void Con_DPrint(const char *msg)
A Con_Print that only shows up if the "developer" cvar is set.
Definition console.c:1531
void CSQC_Shutdown()
void PRVM_Prog_Reset(prvm_prog_t *prog)

References cl, CLVM_prog, Cmd_ClearCSQCCommands(), cmd_local, Con_DPrint(), CSQC_Shutdown(), prvm_prog_t::ExecuteProgram, prvm_prog_t::loaded, PRVM_clientfunction, PRVM_clientglobaledict, PRVM_clientglobalfloat, PRVM_Prog_Reset(), self, client_state_t::time, and time.

Referenced by CL_ClearState(), and CL_DisconnectEx().

◆ CL_VM_TransformView()

qbool CL_VM_TransformView ( int entnum,
matrix4x4_t * viewmatrix,
mplane_t * clipplane,
vec3_t visorigin )

Definition at line 1196 of file csprogs.c.

1197{
1198 prvm_prog_t *prog = CLVM_prog;
1199 qbool ret = false;
1200 prvm_edict_t *ed;
1201 vec3_t forward, left, up, origin, ang;
1202 matrix4x4_t mat, matq;
1203
1204 ed = PRVM_EDICT_NUM(entnum);
1205 // camera:
1206 // camera_transform
1207 if(PRVM_clientedictfunction(ed, camera_transform))
1208 {
1209 ret = true;
1210 if(viewmatrix && clipplane && visorigin)
1211 {
1212 Matrix4x4_ToVectors(viewmatrix, forward, left, up, origin);
1213 AnglesFromVectors(ang, forward, up, false);
1222 prog->ExecuteProgram(prog, PRVM_clientedictfunction(ed, camera_transform), "QC function e.camera_transform is missing");
1228 Matrix4x4_Invert_Full(&mat, viewmatrix);
1229 Matrix4x4_FromVectors(viewmatrix, forward, left, up, origin);
1230 Matrix4x4_Concat(&matq, viewmatrix, &mat);
1231 Matrix4x4_TransformPositivePlane(&matq, clipplane->normal[0], clipplane->normal[1], clipplane->normal[2], clipplane->dist, clipplane->normal_and_dist);
1232 }
1233 }
1234
1235 return ret;
1236}
vector trace_endpos
void AnglesFromVectors(vec3_t angles, const vec3_t forward, const vec3_t up, qbool flippitch)
LadyHavoc: calculates pitch/yaw/roll angles from forward and up vectors.
Definition mathlib.c:650
void Matrix4x4_TransformPositivePlane(const matrix4x4_t *in, float x, float y, float z, float d, float *o)
Definition matrixlib.c:1699
int Matrix4x4_Invert_Full(matrix4x4_t *out, const matrix4x4_t *in1)
Definition matrixlib.c:145
void Matrix4x4_ToVectors(const matrix4x4_t *in, float vx[3], float vy[3], float vz[3], float t[3])
Definition matrixlib.c:939
#define OFS_RETURN
Definition pr_comp.h:33
#define PRVM_clientedictfunction(ed, fieldname)
Definition progsvm.h:188
vec3_t normal
Definition model_brush.h:59
vec_t dist
Definition model_brush.h:60
vec4_t normal_and_dist
Definition model_brush.h:62

References AnglesFromVectors(), cl, CLVM_prog, mplane_t::dist, entnum, prvm_prog_t::ExecuteProgram, forward, Matrix4x4_Concat(), Matrix4x4_FromVectors(), Matrix4x4_Invert_Full(), Matrix4x4_ToVectors(), Matrix4x4_TransformPositivePlane(), mplane_t::normal, mplane_t::normal_and_dist, OFS_PARM0, OFS_PARM1, OFS_RETURN, origin, PRVM_clientedictfunction, PRVM_clientglobaledict, PRVM_clientglobalfloat, PRVM_clientglobalvector, PRVM_EDICT_NUM, PRVM_G_VECTOR, ret, self, client_state_t::time, time, trace_endpos, up, v_forward, v_right, v_up, VectorCopy, and VectorScale.

Referenced by R_Water_ProcessPlanes().

◆ CL_VM_UpdateDmgGlobals()

void CL_VM_UpdateDmgGlobals ( int dmg_take,
int dmg_save,
vec3_t dmg_origin )

Definition at line 222 of file csprogs.c.

223{
224 prvm_prog_t *prog = CLVM_prog;
225
226 if(prog->loaded)
227 {
230 VectorCopy(dmg_origin, PRVM_clientglobalvector(dmg_origin));
231 }
232}
float dmg_take
Definition progsdefs.qc:198
float dmg_save
Definition progsdefs.qc:199

References CLVM_prog, dmg_save, dmg_take, prvm_prog_t::loaded, PRVM_clientglobalfloat, PRVM_clientglobalvector, and VectorCopy.

Referenced by CL_VM_UpdateView(), and V_ParseDamage().

◆ CL_VM_UpdateIntermissionState()

void CL_VM_UpdateIntermissionState ( int intermission)

Definition at line 707 of file csprogs.c.

708{
709 prvm_prog_t *prog = CLVM_prog;
710
711 if(prog->loaded)
713}
float intermission

References CLVM_prog, intermission, prvm_prog_t::loaded, and PRVM_clientglobalfloat.

Referenced by CL_ParseServerMessage().

◆ CL_VM_UpdateShowingScoresState()

void CL_VM_UpdateShowingScoresState ( int showingscores)

Definition at line 714 of file csprogs.c.

715{
716 prvm_prog_t *prog = CLVM_prog;
717
718 if(prog->loaded)
719 PRVM_clientglobalfloat(sb_showscores) = showingscores;
720}
qbool sb_showscores
Definition sbar.c:56

References CLVM_prog, prvm_prog_t::loaded, PRVM_clientglobalfloat, and sb_showscores.

Referenced by Sbar_DontShowScores_f(), and Sbar_ShowScores_f().

◆ CSQC_AddPrintText()

void CSQC_AddPrintText ( const char * msg,
size_t msg_len )

Definition at line 656 of file csprogs.c.

657{
658 prvm_prog_t *prog = CLVM_prog;
660 size_t writebytes = min(msg_len + 1, MAX_INPUTLINE - cl.csqc_printtextbuf_len);
661
662 if(prog->loaded && PRVM_clientfunction(CSQC_Parse_Print))
663 {
664 if(msg[msg_len - 1] != '\n' && msg[msg_len - 1] != '\r')
665 {
666 if(cl.csqc_printtextbuf_len + msg_len + 1 >= MAX_INPUTLINE)
667 {
669 cl.csqc_printtextbuf[0] = '\0';
671 }
672 else
673 {
674 memcpy(start, msg, writebytes);
675 cl.csqc_printtextbuf_len += msg_len;
676 }
677 return;
678 }
679 memcpy(start, msg, writebytes);
680 cl.csqc_printtextbuf_len += msg_len;
682 cl.csqc_printtextbuf[0] = '\0';
684 }
685 else
686 Con_Print(msg);
687}
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1504
static void CL_VM_Parse_Print(const char *msg, size_t msg_len)
Definition csprogs.c:644
#define min(A, B)
Definition mathlib.h:37
#define MAX_INPUTLINE
maximum size of console commandline, QuakeC strings, and many other text processing buffers
Definition qdefs.h:94
size_t csqc_printtextbuf_len
strlen
Definition client.h:1119
char csqc_printtextbuf[MAX_INPUTLINE]
Definition client.h:1118

References cl, CL_VM_Parse_Print(), CLVM_prog, Con_Print(), client_state_t::csqc_printtextbuf, client_state_t::csqc_printtextbuf_len, prvm_prog_t::loaded, MAX_INPUTLINE, min, and PRVM_clientfunction.

Referenced by CL_ParseServerMessage().

◆ CSQC_AddRenderEdict()

qbool CSQC_AddRenderEdict ( prvm_edict_t * ed,
int edictnum )

Definition at line 311 of file csprogs.c.

312{
313 prvm_prog_t *prog = CLVM_prog;
314 int renderflags;
315 int c;
316 float scale;
317 entity_render_t *entrender;
318 model_t *model;
319 prvm_vec3_t modellight_origin;
320
322 if (!model)
323 return false;
324
325 if (edictnum)
326 {
328 return false;
329 entrender = cl.csqcrenderentities + edictnum;
331 entrender->entitynumber = edictnum + MAX_EDICTS;
332 //entrender->shadertime = 0; // shadertime was set by spawn()
333 entrender->flags = 0;
334 entrender->effects = 0;
335 entrender->alpha = 1;
336 entrender->scale = 1;
337 VectorSet(entrender->colormod, 1, 1, 1);
338 VectorSet(entrender->glowmod, 1, 1, 1);
339 entrender->allowdecals = true;
340 }
341 else
342 {
343 entrender = CL_NewTempEntity(0);
344 if (!entrender)
345 return false;
346 }
347
348 entrender->userwavefunc_param[0] = PRVM_clientedictfloat(ed, userwavefunc_param0);
349 entrender->userwavefunc_param[1] = PRVM_clientedictfloat(ed, userwavefunc_param1);
350 entrender->userwavefunc_param[2] = PRVM_clientedictfloat(ed, userwavefunc_param2);
351 entrender->userwavefunc_param[3] = PRVM_clientedictfloat(ed, userwavefunc_param3);
352
353 entrender->model = model;
354 entrender->skinnum = (int)PRVM_clientedictfloat(ed, skin);
355 entrender->effects |= entrender->model->effects;
356 renderflags = (int)PRVM_clientedictfloat(ed, renderflags);
357 entrender->alpha = PRVM_clientedictfloat(ed, alpha);
358 entrender->scale = scale = PRVM_clientedictfloat(ed, scale);
362 if (!entrender->alpha)
363 entrender->alpha = 1.0f;
364 if (!entrender->scale)
365 entrender->scale = scale = 1.0f;
366 if (!VectorLength2(entrender->colormod))
367 VectorSet(entrender->colormod, 1, 1, 1);
368 if (!VectorLength2(entrender->glowmod))
369 VectorSet(entrender->glowmod, 1, 1, 1);
370
371 // LadyHavoc: use the CL_GetTagMatrix function on self to ensure consistent behavior (duplicate code would be bad)
372 // this also sets the custommodellight_origin for us
373 CL_GetTagMatrix(prog, &entrender->matrix, ed, 0, modellight_origin);
374 VectorCopy(modellight_origin, entrender->custommodellight_origin);
375
376 // set up the animation data
377 VM_GenerateFrameGroupBlend(prog, ed->priv.server->framegroupblend, ed);
378 VM_FrameBlendFromFrameGroupBlend(ed->priv.server->frameblend, ed->priv.server->framegroupblend, model, cl.time);
379 VM_UpdateEdictSkeleton(prog, ed, model, ed->priv.server->frameblend);
380 if (PRVM_clientedictfloat(ed, shadertime)) // hack for csprogs.dat files that do not set shadertime, leaves the value at entity spawn time
381 entrender->shadertime = PRVM_clientedictfloat(ed, shadertime);
382
383 // transparent offset
384 if (renderflags & RF_USETRANSPARENTOFFSET)
386
387 // model light
388 if (renderflags & RF_MODELLIGHT)
389 {
394 }
395
396 if(renderflags)
397 {
398 if(renderflags & RF_VIEWMODEL) entrender->flags |= RENDER_VIEWMODEL | RENDER_NODEPTHTEST;
399 if(renderflags & RF_EXTERNALMODEL) entrender->flags |= RENDER_EXTERIORMODEL;
400 if(renderflags & RF_WORLDOBJECT) entrender->flags |= RENDER_WORLDOBJECT;
401 if(renderflags & RF_DEPTHHACK) entrender->flags |= RENDER_NODEPTHTEST;
402 if(renderflags & RF_ADDITIVE) entrender->flags |= RENDER_ADDITIVE;
403 if(renderflags & RF_DYNAMICMODELLIGHT) entrender->flags |= RENDER_DYNAMICMODELLIGHT;
404 }
405
407 if (c <= 0)
408 CL_SetEntityColormapColors(entrender, -1);
409 else if (c <= cl.maxclients && cl.scores != NULL)
411 else
412 CL_SetEntityColormapColors(entrender, c);
413
415 // either fullbright or lit
417 {
418 if (!(entrender->effects & EF_FULLBRIGHT) && !(renderflags & RF_FULLBRIGHT))
419 entrender->flags |= RENDER_LIGHT;
420 }
421 // hide player shadow during intermission or nehahra movie
422 if (!(entrender->effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST))
423 && (entrender->alpha >= 1)
424 && !(renderflags & RF_NOSHADOW)
425 && !(entrender->flags & RENDER_VIEWMODEL)
427 entrender->flags |= RENDER_SHADOW;
428 if (entrender->flags & RENDER_VIEWMODEL)
429 entrender->flags |= RENDER_NOSELFSHADOW;
430 if (entrender->effects & EF_NOSELFSHADOW)
431 entrender->flags |= RENDER_NOSELFSHADOW;
432 if (entrender->effects & EF_NODEPTHTEST)
433 entrender->flags |= RENDER_NODEPTHTEST;
434 if (entrender->effects & EF_ADDITIVE)
435 entrender->flags |= RENDER_ADDITIVE;
436 if (entrender->effects & EF_DOUBLESIDED)
437 entrender->flags |= RENDER_DOUBLESIDED;
438 if (entrender->effects & EF_DYNAMICMODELLIGHT)
439 entrender->flags |= RENDER_DYNAMICMODELLIGHT;
440
441 // make the other useful stuff
442 memcpy(entrender->framegroupblend, ed->priv.server->framegroupblend, sizeof(ed->priv.server->framegroupblend));
443 CL_UpdateRenderEntity(entrender);
444
445 // override animation data with full control
446 memcpy(entrender->frameblend, ed->priv.server->frameblend, sizeof(ed->priv.server->frameblend));
447 if (ed->priv.server->skeleton.relativetransforms)
448 entrender->skeleton = &ed->priv.server->skeleton;
449 else
450 entrender->skeleton = NULL;
451
452 return true;
453}
void CL_UpdateRenderEntity(entity_render_t *ent)
Definition cl_main.c:702
entity_render_t * CL_NewTempEntity(double shadertime)
Definition cl_main.c:794
void CL_SetEntityColormapColors(entity_render_t *ent, int colormap)
Definition cl_main.c:1061
@ PROTOCOL_NEHAHRAMOVIE
Nehahra movie protocol, a big nasty hack dating back to early days of the Quake Standards Group (but ...
Definition common.h:143
cvar_t cl_noplayershadow
Definition cl_main.c:85
#define RF_FULLBRIGHT
Definition csprogs.h:93
#define RF_WORLDOBJECT
Definition csprogs.h:89
#define RF_DEPTHHACK
Definition csprogs.h:83
#define RF_USETRANSPARENTOFFSET
Definition csprogs.h:88
#define RF_DYNAMICMODELLIGHT
Definition csprogs.h:91
#define RF_NOSHADOW
Definition csprogs.h:94
#define RF_ADDITIVE
Definition csprogs.h:84
#define RF_EXTERNALMODEL
Definition csprogs.h:82
#define RF_MODELLIGHT
Definition csprogs.h:90
vector modellight_dir
float transparent_offset
float effects
vector modellight_ambient
vector modellight_diffuse
float skin
float colormap
vector glowmod
float alpha
vector colormod
cvar_t r_fullbright
Definition gl_rmain.c:112
#define VectorClear(a)
Definition mathlib.h:97
#define VectorLength2(a)
Definition mathlib.h:110
#define VectorSet(vec, x, y, z)
Definition mathlib.h:96
void VM_UpdateEdictSkeleton(prvm_prog_t *prog, prvm_edict_t *ed, const struct model_s *edmodel, const struct frameblend_s *frameblend)
void VM_GenerateFrameGroupBlend(prvm_prog_t *prog, struct framegroupblend_s *framegroupblend, const prvm_edict_t *ed)
void VM_FrameBlendFromFrameGroupBlend(struct frameblend_s *frameblend, const struct framegroupblend_s *framegroupblend, const struct model_s *model, double curtime)
#define RENDER_EXTERIORMODEL
Definition protocol.h:359
#define EF_FULLBRIGHT
Definition protocol.h:77
#define EF_NOSHADOW
Definition protocol.h:80
#define EF_NODEPTHTEST
Definition protocol.h:81
#define EF_ADDITIVE
Definition protocol.h:73
#define EF_DYNAMICMODELLIGHT
Definition protocol.h:85
#define RENDER_SHADOW
Definition protocol.h:365
#define RENDER_VIEWMODEL
Definition protocol.h:358
#define EF_NOSELFSHADOW
Definition protocol.h:84
#define RENDER_DYNAMICMODELLIGHT
Definition protocol.h:373
#define EF_DOUBLESIDED
Definition protocol.h:83
#define RENDER_WORLDOBJECT
Definition protocol.h:362
#define RENDER_DOUBLESIDED
Definition protocol.h:371
#define RENDER_ADDITIVE
Definition protocol.h:370
#define RENDER_NOSELFSHADOW
Definition protocol.h:367
#define RENDER_LIGHT
Definition protocol.h:366
#define RENDER_CUSTOMIZEDMODELLIGHT
Definition protocol.h:372
#define RENDER_NODEPTHTEST
Definition protocol.h:369
prvm_vec_t prvm_vec3_t[3]
Definition qtypes.h:63
scoreboard_t * scores
Definition client.h:945
int intermission
Definition client.h:856
entity_render_t * csqcrenderentities
Definition client.h:992
frameblend_t frameblend[MAX_FRAMEBLENDS]
Definition client.h:373
vec3_t custommodellight_lightdir
Definition client.h:404
vec_t userwavefunc_param[Q3WAVEFUNC_USER_COUNT]
Definition client.h:445
float custommodellight_origin[3]
Definition client.h:406
matrix4x4_t matrix
Definition client.h:332
float colormod[3]
Definition client.h:359
model_t * model
Definition client.h:343
vec3_t custommodellight_diffuse
Definition client.h:403
float transparent_offset
Definition client.h:340
framegroupblend_t framegroupblend[MAX_FRAMEGROUPBLENDS]
Definition client.h:363
vec3_t custommodellight_ambient
Definition client.h:402
double shadertime
Definition client.h:366
float glowmod[3]
Definition client.h:360
skeleton_t * skeleton
Definition client.h:375
unsigned effects
union prvm_edict_t::@29 priv
struct edict_engineprivate_s * server
FIXME: this server pointer really means world, not server (it is used by both server qc and client qc...
Definition progsvm.h:106
entity_render_t ** entities
renderable entities (excluding world)
Definition render.h:361
r_refdef_scene_t scene
Definition render.h:418

References entity_render_t::allowdecals, alpha, entity_render_t::alpha, cl, CL_GetModelFromEdict(), CL_GetTagMatrix(), CL_NewTempEntity(), cl_noplayershadow, CL_SetEntityColormapColors(), CL_UpdateRenderEntity(), cls, CLVM_prog, colormap, colormod, entity_render_t::colormod, scoreboard_t::colors, client_state_t::csqcrenderentities, entity_render_t::custommodellight_ambient, entity_render_t::custommodellight_diffuse, entity_render_t::custommodellight_lightdir, entity_render_t::custommodellight_origin, EF_ADDITIVE, EF_DOUBLESIDED, EF_DYNAMICMODELLIGHT, EF_FULLBRIGHT, EF_NODEPTHTEST, EF_NOSELFSHADOW, EF_NOSHADOW, effects, entity_render_t::effects, model_t::effects, r_refdef_scene_t::entities, entity_render_t::entitynumber, entity_render_t::flags, entity_render_t::frameblend, entity_render_t::framegroupblend, entity_render_t::glowmod, glowmod, int(), cvar_t::integer, client_state_t::intermission, entity_render_t::matrix, MAX_EDICTS, client_state_t::maxclients, r_refdef_scene_t::maxentities, entity_render_t::model, model, modellight_ambient, modellight_diffuse, modellight_dir, NULL, r_refdef_scene_t::numentities, prvm_edict_t::priv, client_static_t::protocol, PROTOCOL_NEHAHRAMOVIE, PRVM_clientedictfloat, PRVM_clientedictvector, PRVM_clientglobalfloat, r_fullbright, r_refdef, RENDER_ADDITIVE, RENDER_CUSTOMIZEDMODELLIGHT, RENDER_DOUBLESIDED, RENDER_DYNAMICMODELLIGHT, RENDER_EXTERIORMODEL, RENDER_LIGHT, RENDER_NODEPTHTEST, RENDER_NOSELFSHADOW, RENDER_SHADOW, RENDER_VIEWMODEL, RENDER_WORLDOBJECT, RF_ADDITIVE, RF_DEPTHHACK, RF_DYNAMICMODELLIGHT, RF_EXTERNALMODEL, RF_FULLBRIGHT, RF_MODELLIGHT, RF_NOSHADOW, RF_USETRANSPARENTOFFSET, RF_VIEWMODEL, RF_WORLDOBJECT, entity_render_t::scale, scale, r_refdef_t::scene, client_state_t::scores, prvm_edict_t::server, entity_render_t::shadertime, entity_render_t::skeleton, skin, entity_render_t::skinnum, client_state_t::time, entity_render_t::transparent_offset, transparent_offset, entity_render_t::userwavefunc_param, VectorClear, VectorCopy, VectorLength2, VectorSet, VM_FrameBlendFromFrameGroupBlend(), VM_GenerateFrameGroupBlend(), and VM_UpdateEdictSkeleton().

Referenced by VM_CL_R_AddEntities(), and VM_CL_R_AddEntity().

◆ CSQC_Predraw()

void CSQC_Predraw ( prvm_edict_t * ed)

Definition at line 283 of file csprogs.c.

284{
285 prvm_prog_t *prog = CLVM_prog;
286 int b;
287 if(!PRVM_clientedictfunction(ed, predraw))
288 return;
291 prog->ExecuteProgram(prog, PRVM_clientedictfunction(ed, predraw), "CSQC_Predraw: NULL function\n");
293}
#define PRVM_EDICT_TO_PROG(e)
Definition progsvm.h:875
dp_FragColor b

References b, CLVM_prog, prvm_prog_t::ExecuteProgram, PRVM_clientedictfunction, PRVM_clientglobaledict, PRVM_EDICT_TO_PROG, and self.

Referenced by VM_CL_R_AddEntities().

◆ CSQC_R_RecalcView()

void CSQC_R_RecalcView ( void )

Definition at line 756 of file clvm_cmds.c.

757{
761 if (v_yshearing.value > 0)
766}
matrix4x4_t viewmodelmatrix_withbob
Definition cl_main.c:1056
matrix4x4_t viewmodelmatrix_nobob
Definition cl_main.c:1057
cvar_t v_yshearing
Definition view.c:143
void Matrix4x4_QuakeToDuke3D(const matrix4x4_t *in, matrix4x4_t *out, double maxShearAngle)
Definition matrixlib.c:891
void Matrix4x4_ConcatScale(matrix4x4_t *out, double x)
Definition matrixlib.c:1775
cvar_t cl_viewmodel_scale
Definition view.c:82
matrix4x4_t csqc_viewmodelmatrixfromengine
Definition client.h:1115
vec3_t csqc_viewangles
Definition client.h:1112
vec3_t csqc_vieworigin
Definition client.h:1111
float value
Definition cvar.h:74

References cl, cl_viewmodel_scale, client_state_t::csqc_viewangles, client_state_t::csqc_viewmodelmatrixfromengine, client_state_t::csqc_vieworigin, r_refdef_view_t::matrix, Matrix4x4_Concat(), Matrix4x4_ConcatScale(), Matrix4x4_Copy(), Matrix4x4_CreateFromQuakeEntity(), Matrix4x4_QuakeToDuke3D(), r_refdef, v_yshearing, cvar_t::value, r_refdef_t::view, viewmodelmatrix_nobob, and viewmodelmatrix_withbob.

Referenced by CSQC_SetGlobals(), VM_CL_R_ClearScene(), VM_CL_R_SetView(), and VM_CL_V_CalcRefdef().

◆ CSQC_ReadEntities()

void CSQC_ReadEntities ( void )

Definition at line 798 of file csprogs.c.

799{
800 prvm_prog_t *prog = CLVM_prog;
801 unsigned short entnum, oldself, realentnum;
802
803 if(!prog->loaded)
804 {
805 Host_Error ("CSQC_ReadEntities: CSQC is not loaded");
806 return;
807 }
808
810 oldself = PRVM_clientglobaledict(self);
811 while(1)
812 {
815 break;
816 realentnum = entnum & 0x7FFF;
818 if(entnum & 0x8000)
819 {
821 {
822 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Ent_Remove), "QC function CSQC_Ent_Remove is missing");
823 cl.csqc_server2csqcentitynumber[realentnum] = 0;
824 }
825 else
826 {
827 // LadyHavoc: removing an entity that is already gone on
828 // the csqc side is possible for legitimate reasons (such
829 // as a repeat of the remove message), so no warning is
830 // needed
831 //Con_Printf("Bad csqc_server2csqcentitynumber map\n"); //[515]: never happens ?
832 }
833 }
834 else
835 {
837 {
838 if(!PRVM_clientfunction(CSQC_Ent_Spawn))
839 {
840 prvm_edict_t *ed;
841 ed = PRVM_ED_Alloc(prog);
842 PRVM_clientedictfloat(ed, entnum) = realentnum;
844 }
845 else
846 {
847 // entity( float entnum ) CSQC_Ent_Spawn;
848 // the qc function should set entnum, too (this way it also can return world [2/1/2008 Andreas]
849 PRVM_G_FLOAT(OFS_PARM0) = (float) realentnum;
850 // make sure no one gets wrong ideas
852 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Ent_Spawn), "QC function CSQC_Ent_Spawn is missing");
854 }
856 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Ent_Update), "QC function CSQC_Ent_Update is missing");
857 }
858 else {
860 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Ent_Update), "QC function CSQC_Ent_Update is missing");
861 }
862 }
863 }
864 PRVM_clientglobaledict(self) = oldself;
865}
#define MSG_ReadShort
Definition common.h:191
#define PRVM_EDICT(n)
Definition progsvm.h:866
prvm_edict_t * PRVM_ED_Alloc(prvm_prog_t *prog)
Definition prvm_edict.c:269
precision highp float
Definition shader_glsl.h:53

References sizebuf_t::badread, cl, cl_message, CLVM_prog, client_state_t::csqc_server2csqcentitynumber, entnum, prvm_prog_t::ExecuteProgram, float, Host_Error(), prvm_prog_t::loaded, MSG_ReadShort, OFS_PARM0, OFS_RETURN, PRVM_clientedictfloat, PRVM_clientfunction, PRVM_clientglobaledict, PRVM_clientglobalfloat, PRVM_ED_Alloc(), PRVM_EDICT, PRVM_EDICT_TO_PROG, PRVM_G_FLOAT, PRVM_G_INT, self, client_state_t::time, and time.

Referenced by CL_ParseServerMessage().

◆ CSQC_RelinkAllEntities()

void CSQC_RelinkAllEntities ( int drawmask)

Definition at line 2021 of file cl_main.c.

2022{
2023 // link stuff
2025 // the scene mesh is added first for easier debugging (consistent spot in render entities list)
2031
2032 // link stuff
2034 {
2037 CL_LinkNetworkEntity(&cl.viewent); // link gun model
2039 }
2040
2041 // update view blend
2043}
void CL_MeshEntities_Scene_AddRenderEntity(void)
Definition cl_main.c:2599
static void CL_RelinkStaticEntities(void)
Definition cl_main.c:1737
static void CL_RelinkWorld(void)
Definition cl_main.c:1717
void CL_RelinkBeams(void)
Definition cl_main.c:1884
static void CL_LinkNetworkEntity(entity_t *e)
Definition cl_main.c:1543
static void CL_RelinkNetworkEntities(void)
Definition cl_main.c:1770
void CL_RelinkLightFlashes(void)
Definition cl_main.c:935
static void CL_RelinkEffects(void)
Definition cl_main.c:1789
static void CL_RelinkQWNails(void)
Definition cl_main.c:1968
#define ENTMASK_ENGINEVIEWMODELS
Definition csprogs.h:28
#define ENTMASK_ENGINE
Definition csprogs.h:27
float drawmask
entity_t viewent
Definition client.h:937
void V_CalcViewBlend(void)
Definition view.c:1043

References cl, CL_LinkNetworkEntity(), CL_MeshEntities_Scene_AddRenderEntity(), CL_RelinkBeams(), CL_RelinkEffects(), CL_RelinkLightFlashes(), CL_RelinkNetworkEntities(), CL_RelinkQWNails(), CL_RelinkStaticEntities(), CL_RelinkWorld(), drawmask, ENTMASK_ENGINE, ENTMASK_ENGINEVIEWMODELS, V_CalcViewBlend(), and client_state_t::viewent.

Referenced by CL_UpdateWorld(), and VM_CL_R_AddEntities().

◆ CSQC_RelinkCSQCEntities()

void CSQC_RelinkCSQCEntities ( void )

◆ CSQC_Think()

◆ CSQC_UpdateNetworkTimes()

void CSQC_UpdateNetworkTimes ( double newtime,
double oldtime )

Definition at line 234 of file csprogs.c.

235{
236 prvm_prog_t *prog = CLVM_prog;
237
238 if(!prog->loaded)
239 return;
240
241 PRVM_clientglobalfloat(servertime) = newtime;
242 PRVM_clientglobalfloat(serverprevtime) = oldtime;
243 PRVM_clientglobalfloat(serverdeltatime) = newtime - oldtime;
244}

References CLVM_prog, prvm_prog_t::loaded, and PRVM_clientglobalfloat.

Referenced by CL_NetworkTimeReceived().

◆ MakeDownloadPacket()

qbool MakeDownloadPacket ( const char * filename,
unsigned char * data,
size_t len,
int crc,
int cnt,
sizebuf_t * buf,
int protocol )

Definition at line 940 of file csprogs.c.

941{
942 int packetsize = buf->maxsize - 7; // byte short long
943 int npackets = ((int)len + packetsize - 1) / (packetsize);
944 char vabuf[1024];
945
946 if(protocol == PROTOCOL_QUAKEWORLD)
947 return false; // CSQC can't run in QW anyway
948
949 SZ_Clear(buf);
950 if(cnt == 0)
951 {
953 MSG_WriteString(buf, va(vabuf, sizeof(vabuf), "\ncl_downloadbegin %lu %s\n", (unsigned long)len, filename));
954 return true;
955 }
956 else if(cnt >= 1 && cnt <= npackets)
957 {
958 unsigned long thispacketoffset = (cnt - 1) * packetsize;
959 int thispacketsize = (int)len - thispacketoffset;
960 if(thispacketsize > packetsize)
961 thispacketsize = packetsize;
962
964 MSG_WriteLong(buf, thispacketoffset);
965 MSG_WriteShort(buf, thispacketsize);
966 SZ_Write(buf, data + thispacketoffset, thispacketsize);
967
968 return true;
969 }
970 else if(cnt == npackets + 1)
971 {
973 MSG_WriteString(buf, va(vabuf, sizeof(vabuf), "\ncl_downloadfinished %lu %d\n", (unsigned long)len, crc));
974 return true;
975 }
976 return false;
977}
void MSG_WriteShort(sizebuf_t *sb, int c)
Definition com_msg.c:138
void MSG_WriteString(sizebuf_t *sb, const char *s)
Definition com_msg.c:173
void MSG_WriteLong(sizebuf_t *sb, int c)
Definition com_msg.c:147
void MSG_WriteByte(sizebuf_t *sb, int c)
Definition com_msg.c:130
void SZ_Clear(sizebuf_t *buf)
Definition common.c:44
void SZ_Write(sizebuf_t *buf, const unsigned char *data, int length)
Definition common.c:72
@ PROTOCOL_QUAKEWORLD
quakeworld protocol
Definition common.h:145
GLsizeiptr const GLvoid * data
Definition glquake.h:639
#define svc_downloaddata
Definition protocol.h:269
#define svc_stufftext
Definition protocol.h:223

References buf, data, int(), MSG_WriteByte(), MSG_WriteLong(), MSG_WriteShort(), MSG_WriteString(), PROTOCOL_QUAKEWORLD, svc_downloaddata, svc_stufftext, SZ_Clear(), SZ_Write(), and va().

Referenced by CL_VM_Init(), and SV_SendServerinfo().

◆ QW_CL_StartUpload()

void QW_CL_StartUpload ( unsigned char * data,
int size )

Definition at line 942 of file cl_parse.c.

943{
944 // do nothing in demos or if not connected
945 if (!cls.netcon)
946 return;
947
948 // abort existing upload if in progress
950
951 Con_DPrintf("Starting upload of %d bytes...\n", size);
952
953 cls.qw_uploaddata = (unsigned char *)Mem_Alloc(cls.permanentmempool, size);
954 memcpy(cls.qw_uploaddata, data, size);
956 cls.qw_uploadpos = 0;
957
959}
static void QW_CL_NextUpload_f(cmd_state_t *cmd)
Definition cl_parse.c:912
static void QW_CL_StopUpload_f(cmd_state_t *cmd)
Definition cl_parse.c:968
vector size
mempool_t * permanentmempool
Definition client.h:572
netconn_t * netcon
Definition client.h:630
int qw_uploadsize
Definition client.h:663
unsigned char * qw_uploaddata
Definition client.h:662
#define Mem_Alloc(pool, size)
Definition zone.h:92

References cls, cmd_local, Con_DPrintf(), data, Mem_Alloc, client_static_t::netcon, client_static_t::permanentmempool, QW_CL_NextUpload_f(), QW_CL_StopUpload_f(), client_static_t::qw_uploaddata, client_static_t::qw_uploadpos, client_static_t::qw_uploadsize, and size.

Variable Documentation

◆ csqc_lowres

cvar_t csqc_lowres
extern

Definition at line 40 of file cl_main.c.

40{CF_CLIENT, "csqc_lowres", "0", "make EXT_CSQC functions CSQC_UpdateView(), setproperty(), getproperty() use the virtual 2D resolution (FTEQW/QSS behaviour) instead of the real resolution (DP behaviour); this mode is always used for the CSQC_SIMPLE (aka hud-only) CSQC_DrawHud() parameters; see cvars vid_conheight and vid_conwidth"};
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48

Referenced by CL_Init(), CL_VM_UpdateView(), and VM_CL_R_SetView().

◆ csqc_polygons_defaultmaterial_nocullface

cvar_t csqc_polygons_defaultmaterial_nocullface
extern

Definition at line 39 of file cl_main.c.

39{CF_CLIENT, "csqc_polygons_defaultmaterial_nocullface", "0", "use 'cull none' behavior in the default shader for rendering R_PolygonBegin - warning: enabling this is not consistent with FTEQW behavior on this feature"};

Referenced by CL_Init(), and VM_CL_R_PolygonEnd().

◆ csqc_progcrc

cvar_t csqc_progcrc
extern

Definition at line 36 of file cl_main.c.

36{CF_CLIENT | CF_READONLY, "csqc_progcrc","-1","CRC of csprogs.dat file to load (-1 is none), only used during level changes and then reset to -1"};
#define CF_READONLY
cvar cannot be changed from the console or the command buffer, and is considered CF_PERSISTENT
Definition cmd.h:54

Referenced by CL_BeginDownloads(), CL_DisconnectEx(), CL_VM_Init(), CL_VM_Parse_StuffCmd(), and SV_Init().

◆ csqc_progname

cvar_t csqc_progname
extern

Definition at line 35 of file cl_main.c.

35{CF_CLIENT | CF_SERVER, "csqc_progname","csprogs.dat","name of csprogs.dat file to load"};
#define CF_SERVER
cvar/command that only the server can change/execute
Definition cmd.h:49

Referenced by CL_BeginDownloads(), CL_StopDownload(), CL_VM_Init(), PRVM_Prog_Load(), SV_Init(), and SV_Prepare_CSQC().

◆ csqc_progsize

cvar_t csqc_progsize
extern

Definition at line 37 of file cl_main.c.

37{CF_CLIENT | CF_READONLY, "csqc_progsize","-1","file size of csprogs.dat file to load (-1 is none), only used during level changes and then reset to -1"};

Referenced by CL_BeginDownloads(), CL_DisconnectEx(), CL_VM_Init(), CL_VM_Parse_StuffCmd(), and SV_Init().