X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=clvm_cmds.c;h=06d1d648df927f6ba0c8dbeef63c3ef87db1e208;hb=38185bc1aea210514d6970e3c36a25ad97615e5f;hp=1031110c811eb67d82cb001dfc770339c68aceac;hpb=e4ae176f4a83b82aefce23025177d32be36c1358;p=xonotic%2Fdarkplaces.git diff --git a/clvm_cmds.c b/clvm_cmds.c index 1031110c..06d1d648 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -252,6 +252,8 @@ static void VM_CL_traceline (void) int move, svent; prvm_edict_t *ent; +// R_TimeReport("pretraceline"); + VM_SAFEPARMCOUNTRANGE(4, 4, VM_CL_traceline); prog->xfunction->builtinsprofile += 30; @@ -267,6 +269,7 @@ static void VM_CL_traceline (void) trace = CL_TraceLine(v1, v2, move, ent, CL_GenericHitSuperContentsMask(ent), CL_HitNetworkBrushModels(move), CL_HitNetworkPlayers(move), &svent, true); CL_VM_SetTraceGlobals(&trace, svent); +// R_TimeReport("traceline"); } /* @@ -288,6 +291,7 @@ static void VM_CL_tracebox (void) int move, svent; prvm_edict_t *ent; +// R_TimeReport("pretracebox"); VM_SAFEPARMCOUNTRANGE(6, 8, VM_CL_tracebox); // allow more parameters for future expansion prog->xfunction->builtinsprofile += 30; @@ -305,6 +309,7 @@ static void VM_CL_tracebox (void) trace = CL_TraceBox(v1, m1, m2, v2, move, ent, CL_GenericHitSuperContentsMask(ent), CL_HitNetworkBrushModels(move), CL_HitNetworkPlayers(move), &svent, true); CL_VM_SetTraceGlobals(&trace, svent); +// R_TimeReport("tracebox"); } trace_t CL_Trace_Toss (prvm_edict_t *tossent, prvm_edict_t *ignore, int *svent) @@ -1142,6 +1147,16 @@ static void VM_CL_pointparticles (void) CL_ParticleEffect(i, n, f, f, v, v, NULL, prog->argc >= 5 ? (int)PRVM_G_FLOAT(OFS_PARM4) : 0); } +//#531 void(float pause) setpause +static void VM_CL_setpause(void) +{ + VM_SAFEPARMCOUNT(1, VM_CL_setpause); + if ((int)PRVM_G_FLOAT(OFS_PARM0) != 0) + cl.csqc_paused = true; + else + cl.csqc_paused = false; +} + //#342 string(float keynum) getkeybind (EXT_CSQC) static void VM_CL_getkeybind (void) { @@ -1269,13 +1284,6 @@ static void VM_CL_getplayerkey (void) PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(t); } -//#349 float() isdemo (EXT_CSQC) -static void VM_CL_isdemo (void) -{ - VM_SAFEPARMCOUNT(0, VM_CL_isdemo); - PRVM_G_FLOAT(OFS_RETURN) = cls.demoplayback; -} - //#351 void(vector origin, vector forward, vector right, vector up) SetListener (EXT_CSQC) static void VM_CL_setlistener (void) { @@ -2291,6 +2299,8 @@ typedef struct vmparticletheme_s float stainsize; float delayspawn; float delaycollision; + float angle; + float spin; }vmparticletheme_t; // particle spawner @@ -2328,6 +2338,8 @@ typedef struct vmparticlespawner_s float *particle_staintex; float *particle_delayspawn; float *particle_delaycollision; + float *particle_angle; + float *particle_spin; }vmparticlespawner_t; vmparticlespawner_t vmpartspawner; @@ -2383,6 +2395,8 @@ static void VM_InitParticleSpawner (int maxthemes) getglobal(particle_staintex, "particle_staintex"); getglobal(particle_delayspawn, "particle_delayspawn"); getglobal(particle_delaycollision, "particle_delaycollision"); + getglobal(particle_angle, "particle_angle"); + getglobal(particle_spin, "particle_spin"); #undef getglobal #undef getglobalvector } @@ -2415,6 +2429,8 @@ static void VM_ResetParticleTheme (vmparticletheme_t *theme) theme->staintex = -1; theme->delayspawn = 0.0f; theme->delaycollision = 0.0f; + theme->angle = 0.0f; + theme->spin = 0.0f; } // particle theme -> QC globals @@ -2454,6 +2470,8 @@ void VM_CL_ParticleThemeToGlobals(vmparticletheme_t *theme) *vmpartspawner.particle_stainsize = (float)theme->stainsize; *vmpartspawner.particle_delayspawn = theme->delayspawn; *vmpartspawner.particle_delaycollision = theme->delaycollision; + *vmpartspawner.particle_angle = theme->angle; + *vmpartspawner.particle_spin = theme->spin; } // QC globals -> particle theme @@ -2485,6 +2503,8 @@ void VM_CL_ParticleThemeFromGlobals(vmparticletheme_t *theme) theme->stainsize = *vmpartspawner.particle_stainsize; theme->delayspawn = *vmpartspawner.particle_delayspawn; theme->delaycollision = *vmpartspawner.particle_delaycollision; + theme->angle = *vmpartspawner.particle_angle; + theme->spin = *vmpartspawner.particle_spin; } // init particle spawner interface @@ -2631,7 +2651,7 @@ void VM_CL_SpawnParticle (void) if (prog->argc < 3) // global-set particle { - part = CL_NewParticle(org, (unsigned short)*vmpartspawner.particle_type, ((int)(vmpartspawner.particle_color1[0]) << 16) + ((int)(vmpartspawner.particle_color1[1]) << 8) + ((int)(vmpartspawner.particle_color1[2])), ((int)vmpartspawner.particle_color2[0] << 16) + ((int)vmpartspawner.particle_color2[1] << 8) + ((int)vmpartspawner.particle_color2[2]), (int)*vmpartspawner.particle_tex, *vmpartspawner.particle_size, *vmpartspawner.particle_sizeincrease, *vmpartspawner.particle_alpha*256, *vmpartspawner.particle_alphafade*256, *vmpartspawner.particle_gravity, *vmpartspawner.particle_bounce, org[0], org[1], org[2], dir[0], dir[1], dir[2], *vmpartspawner.particle_airfriction, *vmpartspawner.particle_liquidfriction, *vmpartspawner.particle_originjitter, *vmpartspawner.particle_velocityjitter, (*vmpartspawner.particle_qualityreduction) ? true : false, *vmpartspawner.particle_time, *vmpartspawner.particle_stretch, (pblend_t)*vmpartspawner.particle_blendmode, (porientation_t)*vmpartspawner.particle_orientation, (int)(vmpartspawner.particle_staincolor1[0])*65536 + (int)(vmpartspawner.particle_staincolor1[1])*256 + (int)(vmpartspawner.particle_staincolor1[2]), (int)(vmpartspawner.particle_staincolor2[0])*65536 + (int)(vmpartspawner.particle_staincolor2[1])*256 + (int)(vmpartspawner.particle_staincolor2[2]), (int)*vmpartspawner.particle_staintex, *vmpartspawner.particle_stainalpha*256, *vmpartspawner.particle_stainsize); + part = CL_NewParticle(org, (unsigned short)*vmpartspawner.particle_type, ((int)(vmpartspawner.particle_color1[0]) << 16) + ((int)(vmpartspawner.particle_color1[1]) << 8) + ((int)(vmpartspawner.particle_color1[2])), ((int)vmpartspawner.particle_color2[0] << 16) + ((int)vmpartspawner.particle_color2[1] << 8) + ((int)vmpartspawner.particle_color2[2]), (int)*vmpartspawner.particle_tex, *vmpartspawner.particle_size, *vmpartspawner.particle_sizeincrease, *vmpartspawner.particle_alpha*256, *vmpartspawner.particle_alphafade*256, *vmpartspawner.particle_gravity, *vmpartspawner.particle_bounce, org[0], org[1], org[2], dir[0], dir[1], dir[2], *vmpartspawner.particle_airfriction, *vmpartspawner.particle_liquidfriction, *vmpartspawner.particle_originjitter, *vmpartspawner.particle_velocityjitter, (*vmpartspawner.particle_qualityreduction) ? true : false, *vmpartspawner.particle_time, *vmpartspawner.particle_stretch, (pblend_t)*vmpartspawner.particle_blendmode, (porientation_t)*vmpartspawner.particle_orientation, (int)(vmpartspawner.particle_staincolor1[0])*65536 + (int)(vmpartspawner.particle_staincolor1[1])*256 + (int)(vmpartspawner.particle_staincolor1[2]), (int)(vmpartspawner.particle_staincolor2[0])*65536 + (int)(vmpartspawner.particle_staincolor2[1])*256 + (int)(vmpartspawner.particle_staincolor2[2]), (int)*vmpartspawner.particle_staintex, *vmpartspawner.particle_stainalpha*256, *vmpartspawner.particle_stainsize, *vmpartspawner.particle_angle, *vmpartspawner.particle_spin); if (!part) { PRVM_G_FLOAT(OFS_RETURN) = 0; @@ -2652,7 +2672,7 @@ void VM_CL_SpawnParticle (void) return; } theme = &vmpartspawner.themes[themenum]; - part = CL_NewParticle(org, theme->typeindex, theme->color1, theme->color2, theme->tex, theme->size, theme->sizeincrease, theme->alpha, theme->alphafade, theme->gravity, theme->bounce, org[0], org[1], org[2], dir[0], dir[1], dir[2], theme->airfriction, theme->liquidfriction, theme->originjitter, theme->velocityjitter, theme->qualityreduction, theme->lifetime, theme->stretch, theme->blendmode, theme->orientation, theme->staincolor1, theme->staincolor2, theme->staintex, theme->stainalpha, theme->stainsize); + part = CL_NewParticle(org, theme->typeindex, theme->color1, theme->color2, theme->tex, theme->size, theme->sizeincrease, theme->alpha, theme->alphafade, theme->gravity, theme->bounce, org[0], org[1], org[2], dir[0], dir[1], dir[2], theme->airfriction, theme->liquidfriction, theme->originjitter, theme->velocityjitter, theme->qualityreduction, theme->lifetime, theme->stretch, theme->blendmode, theme->orientation, theme->staincolor1, theme->staincolor2, theme->staintex, theme->stainalpha, theme->stainsize, theme->angle, theme->spin); if (!part) { PRVM_G_FLOAT(OFS_RETURN) = 0; @@ -2685,7 +2705,7 @@ void VM_CL_SpawnParticleDelayed (void) org = PRVM_G_VECTOR(OFS_PARM0); dir = PRVM_G_VECTOR(OFS_PARM1); if (prog->argc < 5) // global-set particle - part = CL_NewParticle(org, (unsigned short)*vmpartspawner.particle_type, ((int)vmpartspawner.particle_color1[0] << 16) + ((int)vmpartspawner.particle_color1[1] << 8) + ((int)vmpartspawner.particle_color1[2]), ((int)vmpartspawner.particle_color2[0] << 16) + ((int)vmpartspawner.particle_color2[1] << 8) + ((int)vmpartspawner.particle_color2[2]), (int)*vmpartspawner.particle_tex, *vmpartspawner.particle_size, *vmpartspawner.particle_sizeincrease, *vmpartspawner.particle_alpha*256, *vmpartspawner.particle_alphafade*256, *vmpartspawner.particle_gravity, *vmpartspawner.particle_bounce, org[0], org[1], org[2], dir[0], dir[1], dir[2], *vmpartspawner.particle_airfriction, *vmpartspawner.particle_liquidfriction, *vmpartspawner.particle_originjitter, *vmpartspawner.particle_velocityjitter, (*vmpartspawner.particle_qualityreduction) ? true : false, *vmpartspawner.particle_time, *vmpartspawner.particle_stretch, (pblend_t)*vmpartspawner.particle_blendmode, (porientation_t)*vmpartspawner.particle_orientation, ((int)vmpartspawner.particle_staincolor1[0] << 16) + ((int)vmpartspawner.particle_staincolor1[1] << 8) + ((int)vmpartspawner.particle_staincolor1[2]), ((int)vmpartspawner.particle_staincolor2[0] << 16) + ((int)vmpartspawner.particle_staincolor2[1] << 8) + ((int)vmpartspawner.particle_staincolor2[2]), (int)*vmpartspawner.particle_staintex, *vmpartspawner.particle_stainalpha*256, *vmpartspawner.particle_stainsize); + part = CL_NewParticle(org, (unsigned short)*vmpartspawner.particle_type, ((int)vmpartspawner.particle_color1[0] << 16) + ((int)vmpartspawner.particle_color1[1] << 8) + ((int)vmpartspawner.particle_color1[2]), ((int)vmpartspawner.particle_color2[0] << 16) + ((int)vmpartspawner.particle_color2[1] << 8) + ((int)vmpartspawner.particle_color2[2]), (int)*vmpartspawner.particle_tex, *vmpartspawner.particle_size, *vmpartspawner.particle_sizeincrease, *vmpartspawner.particle_alpha*256, *vmpartspawner.particle_alphafade*256, *vmpartspawner.particle_gravity, *vmpartspawner.particle_bounce, org[0], org[1], org[2], dir[0], dir[1], dir[2], *vmpartspawner.particle_airfriction, *vmpartspawner.particle_liquidfriction, *vmpartspawner.particle_originjitter, *vmpartspawner.particle_velocityjitter, (*vmpartspawner.particle_qualityreduction) ? true : false, *vmpartspawner.particle_time, *vmpartspawner.particle_stretch, (pblend_t)*vmpartspawner.particle_blendmode, (porientation_t)*vmpartspawner.particle_orientation, ((int)vmpartspawner.particle_staincolor1[0] << 16) + ((int)vmpartspawner.particle_staincolor1[1] << 8) + ((int)vmpartspawner.particle_staincolor1[2]), ((int)vmpartspawner.particle_staincolor2[0] << 16) + ((int)vmpartspawner.particle_staincolor2[1] << 8) + ((int)vmpartspawner.particle_staincolor2[2]), (int)*vmpartspawner.particle_staintex, *vmpartspawner.particle_stainalpha*256, *vmpartspawner.particle_stainsize, *vmpartspawner.particle_angle, *vmpartspawner.particle_spin); else // themed particle { themenum = (int)PRVM_G_FLOAT(OFS_PARM4); @@ -2696,7 +2716,7 @@ void VM_CL_SpawnParticleDelayed (void) return; } theme = &vmpartspawner.themes[themenum]; - part = CL_NewParticle(org, theme->typeindex, theme->color1, theme->color2, theme->tex, theme->size, theme->sizeincrease, theme->alpha, theme->alphafade, theme->gravity, theme->bounce, org[0], org[1], org[2], dir[0], dir[1], dir[2], theme->airfriction, theme->liquidfriction, theme->originjitter, theme->velocityjitter, theme->qualityreduction, theme->lifetime, theme->stretch, theme->blendmode, theme->orientation, theme->staincolor1, theme->staincolor2, theme->staintex, theme->stainalpha, theme->stainsize); + part = CL_NewParticle(org, theme->typeindex, theme->color1, theme->color2, theme->tex, theme->size, theme->sizeincrease, theme->alpha, theme->alphafade, theme->gravity, theme->bounce, org[0], org[1], org[2], dir[0], dir[1], dir[2], theme->airfriction, theme->liquidfriction, theme->originjitter, theme->velocityjitter, theme->qualityreduction, theme->lifetime, theme->stretch, theme->blendmode, theme->orientation, theme->staincolor1, theme->staincolor2, theme->staintex, theme->stainalpha, theme->stainsize, theme->angle, theme->spin); } if (!part) { @@ -2708,7 +2728,88 @@ void VM_CL_SpawnParticleDelayed (void) PRVM_G_FLOAT(OFS_RETURN) = 0; } -// +//==================== +//CSQC engine entities query +//==================== + +// float(float entitynum, float whatfld) getentity; +// vector(float entitynum, float whatfld) getentityvec; +// querying engine-drawn entity +// VorteX: currently it's only tested with whatfld = 1..7 +void VM_CL_GetEntity (void) +{ + int entnum, fieldnum; + float org[3], v1[3], v2[3]; + VM_SAFEPARMCOUNT(2, VM_CL_GetEntityVec); + + entnum = PRVM_G_FLOAT(OFS_PARM0); + if (entnum < 0 || entnum >= cl.num_entities) + { + PRVM_G_FLOAT(OFS_RETURN) = 0; + return; + } + fieldnum = PRVM_G_FLOAT(OFS_PARM1); + switch(fieldnum) + { + case 0: // active state + PRVM_G_FLOAT(OFS_RETURN) = cl.entities_active[entnum]; + break; + case 1: // origin + Matrix4x4_OriginFromMatrix(&cl.entities[entnum].render.matrix, PRVM_G_VECTOR(OFS_RETURN)); + break; + case 2: // forward + Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, PRVM_G_VECTOR(OFS_RETURN), v1, v2, org); + break; + case 3: // right + Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, v1, PRVM_G_VECTOR(OFS_RETURN), v2, org); + break; + case 4: // up + Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, v1, v2, PRVM_G_VECTOR(OFS_RETURN), org); + break; + case 5: // scale + PRVM_G_FLOAT(OFS_RETURN) = Matrix4x4_ScaleFromMatrix(&cl.entities[entnum].render.matrix); + break; + case 6: // origin + v_forward, v_right, v_up + Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, prog->globals.client->v_forward, prog->globals.client->v_right, prog->globals.client->v_up, PRVM_G_VECTOR(OFS_RETURN)); + break; + case 7: // alpha + PRVM_G_FLOAT(OFS_RETURN) = cl.entities[entnum].render.alpha; + break; + case 8: // colormor + VectorCopy(cl.entities[entnum].render.colormod, PRVM_G_VECTOR(OFS_RETURN)); + break; + case 9: // pants colormod + VectorCopy(cl.entities[entnum].render.colormap_pantscolor, PRVM_G_VECTOR(OFS_RETURN)); + break; + case 10: // shirt colormod + VectorCopy(cl.entities[entnum].render.colormap_shirtcolor, PRVM_G_VECTOR(OFS_RETURN)); + break; + case 11: // skinnum + PRVM_G_FLOAT(OFS_RETURN) = cl.entities[entnum].render.skinnum; + break; + case 12: // mins + VectorCopy(cl.entities[entnum].render.mins, PRVM_G_VECTOR(OFS_RETURN)); + break; + case 13: // maxs + VectorCopy(cl.entities[entnum].render.maxs, PRVM_G_VECTOR(OFS_RETURN)); + break; + case 14: // absmin + Matrix4x4_OriginFromMatrix(&cl.entities[entnum].render.matrix, org); + VectorAdd(cl.entities[entnum].render.mins, org, PRVM_G_VECTOR(OFS_RETURN)); + break; + case 15: // absmax + Matrix4x4_OriginFromMatrix(&cl.entities[entnum].render.matrix, org); + VectorAdd(cl.entities[entnum].render.maxs, org, PRVM_G_VECTOR(OFS_RETURN)); + break; + case 16: // light + VectorMA(cl.entities[entnum].render.modellight_ambient, 0.5, cl.entities[entnum].render.modellight_diffuse, PRVM_G_VECTOR(OFS_RETURN)); + break; + default: + PRVM_G_FLOAT(OFS_RETURN) = 0; + break; + } +} + //==================== //QC POLYGON functions //==================== @@ -2828,9 +2929,7 @@ static void VM_DrawPolygonCallback (const entity_render_t *ent, const rtlight_t R_Mesh_ResetTextureState(); R_EntityMatrix(&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_Mesh_PrepareVertices_Generic_Arrays(polys->num_vertices, polys->data_vertex3f, polys->data_color4f, polys->data_texcoord2f); for (surfacelistindex = 0;surfacelistindex < numsurfaces;) { @@ -2858,7 +2957,7 @@ static void VM_DrawPolygonCallback (const entity_render_t *ent, const rtlight_t VectorCopy(polys->data_triangles[surfacelist[surfacelistindex]].elements, polys->data_sortedelement3s + 3*numtriangles); numtriangles++; } - R_Mesh_Draw(0, polys->num_vertices, 0, numtriangles, NULL, polys->data_sortedelement3s, 0, 0); + R_Mesh_Draw(0, polys->num_vertices, 0, numtriangles, NULL, NULL, 0, polys->data_sortedelement3s, NULL, 0); } } @@ -4105,7 +4204,7 @@ VM_CL_setlistener, // #351 void(vector origin, vector forward, vector right, VM_CL_registercmd, // #352 void(string cmdname) registercommand (EXT_CSQC) VM_wasfreed, // #353 float(entity ent) wasfreed (EXT_CSQC) (should be availabe on server too) VM_CL_serverkey, // #354 string(string key) serverkey (EXT_CSQC) -NULL, // #355 +VM_CL_videoplaying, // #355 NULL, // #356 NULL, // #357 NULL, // #358 @@ -4255,7 +4354,7 @@ VM_putentityfieldstring, // #500 float(float fieldnum, entity ent, string s) pu VM_CL_ReadPicture, // #501 string() ReadPicture = #501; NULL, // #502 VM_whichpack, // #503 string(string) whichpack = #503; -NULL, // #504 +VM_CL_GetEntity, // #504 float(float entitynum, float fldnum) getentity = #504; vector(float entitynum, float fldnum) getentityvec = #504; NULL, // #505 NULL, // #506 NULL, // #507 @@ -4282,10 +4381,10 @@ VM_CL_SpawnParticle, // #527 float(vector org, vector vel, [float theme]) part VM_CL_SpawnParticleDelayed, // #528 float(vector org, vector vel, float delay, float collisiondelay, [float theme]) delayedparticle (DP_CSQC_SPAWNPARTICLE) VM_loadfromdata, // #529 VM_loadfromfile, // #530 -NULL, // #531 +VM_CL_setpause, // #531 float(float ispaused) setpause = #531 (DP_CSQC_SETPAUSE) VM_log, // #532 -NULL, // #533 -NULL, // #534 +VM_getsoundtime, // #533 float(entity e, float channel) getsoundtime = #533; (DP_SND_GETSOUNDTIME) +VM_soundlength, // #534 float(string sample) soundlength = #534; (DP_SND_GETSOUNDTIME) NULL, // #535 NULL, // #536 NULL, // #537