From f85340b9a2b347182386e7a68637d9bb787b894c Mon Sep 17 00:00:00 2001 From: Spoike Date: Fri, 1 Jul 2005 19:23:00 +0000 Subject: [PATCH] Big huge mega-whooping commit. I wonder how many things this'll break... On the plus side, nexuiz works well, and ktpro works as well as in mvdsv. Hurrah! git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1122 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_ents.c | 162 +++---- engine/client/cl_main.c | 16 +- engine/client/cl_parse.c | 14 +- engine/client/cl_screen.c | 6 +- engine/client/cl_tent.c | 44 +- engine/client/client.h | 3 - engine/client/pr_csqc.c | 850 ++++++++++++++++++++++++++--------- engine/client/pr_menu.c | 8 +- engine/client/r_part.c | 17 +- engine/client/r_partset.c | 6 +- engine/client/render.h | 3 +- engine/common/cmd.c | 2 +- engine/common/common.c | 7 +- engine/common/cvar.c | 1 + engine/common/gl_q2bsp.c | 16 +- engine/common/protocol.h | 43 +- engine/gl/gl_alias.c | 39 +- engine/gl/gl_backend.c | 6 +- engine/gl/gl_ppl.c | 38 +- engine/gl/gl_rmain.c | 389 ++++++++++------ engine/gl/gl_rsurf.c | 56 +-- engine/gl/glquake.h | 3 +- engine/http/webgen.c | 2 +- engine/qclib/pr_edict.c | 21 +- engine/qclib/pr_exec.c | 2 +- engine/qclib/qcc_pr_comp.c | 14 +- engine/server/net_preparse.c | 4 +- engine/server/pr_cmds.c | 76 ++-- engine/server/progdefs.h | 3 + engine/server/progs.h | 4 - engine/server/sv_ccmds.c | 17 +- engine/server/sv_ents.c | 206 ++++----- engine/server/sv_init.c | 4 +- engine/server/sv_main.c | 23 +- engine/server/sv_mvd.c | 2 +- engine/server/sv_phys.c | 6 +- engine/server/sv_send.c | 2 +- engine/server/sv_user.c | 32 +- engine/server/world.c | 25 +- engine/sw/r_alias.c | 6 +- engine/sw/r_main.c | 14 +- engine/sw/r_sprite.c | 2 +- 42 files changed, 1339 insertions(+), 855 deletions(-) diff --git a/engine/client/cl_ents.c b/engine/client/cl_ents.c index fa1267328..8874f7a6f 100644 --- a/engine/client/cl_ents.c +++ b/engine/client/cl_ents.c @@ -323,15 +323,15 @@ void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int bits, qboolean #ifdef PEXT_SCALE if (morebits & U_SCALE && cls.fteprotocolextensions & PEXT_SCALE) - to->scale = (float)MSG_ReadByte() / 100.0; + to->scale = MSG_ReadByte(); #endif #ifdef PEXT_TRANS if (morebits & U_TRANS && cls.fteprotocolextensions & PEXT_TRANS) - to->trans = (float)MSG_ReadByte() / 255; + to->trans = MSG_ReadByte(); #endif #ifdef PEXT_FATNESS if (morebits & U_FATNESS && cls.fteprotocolextensions & PEXT_FATNESS) - to->trans = (float)MSG_ReadChar() / 2; + to->fatness = MSG_ReadChar(); #endif if (morebits & U_DRAWFLAGS && cls.fteprotocolextensions & PEXT_HEXEN2) @@ -367,16 +367,25 @@ void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int bits, qboolean if (i & RENDER_EXTERIORMODEL) to->flags |= Q2RF_EXTERNALMODEL; } + if (morebits & U_TAGINFO) + { + to->tagentity = MSG_ReadShort(); + to->tagindex = MSG_ReadShort(); + } VectorSubtract(to->origin, from->origin, move); #ifdef HALFLIFEMODELS if (to->frame != from->frame) + { + cl.lerpents[to->number].oldframechange = cl.lerpents[to->number].framechange; //marked for hl models cl.lerpents[to->number].framechange = cl.time; //marked for hl models + } #endif if (to->modelindex != from->modelindex || to->number != from->number || VectorLength(move)>500) //model changed... or entity changed... { #ifdef HALFLIFEMODELS + cl.lerpents[to->number].oldframechange = cl.lerpents[to->number].framechange; //marked for hl models cl.lerpents[to->number].framechange = cl.time; //marked for hl models #endif cl.lerpents[to->number].lerptime = -10; @@ -846,15 +855,15 @@ void DP5_ParseDelta(entity_state_t *s) s->effects = MSG_ReadByte(); } if (bits & E5_ALPHA) - s->trans = MSG_ReadByte()/255.0f; + s->trans = MSG_ReadByte(); if (bits & E5_SCALE) - s->scale = MSG_ReadByte()/255.0f; + s->scale = MSG_ReadByte(); if (bits & E5_COLORMAP) s->colormap = MSG_ReadByte(); if (bits & E5_ATTACHMENT) { - cl.lerpents[s->number].tagent = MSG_ReadShort(); - cl.lerpents[s->number].tagindex = MSG_ReadByte(); + s->tagentity = MSG_ReadShort(); + s->tagindex = MSG_ReadByte(); } if (bits & E5_LIGHT) { @@ -1260,16 +1269,14 @@ void CL_RotateAroundTag(entity_t *ent, int num, int tagent, int tagnum) int frame2 = cl.lerpents[tagent].frame; float frame2ness; -// ent->keynum = tagent; - - if (cl.lerpents[tagent].tagent) - CL_RotateAroundTag(ent, num, cl.lerpents[tagent].tagent, cl.lerpents[tagent].tagindex); - ent->keynum = tagent; ps = CL_FindPacketEntity(tagent); if (ps) { + if (ps->tagentity) + CL_RotateAroundTag(ent, num, ps->tagentity, ps->tagindex); + org = ps->origin; ang = ps->angles; model = ps->modelindex; @@ -1302,7 +1309,7 @@ void CL_RotateAroundTag(entity_t *ent, int num, int tagent, int tagnum) VectorInverse(axis[1]); frame2ness = CL_EntLerpFactor(tagent); - if (Mod_GetTag && Mod_GetTag(cl.model_precache[model], tagnum, frame, frame2, frame2ness, cl.time - cl.lerpents[tagent].framechange, cl.time - cl.lerpents[tagent].framechange, transform)) + if (Mod_GetTag && Mod_GetTag(cl.model_precache[model], tagnum, frame, frame2, frame2ness, cl.time - cl.lerpents[tagent].framechange, cl.time - cl.lerpents[tagent].oldframechange, transform)) { old[0] = ent->axis[0][0]; old[1] = ent->axis[1][0]; @@ -1345,17 +1352,6 @@ void CL_RotateAroundTag(entity_t *ent, int num, int tagent, int tagnum) ent->axis[1][2] = result[9]; ent->axis[2][2] = result[10]; ent->origin[2] = result[11]; -/* - VectorAdd(org, ent->origin, destorg); - VectorMA(destorg, tagorg[0], ent->axis[0], destorg); - VectorMA(destorg, tagorg[1], ent->axis[1], destorg); - VectorMA(destorg, tagorg[2], ent->axis[2], destorg); - VectorCopy(destorg, ent->origin); - -// Con_Printf("Found tag %i\n", cl.lerpents[tagent].tagindex); - Matrix3_Multiply(axis, ent->axis, temp); //the ent->axis here is the result of the parent's transforms - Matrix3_Multiply((void*)tagaxis, temp, ent->axis); -*/ } else //hrm. { @@ -1363,8 +1359,6 @@ void CL_RotateAroundTag(entity_t *ent, int num, int tagent, int tagnum) VectorCopy(org, ent->origin); } } -// if (org) -// VectorAdd(ent->origin, org, ent->origin); } void V_AddEntity(entity_t *in) @@ -1515,7 +1509,7 @@ void CL_LinkPacketEntities (void) ent->keynum = s1->number; - if (cl_r2g.value && s1->modelindex == cl_rocketindex && cl_rocketindex) + if (cl_r2g.value && s1->modelindex == cl_rocketindex && cl_rocketindex && cl_grenadeindex) ent->model = cl.model_precache[cl_grenadeindex]; else ent->model = model; @@ -1547,24 +1541,22 @@ void CL_LinkPacketEntities (void) ent->frame = s1->frame; ent->oldframe = cl.lerpents[s1->number].frame; + ent->frame1time = cl.time - cl.lerpents[s1->number].framechange; + ent->frame2time = cl.time - cl.lerpents[s1->number].oldframechange; // f = (sin(realtime)+1)/2; #ifdef PEXT_SCALE //set scale - ent->scale = s1->scale; - if (!ent->scale) - ent->scale=1; + ent->scale = s1->scale/16.0; #endif #ifdef PEXT_TRANS //set trans - ent->alpha = s1->trans; - if (!ent->alpha) - ent->alpha=1; + ent->alpha = s1->trans/255.0; #endif #ifdef PEXT_FATNESS //set trans - ent->fatness = s1->fatness; + ent->fatness = s1->fatness/2.0; #endif // rotate binary objects locally @@ -1598,18 +1590,18 @@ void CL_LinkPacketEntities (void) AngleVectors(angles, ent->axis[0], ent->axis[1], ent->axis[2]); VectorInverse(ent->axis[1]); - if (cl.lerpents[s1->number].tagent) - { //ent is attached to a tag, rotate this ent accordingly. - CL_RotateAroundTag(ent, s1->number, cl.lerpents[s1->number].tagent, cl.lerpents[s1->number].tagindex); - } - if (ent->keynum <= MAX_CLIENTS #ifdef NQPROT - && cls.protocol != CP_NETQUAKE + && cls.protocol == CP_QUAKEWORLD #endif ) ent->keynum += MAX_EDICTS; + if (s1->tagentity) + { //ent is attached to a tag, rotate this ent accordingly. + CL_RotateAroundTag(ent, s1->number, s1->tagentity, s1->tagindex); + } + // add automatic particle trails if (!model || (!(model->flags&~EF_ROTATE) && model->particletrail<0)) continue; @@ -1933,8 +1925,8 @@ void CL_ParsePlayerinfo (void) state->weaponframe = MSG_ReadByte (); state->hullnum = 1; - state->scale = 1; - state->trans = 1; + state->scale = 1*16; + state->trans = 255; state->fatness = 0; state->pm_type = PM_NORMAL; @@ -2039,35 +2031,35 @@ void CL_ParsePlayerinfo (void) state->hullnum = 1; else state->hullnum = 56; - state->scale = 1; - state->trans = 1; + state->scale = 1*16; + state->trans = 255; state->fatness = 0; +#ifdef PEXT_SCALE + if (flags & PF_SCALE_Z && cls.fteprotocolextensions & PEXT_SCALE) + state->scale = (float)MSG_ReadByte() / 100; +#endif +#ifdef PEXT_TRANS + if (flags & PF_TRANS_Z && cls.fteprotocolextensions & PEXT_TRANS) + state->trans = (float)MSG_ReadByte() / 255; +#endif +#ifdef PEXT_FATNESS + if (flags & PF_FATNESS_Z && cls.fteprotocolextensions & PEXT_FATNESS) + state->fatness = (float)MSG_ReadChar() / 2; +#endif +#ifdef PEXT_HULLSIZE + if (cls.fteprotocolextensions & PEXT_HULLSIZE) + { + if (flags & PF_HULLSIZE_Z) + state->hullnum = MSG_ReadByte(); + } + //should be passed to player move func. +#endif + if (cls.z_ext & Z_EXT_PM_TYPE) { int pm_code; -#ifdef PEXT_SCALE - if (flags & PF_SCALE_Z && cls.fteprotocolextensions & PEXT_SCALE) - state->scale = (float)MSG_ReadByte() / 100; -#endif -#ifdef PEXT_TRANS - if (flags & PF_TRANS_Z && cls.fteprotocolextensions & PEXT_TRANS) - state->trans = (float)MSG_ReadByte() / 255; -#endif -#ifdef PEXT_FATNESS - if (flags & PF_FATNESS_Z && cls.fteprotocolextensions & PEXT_FATNESS) - state->fatness = (float)MSG_ReadChar() / 2; -#endif -#ifdef PEXT_HULLSIZE - if (cls.fteprotocolextensions & PEXT_HULLSIZE) - { - if (flags & PF_HULLSIZE_Z) - state->hullnum = MSG_ReadByte(); - } - //should be passed to player move func. -#endif - pm_code = (flags&PF_PMC_MASK) >> PF_PMC_SHIFT; if (pm_code == PMC_NORMAL || pm_code == PMC_NORMAL_JUMP_HELD) { @@ -2107,24 +2099,6 @@ void CL_ParsePlayerinfo (void) } else { -#ifdef PEXT_SCALE - if (flags & PF_SCALE_NOZ && cls.fteprotocolextensions & PEXT_SCALE) - state->scale = (float)MSG_ReadByte() / 100; -#endif -#ifdef PEXT_TRANS - if (flags & PF_TRANS_NOZ && cls.fteprotocolextensions & PEXT_TRANS) - state->trans = (float)MSG_ReadByte() / 255; -#endif -#ifdef PEXT_FATNESS - if (flags & PF_FATNESS_NOZ && cls.fteprotocolextensions & PEXT_FATNESS) - state->fatness = (float)MSG_ReadChar() / 2; -#endif -#ifdef PEXT_HULLSIZE - if (flags & PF_HULLSIZE_NOZ && cls.fteprotocolextensions & PEXT_HULLSIZE) - state->hullnum = MSG_ReadByte(); - //should be passed to player move func. -#endif - guess_pm_type: if (cl.players[num].spectator) state->pm_type = PM_OLD_SPECTATOR; @@ -2228,15 +2202,6 @@ void CL_AddVWeapModel(entity_t *player, int model) VectorInverse(newent->axis[1]); } -void CL_ParseAttachment(void) -{ - int e = (unsigned short)MSG_ReadShort(); - int o = (unsigned short)MSG_ReadShort(); - int i = (unsigned short)MSG_ReadShort(); - cl.lerpents[e].tagent = o; - cl.lerpents[e].tagindex = i; -} - /* ============= CL_LinkPlayers @@ -2306,6 +2271,9 @@ void CL_LinkPlayers (void) ent->model = cl.model_precache[state->modelindex]; ent->skinnum = state->skinnum; + ent->frame1time = cl.time - cl.lerpents[j].framechange; + ent->frame2time = cl.time - cl.lerpents[j].oldframechange; + ent->frame = state->frame; ent->oldframe = state->oldframe; if (state->lerpstarttime) @@ -2326,16 +2294,12 @@ void CL_LinkPlayers (void) ent->scoreboard = NULL; #ifdef PEXT_SCALE - ent->scale = state->scale; - if (!ent->scale) - ent->scale = 1; + ent->scale = state->scale/16.0f; #endif #ifdef PEXT_TRANS - ent->alpha = state->trans; - if (!ent->alpha) - ent->alpha = 1; + ent->alpha = state->trans/255.0f; #endif - + ent->fatness = state->fatness/2; // // angles // diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 95c7a7326..bba85ae11 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -399,7 +399,7 @@ void CL_SendConnectPacket ( Info_SetValueForStarKey (playerinfo2, "name", "Second player", MAX_INFO_STRING); clients = 1; - if (cl_splitscreen.value) + if (cl_splitscreen.value && (fteprotextsupported & PEXT_SPLITSCREEN)) { // if (adr.type == NA_LOOPBACK) clients = cl_splitscreen.value+1; @@ -827,6 +827,14 @@ void CL_ClearState (void) memset (cl_baselines, 0, sizeof(cl_baselines)); + for (i = 0; i < MAX_EDICTS; i++) + { + cl_baselines[i].scale = 1*16; + cl_baselines[i].trans = 255; + } + + + // // allocate the efrags and chain together into a free list // @@ -980,13 +988,13 @@ void CL_Disconnect (void) void CL_Disconnect_f (void) { - CL_Disconnect (); - #ifndef CLIENTONLY if (sv.state) SV_UnspawnServer(); #endif + CL_Disconnect (); + Alias_WipeStuffedAliaes(); } @@ -2945,6 +2953,8 @@ void Host_Init (quakeparms_t *parms) host_initialized = true; + Cbuf_Execute (); //if the server initialisation causes a problem, give it a place to abort to + Cmd_StuffCmds(); Cbuf_Execute (); //if the server initialisation causes a problem, give it a place to abort to diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index 98c7e554b..584015ff2 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -2027,10 +2027,10 @@ void CL_ParseBaseline (entity_state_t *es) es->angles[i] = MSG_ReadAngle (); } #ifdef PEXT_SCALE - es->scale = 1; + es->scale = 1*16; #endif #ifdef PEXT_TRANS - es->trans = 1; + es->trans = 255; #endif } void CL_ParseBaseline2 (void) @@ -2114,12 +2114,12 @@ void CL_ParseStatic (int version) ent->drawflags = es.hexen2flags; #ifdef PEXT_SCALE - ent->scale = es.scale; + ent->scale = es.scale/16.0; #endif #ifdef PEXT_TRANS - ent->alpha = es.trans; + ent->alpha = es.trans/255.0; #endif - ent->fatness = es.fatness; + ent->fatness = es.fatness/2.0; ent->abslight = es.abslight; VectorCopy (es.origin, ent->origin); @@ -3581,10 +3581,6 @@ void CL_ParseServerMessage (void) SCR_ShowPic_Update(); break; - case svc_setattachment: - CL_ParseAttachment(); - break; - case svcqw_effect: CL_ParseEffect(false); break; diff --git a/engine/client/cl_screen.c b/engine/client/cl_screen.c index 07fbb9efd..2d6d82f71 100644 --- a/engine/client/cl_screen.c +++ b/engine/client/cl_screen.c @@ -1542,10 +1542,8 @@ void SCR_DrawCharToSnap (int num, qbyte *dest, int width) while (drawline--) { for (x=0 ; x<8 ; x++) - if (source[x]) + if (source[x]!=255) dest[x] = source[x]; - else - dest[x] = 98; source += 128; dest -= width; } @@ -1645,8 +1643,8 @@ qboolean SCR_RSShot (void) g /= count; b /= count; *dest++ = r; - *dest++ = b; *dest++ = g; + *dest++ = b; } } diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index eae8d6859..6b265ac55 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -967,8 +967,7 @@ void CL_ParseTEnt (void) // use a particle effect and let the user decide what to do with it? break; - case 76: -#pragma message("CL_ParseTEnt: effect 76 not implemented") + case DPTE_TEI_G3: //nexuiz's nex beam pos[0] = MSG_ReadCoord (); pos[1] = MSG_ReadCoord (); pos[2] = MSG_ReadCoord (); @@ -982,19 +981,19 @@ void CL_ParseTEnt (void) MSG_ReadCoord (); MSG_ReadCoord (); - CLQ2_RailTrail (pos, pos2); + P_ParticleTrail(pos, pos2, P_FindParticleType("te_nexbeam"), NULL); break; case DPTE_SMOKE: //org pos[0] = MSG_ReadCoord (); - pos[0] = MSG_ReadCoord (); - pos[0] = MSG_ReadCoord (); + pos[1] = MSG_ReadCoord (); + pos[2] = MSG_ReadCoord (); //dir pos2[0] = MSG_ReadCoord (); - pos2[0] = MSG_ReadCoord (); - pos2[0] = MSG_ReadCoord (); + pos2[1] = MSG_ReadCoord (); + pos2[2] = MSG_ReadCoord (); //count cnt = MSG_ReadByte (); @@ -1004,7 +1003,7 @@ void CL_ParseTEnt (void) } break; - case 79: + case DPTE_TEI_PLASMAHIT: pos[0] = MSG_ReadCoord (); pos[1] = MSG_ReadCoord (); pos[2] = MSG_ReadCoord (); @@ -1240,12 +1239,27 @@ void CL_ParseParticleEffect4 (void) P_RunParticleEffect4 (org, radius, color, effect, msgcount); } +void CL_SpawnSpriteEffect(vec3_t org, model_t *model, int startframe, int framecount, int framerate) +{ + explosion_t *ex; + + ex = CL_AllocExplosion (); + VectorCopy (org, ex->origin); + ex->start = cl.time; + ex->model = model; + ex->firstframe = startframe; + ex->numframes = framecount; + ex->framerate = framerate; + + ex->angles[0] = 0; + ex->angles[1] = 0; + ex->angles[2] = 0; +} // [vector] org [byte] modelindex [byte] startframe [byte] framecount [byte] framerate // [vector] org [short] modelindex [short] startframe [byte] framecount [byte] framerate void CL_ParseEffect (qboolean effect2) { - explosion_t *ex; vec3_t org; int modelindex; int startframe; @@ -1270,17 +1284,7 @@ void CL_ParseEffect (qboolean effect2) framerate = MSG_ReadByte(); - ex = CL_AllocExplosion (); - VectorCopy (org, ex->origin); - ex->start = cl.time; - ex->model = cl.model_precache[modelindex]; - ex->firstframe = startframe; - ex->numframes = framecount; - ex->framerate = framerate; - - ex->angles[0] = 0; - ex->angles[1] = 0; - ex->angles[2] = 0; + CL_SpawnSpriteEffect(org, cl.model_precache[modelindex], startframe, framecount, framerate); } #ifdef Q2CLIENT diff --git a/engine/client/client.h b/engine/client/client.h index f60f68423..9baf89f79 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -391,8 +391,6 @@ typedef struct { vec3_t angles; trailstate_t *trailstate; //when to next throw out a trail unsigned short frame; - unsigned short tagent; - unsigned short tagindex; } lerpents_t; // // the client_state_t structure is wiped completely at every @@ -713,7 +711,6 @@ void CL_StartUpload (qbyte *data, int size); void CL_StopUpload(void); void CL_RequestNextDownload (void); -void CL_ParseAttachment(void); // // view.c diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index 66252b24d..59929c153 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -137,11 +137,25 @@ static void CSQC_FindGlobals(void) fieldfloat(frame); \ fieldfloat(oldframe); \ fieldfloat(lerpfrac); \ + fieldfloat(renderflags);\ \ fieldfloat(drawmask); /*So that the qc can specify all rockets at once or all bannanas at once*/ \ fieldfunction(predraw); /*If present, is called just before it's drawn.*/ \ \ - fieldstring(model); + fieldstring(model); \ + fieldfloat(ideal_yaw); \ + fieldfloat(ideal_pitch);\ + fieldfloat(yaw_speed); \ + fieldfloat(pitch_speed);\ + \ + fieldentity(chain); \ + \ + fieldvector(solid); \ + fieldvector(mins); \ + fieldvector(maxs); \ + fieldvector(absmins); \ + fieldvector(absmaxs); \ + fieldfloat(hull); /*(FTE_PEXT_HEXEN2)*/ //note: doesn't even have to match the clprogs.dat :) @@ -243,8 +257,10 @@ void PF_normalize (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_vlen (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_vectoyaw (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_vectoangles (progfuncs_t *prinst, struct globalvars_s *pr_globals); +void PF_FindFlags (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_findchain (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_findchainfloat (progfuncs_t *prinst, struct globalvars_s *pr_globals); +void PF_findchainflags (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_coredump (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_traceon (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_traceoff (progfuncs_t *prinst, struct globalvars_s *pr_globals); @@ -274,6 +290,12 @@ void PF_CL_drawsetcliparea (progfuncs_t *prinst, struct globalvars_s *pr_globals void PF_CL_drawresetcliparea (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_CL_drawgetimagesize (progfuncs_t *prinst, struct globalvars_s *pr_globals); +void search_close_progs(progfuncs_t *prinst, qboolean complain); +void PF_search_begin (progfuncs_t *prinst, struct globalvars_s *pr_globals); +void PF_search_end (progfuncs_t *prinst, struct globalvars_s *pr_globals); +void PF_search_getsize (progfuncs_t *prinst, struct globalvars_s *pr_globals); +void PF_search_getfilename (progfuncs_t *prinst, struct globalvars_s *pr_globals); + #define MAXTEMPBUFFERLEN 1024 @@ -281,7 +303,72 @@ void PF_fclose_progs (progfuncs_t *prinst); char *PF_VarString (progfuncs_t *prinst, int first, struct globalvars_s *pr_globals); -static void PF_Remove_ (progfuncs_t *prinst, struct globalvars_s *pr_globals) + + + + + +void CL_CS_LinkEdict(csqcedict_t *ent) +{ + //FIXME: use some sort of area grid ? + VectorAdd(ent->v->origin, ent->v->mins, ent->v->absmins); + VectorAdd(ent->v->origin, ent->v->maxs, ent->v->absmaxs); +} + +//FIXME: Not fully functional +trace_t CL_Move(vec3_t v1, vec3_t mins, vec3_t maxs, vec3_t v2, float nomonsters, csqcedict_t *passedict) +{ + int e; + csqcedict_t *ed; + vec3_t minb, maxb; + hull_t *hull; + + trace_t trace, trace2; + + memset(&trace, 0, sizeof(trace)); + trace.fraction = 1; + cl.worldmodel->hulls->funcs.RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, v1, v2, &trace); + +//why use trace.endpos instead? +//so that if we hit a wall early, we don't have a box covering the whole world because of a shotgun trace. + minb[0] = ((v1[0] < trace.endpos[0])?v1[0]:trace.endpos[0]) - mins[0]-1; + minb[1] = ((v1[1] < trace.endpos[1])?v1[1]:trace.endpos[1]) - mins[1]-1; + minb[2] = ((v1[2] < trace.endpos[2])?v1[2]:trace.endpos[2]) - mins[2]-1; + maxb[0] = ((v1[0] > trace.endpos[0])?v1[0]:trace.endpos[0]) + maxs[0]+1; + maxb[1] = ((v1[1] > trace.endpos[1])?v1[1]:trace.endpos[1]) + maxs[1]+1; + maxb[2] = ((v1[2] > trace.endpos[2])?v1[2]:trace.endpos[2]) + maxs[2]+1; +/* + for (e=1; e < *csqcprogs->parms->sv_num_edicts; e++) + { + ed = (void*)EDICT_NUM(csqcprogs, e); + if (ed->isfree) + continue; //can't collide + if (!ed->v->solid) + continue; + if (ed->v->absmaxs[0] < minb[0] || + ed->v->absmaxs[1] < minb[1] || + ed->v->absmaxs[2] < minb[2] || + ed->v->absmins[0] > maxb[0] || + ed->v->absmins[1] > maxb[1] || + ed->v->absmins[2] > maxb[2]) + continue; + + hull = CL_HullForEntity(ed); + memset(&trace, 0, sizeof(trace)); + trace.fraction = 1; + TransformedHullCheck(hull, v1, v2, &trace2, ed->v->angles); + trace2.ent = (void*)ed; + if (trace2.fraction < trace.fraction) + trace = trace2; + } +*/ + return trace; +} + + + + +static void PF_cs_remove (progfuncs_t *prinst, struct globalvars_s *pr_globals) { csqcedict_t *ed; @@ -316,23 +403,23 @@ static void PF_Fixme (progfuncs_t *prinst, struct globalvars_s *pr_globals) { Con_Printf("\n"); - prinst->RunError(prinst, "\nBuiltin %i not implemented.\nMenu is not compatable.", prinst->lastcalledbuiltinnumber); + prinst->RunError(prinst, "\nBuiltin %i not implemented.\nCSQC is not compatable.", prinst->lastcalledbuiltinnumber); PR_BIError (prinst, "bulitin not implemented"); } -static void PF_csqc_centerprint (progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_cl_cprint (progfuncs_t *prinst, struct globalvars_s *pr_globals) { char *str = PF_VarString(prinst, 0, pr_globals); SCR_CenterPrint(0, str); } -static void PF_makevectors (progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_cs_makevectors (progfuncs_t *prinst, struct globalvars_s *pr_globals) { if (!csqcg.forward || !csqcg.right || !csqcg.up) Host_EndGame("PF_makevectors: one of v_forward, v_right or v_up was not defined\n"); AngleVectors (G_VECTOR(OFS_PARM0), csqcg.forward, csqcg.right, csqcg.up); } - +/* void QuaternainToAngleMatrix(float *quat, vec3_t *mat) { float xx = quat[0] * quat[0]; @@ -392,8 +479,14 @@ void EularToQuaternian(vec3_t angles, float *quat) quaternion_multiply(x, y, t); quaternion_multiply(t, z, quat); } +*/ +#define CSQCRF_VIEWMODEL 1 //Not drawn in mirrors +#define CSQCRF_EXTERNALMODEL 2 //drawn ONLY in mirrors +#define CSQCRF_DEPTHHACK 4 //fun depthhack +#define CSQCRF_ADDATIVE 8 //add instead of blend +#define CSQCRF_USEAXIS 16 //use v_forward/v_right/v_up as an axis/matrix - predraw is needed to use this properly -void _PF_R_AddEntity(progfuncs_t *prinst, struct globalvars_s *pr_globals) +void PF_R_AddEntity(progfuncs_t *prinst, struct globalvars_s *pr_globals) { csqcedict_t *in = (void*)G_EDICT(prinst, OFS_PARM0); entity_t ent; @@ -427,6 +520,19 @@ void _PF_R_AddEntity(progfuncs_t *prinst, struct globalvars_s *pr_globals) return; } + if (in->v->renderflags) + { + i = in->v->renderflags; + if (i & CSQCRF_VIEWMODEL) + ent.flags |= Q2RF_WEAPONMODEL; + if (i & CSQCRF_EXTERNALMODEL) + ent.flags |= Q2RF_EXTERNALMODEL; + if (i & CSQCRF_DEPTHHACK) + ent.flags |= Q2RF_DEPTHHACK; + if (i * CSQCRF_ADDATIVE) + ent.flags |= Q2RF_ADDATIVE; + //CSQCRF_USEAXIS is below + } ent.frame = in->v->frame; ent.oldframe = in->v->oldframe; @@ -436,13 +542,23 @@ void _PF_R_AddEntity(progfuncs_t *prinst, struct globalvars_s *pr_globals) ent.angles[1] = in->v->angles[1]; ent.angles[2] = in->v->angles[2]; - memcpy(ent.origin, in->v->origin, sizeof(vec3_t)); - AngleVectors(ent.angles, ent.axis[0], ent.axis[1], ent.axis[2]); - VectorInverse(ent.axis[1]); + VectorCopy(in->v->origin, ent.origin); + if ((int)in->v->renderflags & CSQCRF_USEAXIS) + { + VectorCopy(csqcg.forward, ent.axis[0]); + VectorNegate(csqcg.right, ent.axis[1]); + VectorCopy(csqcg.up, ent.axis[2]); + } + else + { + AngleVectors(ent.angles, ent.axis[0], ent.axis[1], ent.axis[2]); + VectorInverse(ent.axis[1]); + } ent.alpha = in->v->alpha; ent.scale = in->v->scale; ent.skinnum = in->v->skin; + ent.fatness = in->v->fatness; V_AddEntity(&ent); @@ -466,10 +582,6 @@ void _PF_R_AddEntity(progfuncs_t *prinst, struct globalvars_s *pr_globals) } */ } -void PF_R_AddEntity(progfuncs_t *prinst, struct globalvars_s *pr_globals) -{ - _PF_R_AddEntity(prinst, pr_globals); -} static void PF_R_AddDynamicLight(progfuncs_t *prinst, struct globalvars_s *pr_globals) { @@ -557,6 +669,8 @@ static void PF_R_SetViewFlag(progfuncs_t *prinst, struct globalvars_s *pr_global { char *s = PR_GetStringOfs(prinst, OFS_PARM0); float *p = G_VECTOR(OFS_PARM1); + + G_FLOAT(OFS_RETURN) = 1; switch(*s) { case 'F': @@ -667,6 +781,8 @@ static void PF_R_SetViewFlag(progfuncs_t *prinst, struct globalvars_s *pr_global break; } Con_DPrintf("SetViewFlag: %s not recognised\n", s); + + G_FLOAT(OFS_RETURN) = 0; } static void PF_R_RenderScene(progfuncs_t *prinst, struct globalvars_s *pr_globals) @@ -754,39 +870,40 @@ static void PF_cs_getstats(progfuncs_t *prinst, struct globalvars_s *pr_globals) RETURN_SSTRING(out); } -static void PF_CSQC_SetOrigin(progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_cs_SetOrigin(progfuncs_t *prinst, struct globalvars_s *pr_globals) { csqcedict_t *ent = (void*)G_EDICT(prinst, OFS_PARM0); float *org = G_VECTOR(OFS_PARM1); + VectorCopy(org, ent->v->origin); - //fixme: add some sort of fast area grid + CL_CS_LinkEdict(ent); } -static void PF_CSQC_SetSize(progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_cs_SetSize(progfuncs_t *prinst, struct globalvars_s *pr_globals) { csqcedict_t *ent = (void*)G_EDICT(prinst, OFS_PARM0); float *mins = G_VECTOR(OFS_PARM1); float *maxs = G_VECTOR(OFS_PARM1); - //fixme: set the size. :p + VectorCopy(mins, ent->v->mins); + VectorCopy(maxs, ent->v->maxs); - //fixme: add some sort of fast area grid + CL_CS_LinkEdict(ent); } -//FIXME: Not fully functional -static void PF_CSQC_traceline(progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_cs_traceline(progfuncs_t *prinst, struct globalvars_s *pr_globals) { float *v1, *v2, *mins, *maxs; trace_t trace; int nomonsters; - edict_t *ent; -// int savedhull; + csqcedict_t *ent; + int savedhull; v1 = G_VECTOR(OFS_PARM0); v2 = G_VECTOR(OFS_PARM1); nomonsters = G_FLOAT(OFS_PARM2); - ent = G_EDICT(prinst, OFS_PARM3); + ent = (csqcedict_t*)G_EDICT(prinst, OFS_PARM3); // if (*prinst->callargc == 6) // { @@ -798,17 +915,12 @@ static void PF_CSQC_traceline(progfuncs_t *prinst, struct globalvars_s *pr_globa mins = vec3_origin; maxs = vec3_origin; } -/* - savedhull = ent->v.hull; - ent->v.hull = 0; - trace = SV_Move (v1, mins, maxs, v2, nomonsters, ent); - ent->v.hull = savedhull; -*/ - - memset(&trace, 0, sizeof(trace)); - trace.fraction = 1; - cl.worldmodel->hulls->funcs.RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, v1, v2, &trace); + savedhull = ent->v->hull; + ent->v->hull = 0; + trace = CL_Move (v1, mins, maxs, v2, nomonsters, ent); + ent->v->hull = savedhull; + *csqcg.trace_allsolid = trace.allsolid; *csqcg.trace_startsolid = trace.startsolid; *csqcg.trace_fraction = trace.fraction; @@ -817,13 +929,46 @@ static void PF_CSQC_traceline(progfuncs_t *prinst, struct globalvars_s *pr_globa VectorCopy (trace.endpos, csqcg.trace_endpos); VectorCopy (trace.plane.normal, csqcg.trace_plane_normal); *csqcg.trace_plane_dist = trace.plane.dist; -// if (trace.ent) -// *csqcg.trace_ent = EDICT_TO_PROG(prinst, trace.ent); -// else + if (trace.ent) + *csqcg.trace_ent = EDICT_TO_PROG(prinst, (void*)trace.ent); + else + *csqcg.trace_ent = EDICT_TO_PROG(prinst, (void*)csqc_edicts); +} +static void PF_cs_tracebox(progfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + float *v1, *v2, *mins, *maxs; + trace_t trace; + int nomonsters; + csqcedict_t *ent; + int savedhull; + + v1 = G_VECTOR(OFS_PARM0); + mins = G_VECTOR(OFS_PARM1); + maxs = G_VECTOR(OFS_PARM2); + v2 = G_VECTOR(OFS_PARM3); + nomonsters = G_FLOAT(OFS_PARM4); + ent = (csqcedict_t*)G_EDICT(prinst, OFS_PARM5); + + savedhull = ent->v->hull; + ent->v->hull = 0; + trace = CL_Move (v1, mins, maxs, v2, nomonsters, ent); + ent->v->hull = savedhull; + + *csqcg.trace_allsolid = trace.allsolid; + *csqcg.trace_startsolid = trace.startsolid; + *csqcg.trace_fraction = trace.fraction; + *csqcg.trace_inwater = trace.inwater; + *csqcg.trace_inopen = trace.inopen; + VectorCopy (trace.endpos, csqcg.trace_endpos); + VectorCopy (trace.plane.normal, csqcg.trace_plane_normal); + *csqcg.trace_plane_dist = trace.plane.dist; + if (trace.ent) + *csqcg.trace_ent = EDICT_TO_PROG(prinst, (void*)trace.ent); + else *csqcg.trace_ent = EDICT_TO_PROG(prinst, (void*)csqc_edicts); } -static void PF_CSQC_pointcontents(progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_cs_pointcontents(progfuncs_t *prinst, struct globalvars_s *pr_globals) { float *v; int cont; @@ -868,7 +1013,7 @@ static int FindModel(char *name, int *free) } return 0; } -static void PF_CSQC_SetModel(progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_cs_SetModel(progfuncs_t *prinst, struct globalvars_s *pr_globals) { csqcedict_t *ent = (void*)G_EDICT(prinst, OFS_PARM0); char *modelname = PR_GetStringOfs(prinst, OFS_PARM1); @@ -892,7 +1037,7 @@ static void PF_CSQC_SetModel(progfuncs_t *prinst, struct globalvars_s *pr_global else ent->v->model = PR_SetString(prinst, cl.model_name[modelindex]); } -static void PF_CSQC_SetModelIndex(progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_cs_SetModelIndex(progfuncs_t *prinst, struct globalvars_s *pr_globals) { csqcedict_t *ent = (void*)G_EDICT(prinst, OFS_PARM0); int modelindex = G_FLOAT(OFS_PARM1); @@ -903,7 +1048,7 @@ static void PF_CSQC_SetModelIndex(progfuncs_t *prinst, struct globalvars_s *pr_g else ent->v->model = PR_SetString(prinst, cl.model_name[modelindex]); } -static void PF_CSQC_PrecacheModel(progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_cs_PrecacheModel(progfuncs_t *prinst, struct globalvars_s *pr_globals) { int modelindex, freei; char *modelname = PR_GetStringOfs(prinst, OFS_PARM0); @@ -932,13 +1077,13 @@ static void PF_CSQC_PrecacheModel(progfuncs_t *prinst, struct globalvars_s *pr_g cl.model_csqcprecache[-freei] = Mod_ForName(cl.model_csqcname[-freei], false); } } -static void PF_CSQC_PrecacheSound(progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_cs_PrecacheSound(progfuncs_t *prinst, struct globalvars_s *pr_globals) { char *soundname = PR_GetStringOfs(prinst, OFS_PARM0); S_PrecacheSound(soundname); } -static void PF_CSQC_ModelnameForIndex(progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_cs_ModelnameForIndex(progfuncs_t *prinst, struct globalvars_s *pr_globals) { int modelindex = G_FLOAT(OFS_PARM0); @@ -1022,7 +1167,7 @@ static void PF_cs_setsensativityscaler (progfuncs_t *prinst, struct globalvars_s static void PF_cs_pointparticles (progfuncs_t *prinst, struct globalvars_s *pr_globals) { - int effectnum = G_FLOAT(OFS_PARM0); + int effectnum = G_FLOAT(OFS_PARM0)-1; float *org = G_VECTOR(OFS_PARM1); float *vel = G_VECTOR(OFS_PARM2); float count = G_FLOAT(OFS_PARM3); @@ -1038,7 +1183,7 @@ static void PF_cs_pointparticles (progfuncs_t *prinst, struct globalvars_s *pr_g static void PF_cs_particlesloaded (progfuncs_t *prinst, struct globalvars_s *pr_globals) { char *effectname = PR_GetStringOfs(prinst, OFS_PARM0); - G_FLOAT(OFS_RETURN) = P_ParticleTypeForName(effectname); + G_FLOAT(OFS_RETURN) = P_DescriptionIsLoaded(effectname); } //get the input commands, and stuff them into some globals. @@ -1251,9 +1396,14 @@ static void PF_cs_getmousepos (progfuncs_t *prinst, struct globalvars_s *pr_glob G_FLOAT(OFS_RETURN+2) = 0; } +#define lh_extension_t void +lh_extension_t *checkfteextensionsv(char *name); +lh_extension_t *checkextension(char *name); + static void PF_checkextension (progfuncs_t *prinst, struct globalvars_s *pr_globals) { - G_FLOAT(OFS_RETURN) = 0; + char *extname = PR_GetStringOfs(prinst, OFS_PARM0); + G_FLOAT(OFS_RETURN) = checkextension(extname) || checkfteextensionsv(extname); } void PF_cs_sound(progfuncs_t *prinst, struct globalvars_s *pr_globals) @@ -1277,108 +1427,313 @@ void PF_cs_sound(progfuncs_t *prinst, struct globalvars_s *pr_globals) S_StartSound(-entity->entnum, channel, sfx, entity->v->origin, volume, attenuation); }; +static void PF_cs_particle(progfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + float *org = G_VECTOR(OFS_PARM0); + float *dir = G_VECTOR(OFS_PARM1); + float colour = G_FLOAT(OFS_PARM2); + float count = G_FLOAT(OFS_PARM2); + + P_RunParticleEffect(org, dir, colour, count); +} + +void CL_SpawnSpriteEffect(vec3_t org, model_t *model, int startframe, int framecount, int framerate); +void PF_cl_effect(progfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + float *org = G_VECTOR(OFS_PARM0); + char *name = PR_GetStringOfs(prinst, OFS_PARM1); + float startframe = G_FLOAT(OFS_PARM2); + float endframe = G_FLOAT(OFS_PARM3); + float framerate = G_FLOAT(OFS_PARM4); + model_t *mdl; + + mdl = Mod_ForName(name, false); + if (mdl) + CL_SpawnSpriteEffect(org, mdl, startframe, endframe, framerate); + else + Con_Printf("PF_cl_effect: Couldn't load model %s\n", name); +} + +void PF_cl_ambientsound(progfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + char *samp; + float *pos; + float vol, attenuation; + + pos = G_VECTOR (OFS_PARM0); + samp = PR_GetStringOfs(prinst, OFS_PARM1); + vol = G_FLOAT(OFS_PARM2); + attenuation = G_FLOAT(OFS_PARM3); + + S_StaticSound (S_PrecacheSound (samp), pos, vol, attenuation); +} + +static void PF_cs_vectorvectors (progfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + VectorCopy(G_VECTOR(OFS_PARM0), csqcg.forward); + VectorNormalize(csqcg.forward); + VectorVectors(csqcg.forward, csqcg.right, csqcg.up); +} + +static void PF_cs_lightstyle (progfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + int stnum = G_FLOAT(OFS_PARM0); + char *str = PR_GetStringOfs(prinst, OFS_PARM1); + int colourflags = 7; + + if ((unsigned)stnum >= MAX_LIGHTSTYLES) + { + Con_Printf ("PF_cs_lightstyle: stnum > MAX_LIGHTSTYLES"); + return; + } + cl_lightstyle[stnum].colour = colourflags; + Q_strncpyz (cl_lightstyle[stnum].map, str, sizeof(cl_lightstyle[stnum].map)); + cl_lightstyle[stnum].length = Q_strlen(cl_lightstyle[stnum].map); +} + +void PF_cs_changeyaw (progfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + csqcedict_t *ent; + float ideal, current, move, speed; + + ent = (void*)PROG_TO_EDICT(prinst, *csqcg.self); + current = anglemod( ent->v->angles[1] ); + ideal = ent->v->ideal_yaw; + speed = ent->v->yaw_speed; + + if (current == ideal) + return; + move = ideal - current; + if (ideal > current) + { + if (move >= 180) + move = move - 360; + } + else + { + if (move <= -180) + move = move + 360; + } + if (move > 0) + { + if (move > speed) + move = speed; + } + else + { + if (move < -speed) + move = -speed; + } + + ent->v->angles[1] = anglemod (current + move); +} +void PF_cs_changepitch (progfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + csqcedict_t *ent; + float ideal, current, move, speed; + + ent = (void*)PROG_TO_EDICT(prinst, *csqcg.self); + current = anglemod( ent->v->angles[0] ); + ideal = ent->v->ideal_pitch; + speed = ent->v->pitch_speed; + + if (current == ideal) + return; + move = ideal - current; + if (ideal > current) + { + if (move >= 180) + move = move - 360; + } + else + { + if (move <= -180) + move = move + 360; + } + if (move > 0) + { + if (move > speed) + move = speed; + } + else + { + if (move < -speed) + move = -speed; + } + + ent->v->angles[0] = anglemod (current + move); +} + +static void PF_cs_findradius (progfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + csqcedict_t *ent, *chain; + float rad; + float *org; + vec3_t eorg; + int i, j; + + chain = (csqcedict_t *)sv.edicts; + + org = G_VECTOR(OFS_PARM0); + rad = G_FLOAT(OFS_PARM1); + + for (i=1 ; iisfree) + continue; + if (ent->v->solid == SOLID_NOT) + continue; + for (j=0 ; j<3 ; j++) + eorg[j] = org[j] - (ent->v->origin[j] + (ent->v->mins[j] + ent->v->maxs[j])*0.5); + if (Length(eorg) > rad) + continue; + + ent->v->chain = EDICT_TO_PROG(prinst, (void*)chain); + chain = ent; + } + + RETURN_EDICT(prinst, (void*)chain); +} + +//these are the builtins that still need to be added. +#define PF_cs_droptofloor PF_Fixme +#define PF_cs_tracetoss PF_Fixme +#define PF_cs_makestatic PF_Fixme +#define PF_cs_copyentity PF_Fixme +#define PF_cl_te_blood PF_Fixme +#define PF_cl_te_bloodshower PF_Fixme +#define PF_cl_te_particlecube PF_Fixme +#define PF_cl_te_spark PF_Fixme +#define PF_cl_te_smallflash PF_Fixme +#define PF_cl_te_customflash PF_Fixme +#define PF_cl_te_gunshot PF_Fixme +#define PF_cl_te_spike PF_Fixme +#define PF_cl_te_superspike PF_Fixme +#define PF_cl_te_explosion PF_Fixme +#define PF_cl_te_tarexplosion PF_Fixme +#define PF_cl_te_wizspike PF_Fixme +#define PF_cl_te_knightspike PF_Fixme +#define PF_cl_te_lavasplash PF_Fixme +#define PF_cl_te_teleport PF_Fixme +#define PF_cl_te_explosion2 PF_Fixme +#define PF_cl_te_lightning1 PF_Fixme +#define PF_cl_te_lightning2 PF_Fixme +#define PF_cl_te_lightning3 PF_Fixme +#define PF_cl_te_beam PF_Fixme +#define PF_cl_te_plasmaburn PF_Fixme +#define PS_cs_setattachment PF_Fixme +#define PF_cs_break PF_Fixme +#define PF_cs_walkmove PF_Fixme +#define PF_cs_checkbottom PF_Fixme +#define PF_cl_playingdemo PF_Fixme +#define PF_cl_runningserver PF_Fixme + #define PF_FixTen PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme +//prefixes: +//PF_ - common, works on any vm +//PF_cs_ - works in csqc only (dependant upon globals or fields) +//PF_cl_ - works in csqc and menu (if needed...) + //warning: functions that depend on globals are bad, mkay? static builtin_t csqc_builtins[] = { //0 - PF_Fixme, - PF_makevectors, - PF_CSQC_SetOrigin, //PF_setorigin - PF_CSQC_SetModel, //PF_setmodel - PF_CSQC_SetSize, //PF_setsize - PF_Fixme, - PF_Fixme, //PF_break, - PF_random, - PF_cs_sound, //PF_sound, - PF_normalize, +PF_Fixme, // #0 +PF_cs_makevectors, // #1 void() makevectors (QUAKE) +PF_cs_SetOrigin, // #2 void(entity e, vector org) setorigin (QUAKE) +PF_cs_SetModel, // #3 void(entity e, string modl) setmodel (QUAKE) +PF_cs_SetSize, // #4 void(entity e, vector mins, vector maxs) setsize (QUAKE) +PF_Fixme, // #5 +PF_cs_break, // #6 void() debugbreak (QUAKE) +PF_random, // #7 float() random (QUAKE) +PF_cs_sound, // #8 void(entity e, float chan, string samp, float vol, float atten) sound (QUAKE) +PF_normalize, // #9 vector(vector in) normalize (QUAKE) //10 - PF_error, - PF_objerror, - PF_vlen, - PF_vectoyaw, - PF_Spawn, - PF_Remove_, //PF_Remove, - PF_CSQC_traceline, //PF_traceline, - PF_Fixme, //PF_checkclient, (don't support) - PF_FindString, - PF_CSQC_PrecacheSound, //PF_precache_sound, +PF_error, // #10 void(string errortext) error (QUAKE) +PF_objerror, // #11 void(string errortext) onjerror (QUAKE) +PF_vlen, // #12 float(vector v) vlen (QUAKE) +PF_vectoyaw, // #13 float(vector v) vectoyaw (QUAKE) +PF_Spawn, // #14 entity() spawn (QUAKE) +PF_cs_remove, // #15 void(entity e) remove (QUAKE) +PF_cs_traceline, // #16 void(vector v1, vector v2, float nomonst, entity forent) traceline (QUAKE) +PF_Fixme, // #17 entity() checkclient (QUAKE) (don't support) +PF_FindString, // #18 entity(entity start, .string fld, string match) findstring (QUAKE) +PF_cs_PrecacheSound, // #19 void(string str) precache_sound (QUAKE) //20 - PF_CSQC_PrecacheModel, //PF_precache_model, - PF_Fixme, //PF_stuffcmd, (don't support) - PF_Fixme, //PF_findradius, - PF_Fixme, //PF_bprint, (don't support) - PF_Fixme, //PF_sprint, - PF_dprint, - PF_ftos, - PF_vtos, - PF_coredump, - PF_traceon, +PF_cs_PrecacheModel, // #20 void(string str) precache_model (QUAKE) +PF_Fixme, // #21 void(entity client, string s) stuffcmd (QUAKE) (don't support) +PF_cs_findradius, // #22 entity(vector org, float rad) findradius (QUAKE) +PF_Fixme, // #23 void(string s, ...) bprint (QUAKE) (don't support) +PF_Fixme, // #24 void(entity e, string s, ...) sprint (QUAKE) (don't support) +PF_dprint, // #25 void(string s, ...) dprint (QUAKE) +PF_ftos, // #26 string(float f) ftos (QUAKE) +PF_vtos, // #27 string(vector f) vtos (QUAKE) +PF_coredump, // #28 void(void) coredump (QUAKE) +PF_traceon, // #29 void() traceon (QUAKE) //30 - PF_traceoff, - PF_eprint, - PF_Fixme, //PF_walkmove, (don't support yet) - PF_Fixme, -PF_Fixme, //PF_droptofloor, -PF_Fixme, //PF_lightstyle, -PF_rint, -PF_floor, -PF_ceil, -PF_Fixme, +PF_traceoff, // #30 void() traceoff (QUAKE) +PF_eprint, // #31 void(entity e) eprint (QUAKE) +PF_cs_walkmove, // #32 float(float yaw, float dist) walkmove (QUAKE) +PF_Fixme, // #33 +PF_cs_droptofloor, // #34 +PF_cs_lightstyle, // #35 void(float lightstyle, string stylestring) lightstyle (QUAKE) +PF_rint, // #36 float(float f) rint (QUAKE) +PF_floor, // #37 float(float f) floor (QUAKE) +PF_ceil, // #38 float(float f) ceil (QUAKE) +PF_Fixme, // #39 //40 -PF_Fixme, //PF_checkbottom, -PF_CSQC_pointcontents, //PF_pointcontents, -PF_Fixme, -PF_fabs, -PF_Fixme, //PF_aim, hehehe... (don't support) -PF_cvar, -PF_localcmd, -PF_nextent, -PF_Fixme, //PF_particle, -PF_Fixme, //PF_changeyaw, +PF_cs_checkbottom, // #40 float(entity e) checkbottom (QUAKE) +PF_cs_pointcontents, // #41 float(vector org) pointcontents (QUAKE) +PF_Fixme, // #42 +PF_fabs, // #43 float(float f) fabs (QUAKE) +PF_Fixme, // #44 vector(entity e, float speed) aim (QUAKE) (don't support) +PF_cvar, // #45 float(string cvarname) cvar (QUAKE) +PF_localcmd, // #46 void(string str) localcmd (QUAKE) +PF_nextent, // #47 entity(entity e) nextent (QUAKE) +PF_cs_particle, // #48 void(vector org, vector dir, float colour, float count) particle (QUAKE) +PF_cs_changeyaw, // #49 void() changeyaw (QUAKE) //50 -PF_Fixme, -PF_vectoangles, +PF_Fixme, // #50 +PF_vectoangles, // #51 vector(vector v) vectoangles (QUAKE) +PF_Fixme, // #52 void(float to, float f) WriteByte (QUAKE) +PF_Fixme, // #53 void(float to, float f) WriteChar (QUAKE) +PF_Fixme, // #54 void(float to, float f) WriteShort (QUAKE) -PF_ReadByte, -PF_ReadChar, -PF_ReadShort, -PF_ReadLong, -PF_ReadCoord, -PF_ReadAngle, -PF_ReadString, -PF_Fixme,//PF_ReadEntity, +PF_Fixme, // #55 void(float to, float f) WriteLong (QUAKE) +PF_Fixme, // #56 void(float to, float f) WriteCoord (QUAKE) +PF_Fixme, // #57 void(float to, float f) WriteAngle (QUAKE) +PF_Fixme, // #58 void(float to, float f) WriteString (QUAKE) +PF_Fixme, // #59 void(float to, float f) WriteEntity (QUAKE) //60 -PF_Fixme, +PF_Sin, // #60 float(float angle) sin (DP_QC_SINCOSSQRTPOW) +PF_Cos, // #61 float(float angle) cos (DP_QC_SINCOSSQRTPOW) +PF_Sqrt, // #62 float(float value) sqrt (DP_QC_SINCOSSQRTPOW) +PF_cs_changepitch, // #63 void(entity ent) changepitch (DP_QC_CHANGEPITCH) +PF_cs_tracetoss, // #64 void(entity ent, entity ignore) tracetoss (DP_QC_TRACETOSS) -PF_Sin, -PF_Cos, -PF_Sqrt, - -PF_Fixme, - -PF_Fixme, -PF_Fixme, -SV_MoveToGoal, -PF_Fixme, //PF_precache_file, (don't support) -PF_Fixme, //PF_makestatic, +PF_etos, // #65 string(entity ent) etos (DP_QC_ETOS) +PF_Fixme, // #66 +PF_Fixme, // #67 void(float step) movetogoal (QUAKE) +PF_Fixme, // #68 void(string s) precache_file (QUAKE) (don't support) +PF_cs_makestatic, // #69 void(entity e) makestatic (QUAKE) //70 -PF_Fixme, //PF_changelevel, (don't support) -PF_Fixme, -PF_cvar_set, -PF_Fixme, //PF_centerprint, -PF_Fixme, //PF_ambientsound, +PF_Fixme, // #70 void(string mapname) changelevel (QUAKE) (don't support) +PF_Fixme, // #71 +PF_cvar_set, // #72 void(string cvarname, string valuetoset) cvar_set (QUAKE) +PF_Fixme, // #73 void(entity ent, string text) centerprint (QUAKE) (don't support - cprint is supported instead) +PF_cl_ambientsound, // #74 void (vector pos, string samp, float vol, float atten) ambientsound (QUAKE) -PF_CSQC_PrecacheModel, //PF_precache_model, -PF_Fixme, //PF_precache_sound, -PF_Fixme, //PF_precache_file, -PF_Fixme, //PF_setspawnparms, -PF_Fixme, //PF_logfrag, (don't support) +PF_cs_PrecacheModel, // #75 void(string str) precache_model2 (QUAKE) +PF_cs_PrecacheSound, // #76 void(string str) precache_sound2 (QUAKE) +PF_Fixme, // #77 void(string str) precache_file2 (QUAKE) +PF_Fixme, // #78 void() setspawnparms (QUAKE) (don't support) +PF_Fixme, // #79 void(entity killer, entity killee) logfrag (QW_ENGINE) (don't support) //80 -PF_Fixme, //PF_infokey, -PF_stof, -PF_Fixme, //PF_multicast, (don't support) +PF_Fixme, // #80 string(entity e, string keyname) infokey (QW_ENGINE) (don't support) +PF_stof, // #81 float(string s) stof (FRIK_FILE or QW_ENGINE) +PF_Fixme, // #82 void(vector where, float set) multicast (QW_ENGINE) (don't support) PF_Fixme, PF_Fixme, @@ -1388,19 +1743,19 @@ PF_Fixme, PF_Fixme, PF_Fixme, //90 +PF_cs_tracebox, PF_Fixme, PF_Fixme, -PF_Fixme, -PF_registercvar, -PF_Fixme, +PF_registercvar, // #93 void(string cvarname, string defaultvalue) registercvar (DP_QC_REGISTERCVAR) +PF_min, // #94 float(float a, floats) min (DP_QC_MINMAXBOUND) -PF_Fixme, -PF_Fixme, -PF_Fixme, -PF_Fixme, -PF_Fixme, +PF_max, // #95 float(float a, floats) max (DP_QC_MINMAXBOUND) +PF_bound, // #96 float(float minimum, float val, float maximum) bound (DP_QC_MINMAXBOUND) +PF_pow, // #97 float(float value) pow (DP_QC_SINCOSSQRTPOW) +PF_Fixme, // #98 +PF_checkextension, // #99 float(string extname) checkextension (EXT_CSQC) //100 -PF_checkextension, +PF_Fixme, PF_Fixme, PF_Fixme, PF_Fixme, @@ -1412,17 +1767,17 @@ PF_Fixme, PF_Fixme, PF_Fixme, //110 -PF_fopen, -PF_fclose, -PF_fgets, -PF_fputs, -PF_strlen, +PF_fopen, // #110 float(string strname, float accessmode) fopen (FRIK_FILE) +PF_fclose, // #111 void(float fnum) fclose (FRIK_FILE) +PF_fgets, // #112 string(float fnum) fgets (FRIK_FILE) +PF_fputs, // #113 void(float fnum, string str) fputs (FRIK_FILE) +PF_strlen, // #114 float(string str) strlen (FRIK_FILE) -PF_strcat, -PF_substring, -PF_stov, -PF_dupstring, -PF_forgetstring, +PF_strcat, // #115 string(string str1, string str2, ...) strcat (FRIK_FILE) +PF_substring, // #116 string(string str, float start, float length) substring (FRIK_FILE) +PF_stov, // #117 vector(string str) stov (FRIK_FILE) +PF_dupstring, // #118 string(string str) dupstring (FRIK_FILE) +PF_forgetstring, // #119 void(string str) freestring (FRIK_FILE) //120 @@ -1439,58 +1794,69 @@ PF_Fixme, PF_Fixme, //130 -PF_R_ClearScene, -PF_R_AddEntityMask, -PF_R_AddEntity, -PF_R_SetViewFlag, -PF_R_RenderScene, +PF_R_ClearScene, // #??? +PF_R_AddEntityMask, // #??? +PF_R_AddEntity, // #??? +PF_R_SetViewFlag, // #??? +PF_R_RenderScene, // #??? -PF_R_AddDynamicLight, +PF_R_AddDynamicLight, // #??? PF_Fixme, PF_Fixme, PF_Fixme, PF_Fixme, //140 -PF_CL_is_cached_pic,//0 -PF_CL_precache_pic,//1 -PF_CL_free_pic,//2 -PF_CL_drawcharacter,//3 -PF_CL_drawstring,//4 -PF_CL_drawpic,//5 -PF_CL_drawfill,//6 -PF_CL_drawsetcliparea,//7 -PF_CL_drawresetcliparea,//8 -PF_CL_drawgetimagesize,//9 +PF_CL_is_cached_pic, // #??? +PF_CL_precache_pic, // #??? +PF_CL_free_pic, // #??? +PF_CL_drawcharacter, // #??? +PF_CL_drawstring, // #??? +PF_CL_drawpic, // #??? +PF_CL_drawfill, // #??? +PF_CL_drawsetcliparea, // #??? +PF_CL_drawresetcliparea, // #??? +PF_CL_drawgetimagesize, // #??? //150 -PF_cs_getstatf, -PF_cs_getstati, -PF_cs_getstats, -PF_CSQC_SetModelIndex, -PF_CSQC_ModelnameForIndex, +PF_cs_getstatf, // #??? +PF_cs_getstati, // #??? +PF_cs_getstats, // #??? +PF_cs_SetModelIndex, // #??? +PF_cs_ModelnameForIndex, // #??? -PF_cs_setsensativityscaler, -PF_csqc_centerprint, -PF_print, -PF_cs_pointparticles, -PF_cs_particlesloaded, +PF_cs_setsensativityscaler, // #??? +PF_cl_cprint, // #??? centerprint +PF_print, // #??? console print +PF_cs_pointparticles, // #??? +PF_cs_particlesloaded, // #??? //160 -PF_cs_getinputstate, -PF_cs_runplayerphysics, -PF_cs_getplayerkey, -PF_cs_setwantskeys, -PF_cs_getmousepos, +PF_cs_getinputstate, // #??? +PF_cs_runplayerphysics, // #??? +PF_cs_getplayerkey, // #??? +PF_cs_setwantskeys, // #??? +PF_cs_getmousepos, // #??? -PF_Fixme, -PF_Fixme, +PF_cl_playingdemo, // #??? float() isdemo +PF_cl_runningserver, // #??? float() isserver PF_Fixme, PF_Fixme, PF_Fixme, //170 -PF_FixTen, +//note that 'ReadEntity' is pretty hard to implement reliably. Modders should use a combination of ReadShort, and findfloat, and remember that it might not be known clientside (pvs culled or other reason) +PF_ReadByte, // #??? +PF_ReadChar, // #??? +PF_ReadShort, // #??? +PF_ReadLong, // #??? +PF_ReadCoord, // #??? + +PF_ReadAngle, // #??? +PF_ReadString, // #??? +PF_Fixme, +PF_Fixme, +PF_Fixme, //180 PF_FixTen, @@ -1505,17 +1871,17 @@ PF_FixTen, PF_FixTen, //220 -PF_Fixme, -PF_strstrofs, -PF_str2chr, -PF_chr2str, -PF_strconv, +PF_Fixme, // #220 +PF_strstrofs, // #221 float(string s1, string sub) strstrofs (FTE_STRINGS) +PF_str2chr, // #222 float(string str, float index) str2chr (FTE_STRINGS) +PF_chr2str, // #223 string(float chr, ...) chr2str (FTE_STRINGS) +PF_strconv, // #224 string(float ccase, float redalpha, float redchars, string str, ...) strconv (FTE_STRINGS) -PF_infoadd, -PF_infoget, -PF_strncmp, -PF_strcasecmp, -PF_strncasecmp, +PF_infoadd, // #225 string(string old, string key, string value) infoadd +PF_infoget, // #226 string(string info, string key) infoget +PF_strncmp, // #227 float(string s1, string s2, float len) strncmp (FTE_STRINGS) +PF_strcasecmp, // #228 float(string s1, string s2) strcasecmp (FTE_STRINGS) +PF_strncasecmp, // #229 float(string s1, string s2, float len) strncasecmp (FTE_STRINGS) //230 PF_FixTen, @@ -1569,29 +1935,80 @@ PF_FixTen, PF_FixTen, //400 +PF_cs_copyentity, // #400 void(entity from, entity to) copyentity (DP_QC_COPYENTITY) +PF_Fixme, // #401 void(entity cl, float colours) setcolors (DP_SV_SETCOLOR) (don't implement) +PF_findchain, // #402 entity(string field, string match) findchain (DP_QC_FINDCHAIN) +PF_findchainfloat, // #403 entity(float fld, float match) findchainfloat (DP_QC_FINDCHAINFLOAT) +PF_cl_effect, // #404 void(vector org, string modelname, float startframe, float endframe, float framerate) effect (DP_SV_EFFECT) + +PF_cl_te_blood, // #405 te_blood (DP_TE_BLOOD) +PF_cl_te_bloodshower, // #406 void(vector mincorner, vector maxcorner, float explosionspeed, float howmany) te_bloodshower (DP_TE_BLOODSHOWER) +PF_Fixme, // #407 +PF_cl_te_particlecube, // #408 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color, float gravityflag, float randomveljitter) te_particlecube (DP_TE_PARTICLECUBE) +PF_Fixme, // #409 + +PF_Fixme, // #410 +PF_cl_te_spark, // #411 void(vector org, vector vel, float howmany) te_spark (DP_TE_SPARK) +PF_Fixme, // #412 +PF_Fixme, // #413 +PF_Fixme, // #414 + +PF_Fixme, // #415 +PF_cl_te_smallflash, // #416 void(vector org) te_smallflash (DP_TE_SMALLFLASH) +PF_cl_te_customflash, // #417 void(vector org, float radius, float lifetime, vector color) te_customflash (DP_TE_CUSTOMFLASH) +PF_cl_te_gunshot, // #418 te_gunshot (DP_TE_STANDARDEFFECTBUILTINS) +PF_cl_te_spike, // #419 te_spike (DP_TE_STANDARDEFFECTBUILTINS) + +PF_cl_te_superspike, // #420 te_superspike (DP_TE_STANDARDEFFECTBUILTINS) +PF_cl_te_explosion, // #421 te_explosion (DP_TE_STANDARDEFFECTBUILTINS) +PF_cl_te_tarexplosion, // #422 te_tarexplosion (DP_TE_STANDARDEFFECTBUILTINS) +PF_cl_te_wizspike, // #423 te_wizspike (DP_TE_STANDARDEFFECTBUILTINS) +PF_cl_te_knightspike, // #424 te_knightspike (DP_TE_STANDARDEFFECTBUILTINS) + +PF_cl_te_lavasplash, // #425 te_lavasplash (DP_TE_STANDARDEFFECTBUILTINS) +PF_cl_te_teleport, // #426 te_teleport (DP_TE_STANDARDEFFECTBUILTINS) +PF_cl_te_explosion2, // #427 te_explosion2 (DP_TE_STANDARDEFFECTBUILTINS) +PF_cl_te_lightning1, // #428 te_lightning1 (DP_TE_STANDARDEFFECTBUILTINS) +PF_cl_te_lightning2, // #429 te_lightning2 (DP_TE_STANDARDEFFECTBUILTINS) + +PF_cl_te_lightning3, // #430 te_lightning3 (DP_TE_STANDARDEFFECTBUILTINS) +PF_cl_te_beam, // #431 te_beam (DP_TE_STANDARDEFFECTBUILTINS) +PF_cs_vectorvectors, // #432 void(vector dir) vectorvectors (DP_QC_VECTORVECTORS) +PF_cl_te_plasmaburn, // #433 void(vector org) te_plasmaburn (DP_TE_PLASMABURN) +PF_Fixme, // #434 + +PF_Fixme, // #435 +PF_Fixme, // #436 +PF_Fixme, // #437 +PF_Fixme, // #438 +PF_Fixme, // #439 + +PF_Fixme, // #440 void(entity e, string s) clientcommand (KRIMZON_SV_PARSECLIENTCOMMAND) (don't implement) +PF_Tokenize, // #441 float(string s) tokenize (KRIMZON_SV_PARSECLIENTCOMMAND) +PF_ArgV, // #442 string(float n) argv (KRIMZON_SV_PARSECLIENTCOMMAND) +PS_cs_setattachment, // #443 void(entity e, entity tagentity, string tagname) setattachment (DP_GFX_QUAKE3MODELTAGS) +PF_search_begin, // #444 float search_begin(string pattern, float caseinsensitive, float quiet) (DP_QC_FS_SEARCH) + +PF_search_end, // #445 void search_end(float handle) (DP_QC_FS_SEARCH) +PF_search_getsize, // #446 float search_getsize(float handle) (DP_QC_FS_SEARCH) +PF_search_getfilename, // #447 string search_getfilename(float handle, float num) (DP_QC_FS_SEARCH) +PF_cvar_string, // #448 string(float n) cvar_string (DP_QC_CVAR_STRING) +PF_FindFlags, // #449 entity(entity start, .entity fld, float match) findflags (DP_QC_FINDFLAGS) + +PF_findchainflags, // #450 entity(.float fld, float match) findchainflags (DP_QC_FINDCHAINFLAGS) +PF_Fixme, // #451 +PF_Fixme, // #452 +PF_Fixme, // #453 void(entity player) dropclient (DP_QC_BOTCLIENT) (don't implement) +PF_Fixme, // #454 entity() spawnclient (DP_QC_BOTCLIENT) (don't implement) + +PF_Fixme, // #455 float(entity client) clienttype (DP_QC_BOTCLIENT) (don't implement) +PF_Fixme, // #456 +PF_Fixme, // #457 +PF_Fixme, // #458 +PF_Fixme, // #459 + +//460 PF_FixTen, - -//410 -PF_FixTen, - -//420 -PF_FixTen, - -//430 -PF_FixTen, - -//440 -PF_Fixme, -PF_Tokenize, -PF_ArgV, -PF_Fixme, -PF_Fixme, - -PF_Fixme, -PF_Fixme, -PF_Fixme, -PF_Fixme, -PF_Fixme, }; static int csqc_numbuiltins = sizeof(csqc_builtins)/sizeof(csqc_builtins[0]); @@ -1636,6 +2053,7 @@ void VARGS CSQC_Abort (char *format, ...) //an error occured. void CSQC_Shutdown(void) { + search_close_progs(csqcprogs, false); if (csqcprogs) { CloseProgs(csqcprogs); diff --git a/engine/client/pr_menu.c b/engine/client/pr_menu.c index 04c94b1dc..7b3ef23d3 100644 --- a/engine/client/pr_menu.c +++ b/engine/client/pr_menu.c @@ -398,13 +398,13 @@ void PF_CL_drawpic (progfuncs_t *prinst, struct globalvars_s *pr_globals) #ifdef RGLQUAKE if (qrenderer == QR_OPENGL) { - if (flag == 1) + if (flag == 1) //add qglBlendFunc(GL_SRC_ALPHA, GL_ONE); - else if(flag == 2) + else if(flag == 2) //modulate qglBlendFunc(GL_DST_COLOR, GL_ZERO); - else if(flag == 3) + else if(flag == 3) //modulate*2 qglBlendFunc(GL_DST_COLOR,GL_SRC_COLOR); - else + else //blend qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } #endif diff --git a/engine/client/r_part.c b/engine/client/r_part.c index 0112071be..e47959bce 100644 --- a/engine/client/r_part.c +++ b/engine/client/r_part.c @@ -261,7 +261,8 @@ static part_type_t *P_GetParticleType(char *name) int P_AllocateParticleType(char *name) //guarentees that the particle type exists, returning it's index. { - return P_GetParticleType(name) - part_type; + part_type_t *pt = P_GetParticleType(name); + return pt - part_type; } int P_ParticleTypeForName(char *name) @@ -289,14 +290,16 @@ int P_FindParticleType(char *name) //checks if particle description 'name' exist return -1; } -qboolean P_DescriptionIsLoaded(char *name) +int P_DescriptionIsLoaded(char *name) { int i = P_FindParticleType(name); part_type_t *ptype; if (i < 0) return false; ptype = &part_type[i]; - return ptype->loaded; + if (!ptype->loaded) + return false; + return i+1; } static void P_SetModified(void) //called when the particle system changes (from console). @@ -322,7 +325,7 @@ static int CheckAssosiation(char *name, int from) { if (to == from) { - Con_Printf("Assosiation would cause infinate loop\n"); + Con_Printf("Assosiation of %s would cause infinate loop\n", name); return -1; } to = part_type[to].assoc; @@ -470,7 +473,11 @@ void P_ParticleEffect_f(void) } else if (!strcmp(var, "scale")) + { ptype->scale = atof(value); + if (Cmd_Argc()>2) + ptype->randscale = atof(Cmd_Argv(2)) - ptype->scale; + } else if (!strcmp(var, "scalerand")) ptype->randscale = atof(value); @@ -2410,7 +2417,7 @@ int P_ParticleTrail (vec3_t startpos, vec3_t end, int type, trailstate_t **tsk) float randvel = ptype->randomvel; float step; float stop; - float tdegree = 1/50; /* MSVC whine */ + float tdegree = 2*M_PI/256; /* MSVC whine */ if (!ptype->loaded) return 1; diff --git a/engine/client/r_partset.c b/engine/client/r_partset.c index 1603a6543..c1a8beb2e 100644 --- a/engine/client/r_partset.c +++ b/engine/client/r_partset.c @@ -267,7 +267,7 @@ char *particle_set_spikeset = "r_part randomspark\n" "{\n" " count 1\n" -" texture \"\"\n" +" texture \"ball\"\n" " red 255\n" " green 128\n" " blue 76\n" @@ -278,12 +278,13 @@ char *particle_set_spikeset = " randomvel 128\n" " veladd 0\n" " cliptype randomspark\n" +" type texturedspark\n" "}\n" "r_part insaneshrapnal\n" "{\n" " count 24\n" -" texture \"\"\n" +" texture \"ball\"\n" " red 255\n" " green 128\n" " blue 76\n" @@ -294,6 +295,7 @@ char *particle_set_spikeset = " veladd 1\n" " cliptype randomspark\n" " clipcount 5\n" +" type texturedspark\n" "}\n" "r_part ember\n" diff --git a/engine/client/render.h b/engine/client/render.h index a8d35f148..49fb2318d 100644 --- a/engine/client/render.h +++ b/engine/client/render.h @@ -56,7 +56,8 @@ typedef struct entity_s struct player_info_s *scoreboard; // identify player - float syncbase; + float frame1time; + float frame2time; struct efrag_s *efrag; // linked list of efrags (FIXME) int visframe; // last frame this entity was diff --git a/engine/common/cmd.c b/engine/common/cmd.c index 1fcb74b08..74b126e2b 100644 --- a/engine/common/cmd.c +++ b/engine/common/cmd.c @@ -1679,7 +1679,7 @@ void Cmd_ExecuteString (char *text, int level) Cbuf_InsertText (a->value, level); - if (Cmd_FromGamecode()) + if (level>=RESTRICT_SERVER) return; //don't do the cmd_argc/cmd_argv stuff. When it's from the server, we had a tendancy to lock aliases, so don't set them anymore. Cbuf_InsertText (va("set cmd_argc \"%i\"\n", cmd_argc), level); diff --git a/engine/common/common.c b/engine/common/common.c index 6ed07bbcf..1c68a7a6a 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -460,6 +460,9 @@ float Q_atof (char *str) int sign; int c; int decimal, total; + + while(*str == ' ') + str++; if (*str == '-') { @@ -4229,7 +4232,7 @@ gamemode_info_t gamemode_info[] = { {"Darkplaces-Quake", "darkplaces", "-quake", "id1/pak0.pak", "id1", "qw", "fte"}, {"Darkplaces-Hipnotic", "hipnotic", "-hipnotic", NULL/*"hipnotic/pak0.pak"*/,"id1", "qw", "hipnotic", "fte"}, {"Darkplaces-Rogue", "rogue", "-rogue", NULL/*"rogue/pak0.pak", "id1"*/, "qw", "rogue", "fte"}, - {"Nexuiz", "nexuiz", "-nexuiz", "data/data.pk3", "id1", "qw", "data", "fte"}, + {"Nexuiz", "nexuiz", "-nexuiz", "data/data20050531.pk3", "id1", "qw", "data", "fte"}, //supported commercial mods (some are currently only partially supported) {"FTE-Hexen2", "hexen", "-hexen2", "data1/pak0.pak", "data1", "fte"}, @@ -4274,7 +4277,7 @@ void COM_InitFilesystem (void) for (i = 0; gamemode_info[i].gamename; i++) { if (!gamemode_info[i].auniquefile) - return; + continue; //no more f = fopen(va("%s/%s", com_quakedir, gamemode_info[i].auniquefile), "rb"); if (f) { diff --git a/engine/common/cvar.c b/engine/common/cvar.c index 2fef60bf2..009824053 100644 --- a/engine/common/cvar.c +++ b/engine/common/cvar.c @@ -563,6 +563,7 @@ qboolean Cvar_Command (int level) Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string); if (v->latched_string) Con_Printf ("Latched as \"%s\"\n", v->latched_string); + Con_Printf("Default: \"%s\"\n", v->defaultstr); return true; } diff --git a/engine/common/gl_q2bsp.c b/engine/common/gl_q2bsp.c index 721a9829f..bbb106131 100644 --- a/engine/common/gl_q2bsp.c +++ b/engine/common/gl_q2bsp.c @@ -3261,8 +3261,8 @@ void CMQ3_CalcPHS (void) continue; // OR this pvs row into the phs index = (j<<3) + k; - if (index >= numclusters) - Host_Error ("CM_CalcPHS: Bad bit in PVS"); // pad bits should be 0 +// if (index >= numclusters) +// Host_Error ("CM_CalcPHS: Bad bit in PVS"); // pad bits should be 0 src = (unsigned *)((qbyte*)map_q3pvs->data) + index*rowwords; for (l=0 ; lnumsides) return; @@ -4511,6 +4512,12 @@ void CM_TestBoxInBrush (vec3_t mins, vec3_t maxs, vec3_t p1, d1 = DotProduct (p1, plane->normal) - dist; + if (side->surface->c.flags & 4) + { + issky = true; + d1 -= DIST_EPSILON*2; + } + // if completely in front of face, no intersection if (d1 > 0) return; @@ -4520,7 +4527,10 @@ void CM_TestBoxInBrush (vec3_t mins, vec3_t maxs, vec3_t p1, // inside this brush trace->startsolid = trace->allsolid = true; trace->fraction = 0; - trace->contents = brush->contents; + if (issky) + trace->contents |= FTECONTENTS_SKY; + else + trace->contents |= brush->contents; } void CM_TestBoxInPatch (vec3_t mins, vec3_t maxs, vec3_t p1, diff --git a/engine/common/protocol.h b/engine/common/protocol.h index 564a1118b..38ef8e5f6 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -237,8 +237,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define svc_movepic 71 #define svc_updatepic 72 -#define svc_setattachment 73 - #define svcqw_effect 74 // [vector] org [byte] modelindex [byte] startframe [byte] framecount [byte] framerate #define svcqw_effect2 75 // [vector] org [short] modelindex [short] startframe [byte] framecount [byte] framerate @@ -334,19 +332,15 @@ enum clcq2_ops_e // bits 11..13 are player move type bits #ifdef PEXT_SCALE -#define PF_SCALE_NOZ (1<<12) #define PF_SCALE_Z (1<<16) #endif #ifdef PEXT_TRANS -#define PF_TRANS_NOZ (1<<13) #define PF_TRANS_Z (1<<17) #endif #ifdef PEXT_FATNESS -#define PF_FATNESS_NOZ (1<<14) #define PF_FATNESS_Z (1<<18) #endif #ifdef PEXT_HULLSIZE -#define PF_HULLSIZE_NOZ (1<<15) #define PF_HULLSIZE_Z (1<<14) #endif @@ -448,6 +442,9 @@ enum clcq2_ops_e #endif #define U_DPFLAGS (1<<11) +#define U_TAGINFO (1<<12) + +#define U_FARMORE (1<<15) #endif @@ -614,8 +611,10 @@ enum { #define DPTE_CUSTOMFLASH 73 #define DPTE_FLAMEJET 74 #define DPTE_PLASMABURN 75 - +#define DPTE_TEI_G3 76 #define DPTE_SMOKE 77 +#define DPTE_TEI_BIGEXPLOSION 78 +#define DPTE_TEI_PLASMAHIT 79 #define TE_SEEF_BRIGHTFIELD 200 #define TE_SEEF_DARKLIGHT 201 @@ -661,42 +660,38 @@ enum { typedef struct entity_state_s { - int number; // edict index + unsigned short number; // edict index + unsigned short modelindex; int bitmask; // for dp ents, so lost state can be repeated in replacement packets. int flags; // nolerp, etc vec3_t origin; vec3_t old_origin; //q2 vec3_t angles; - unsigned short modelindex; unsigned short modelindex2; //q2 - unsigned short modelindex3; //q2 - unsigned short modelindex4; //q2 + qbyte modelindex3; //q2 + qbyte modelindex4; //q2 unsigned short frame; unsigned short colormap; unsigned short skinnum; int effects; int renderfx; //q2 - int sound; //q2 - int event; //q2 + qbyte sound; //q2 + qbyte event; //q2 + qbyte glowsize; + qbyte glowcolour; -#ifdef PEXT_SCALE - float scale; -#endif -#ifdef PEXT_TRANS - float trans; -#endif -#ifdef PEXT_FATNESS - float fatness; -#endif + qbyte scale; + qbyte trans; + char fatness; qbyte hexen2flags; qbyte abslight; qbyte dpflags; qbyte solid; - qbyte glowsize; - qbyte glowcolour; + unsigned short tagentity; + unsigned short tagindex; } entity_state_t; diff --git a/engine/gl/gl_alias.c b/engine/gl/gl_alias.c index ac3c31cd7..9e487b9b1 100644 --- a/engine/gl/gl_alias.c +++ b/engine/gl/gl_alias.c @@ -422,7 +422,7 @@ static void R_GAliasAddDlights(mesh_t *mesh, vec3_t org, vec3_t angles) } } -static qboolean R_GAliasBuildMesh(mesh_t *mesh, galiasinfo_t *inf, int frame1, int frame2, float lerp, float alpha) +static qboolean R_GAliasBuildMesh(mesh_t *mesh, galiasinfo_t *inf, int frame1, int frame2, float lerp, float alpha, float fg1time, float fg2time) { galiasgroup_t *g1, *g2; @@ -509,7 +509,7 @@ static qboolean R_GAliasBuildMesh(mesh_t *mesh, galiasinfo_t *inf, int frame1, i float *pose[4]; float mlerp; //minor lerp, poses within a group. - mlerp = (cl.time-cl.lerpents[currententity->keynum].lerptime)*g1->rate; + mlerp = (fg1time)*g1->rate; frame1=mlerp; frame2=frame1+1; mlerp-=frame1; @@ -523,19 +523,22 @@ static qboolean R_GAliasBuildMesh(mesh_t *mesh, galiasinfo_t *inf, int frame1, i if (plerp[l]>0) pose[l++] = (float *)((char *)g1 + g1->poseofs + sizeof(float)*inf->numbones*12*frame2); - mlerp = (cl.time-cl.lerpents[currententity->keynum].lerptime)*g2->rate; - frame1=mlerp; - frame2=frame1+1; - mlerp-=frame1; - frame1=frame1%g2->numposes; - frame2=frame2%g2->numposes; + if (lerp) + { + mlerp = (fg2time)*g2->rate; + frame1=mlerp; + frame2=frame1+1; + mlerp-=frame1; + frame1=frame1%g2->numposes; + frame2=frame2%g2->numposes; - plerp[l] = (1-mlerp)*(lerp); - if (plerp[l]>0) - pose[l++] = (float *)((char *)g2 + g2->poseofs + sizeof(float)*inf->numbones*12*frame1); - plerp[l] = (mlerp)*(lerp); - if (plerp[l]>0) - pose[l++] = (float *)((char *)g2 + g2->poseofs + sizeof(float)*inf->numbones*12*frame2); + plerp[l] = (1-mlerp)*(lerp); + if (plerp[l]>0) + pose[l++] = (float *)((char *)g2 + g2->poseofs + sizeof(float)*inf->numbones*12*frame1); + plerp[l] = (mlerp)*(lerp); + if (plerp[l]>0) + pose[l++] = (float *)((char *)g2 + g2->poseofs + sizeof(float)*inf->numbones*12*frame2); + } /* pose[0] = (float *)((char *)g1 + g1->poseofs); plerp[0] = 1; @@ -551,7 +554,7 @@ static qboolean R_GAliasBuildMesh(mesh_t *mesh, galiasinfo_t *inf, int frame1, i if (g1 == g2) //lerping within group is only done if not changing group { - lerp = cl.time*g1->rate; + lerp = fg1time*g1->rate; frame1=lerp; frame2=frame1+1; lerp-=frame1; @@ -1480,7 +1483,7 @@ void R_DrawGAliasModel (entity_t *e) memset(&mesh, 0, sizeof(mesh)); for(; inf; ((inf->nextsurf)?(inf = (galiasinfo_t*)((char *)inf + inf->nextsurf)):(inf=NULL))) { - if (R_GAliasBuildMesh(&mesh, inf, e->frame, e->oldframe, e->lerpfrac, e->alpha) && r_vertexdlights.value) + if (R_GAliasBuildMesh(&mesh, inf, e->frame, e->oldframe, e->lerpfrac, e->alpha, e->frame1time, e->frame2time) && r_vertexdlights.value) if (mesh.colors_array) R_GAliasAddDlights(&mesh, e->origin, e->angles); @@ -1799,7 +1802,7 @@ void R_DrawGAliasShadowVolume(entity_t *e, vec3_t lightpos, float radius) { if (inf->ofs_trineighbours) { - R_GAliasBuildMesh(&mesh, inf, e->frame, e->oldframe, e->lerpfrac, e->alpha); + R_GAliasBuildMesh(&mesh, inf, e->frame, e->oldframe, e->lerpfrac, e->alpha, e->frame1time, e->frame2time); R_CalcFacing(&mesh, lightorg); R_ProjectShadowVolume(&mesh, lightorg); R_DrawShadowVolume(&mesh); @@ -2863,6 +2866,7 @@ qboolean GLMod_GetTag(model_t *model, int tagnum, int frame1, int frame2, float g1 = (galiasgroup_t*)((char *)inf + inf->groupofs + sizeof(galiasgroup_t)*frame1); g2 = (galiasgroup_t*)((char *)inf + inf->groupofs + sizeof(galiasgroup_t)*frame2); + f1time *= g1->rate; frame1 = (int)f1time%g1->numposes; frame2 = ((int)f1time+1)%g1->numposes; f1time = f1time - (int)f1time; @@ -2877,6 +2881,7 @@ qboolean GLMod_GetTag(model_t *model, int tagnum, int frame1, int frame2, float } if (f2ness) { + f2time *= g2->rate; frame1 = (int)f2time%g2->numposes; frame2 = ((int)f2time+1)%g2->numposes; f2time = f2time - (int)f2time; diff --git a/engine/gl/gl_backend.c b/engine/gl/gl_backend.c index 2a485017e..96617329f 100644 --- a/engine/gl/gl_backend.c +++ b/engine/gl/gl_backend.c @@ -881,9 +881,9 @@ void R_DeformVertices ( meshbuffer_t *mb ) VectorNormalizeFast ( m0[2] ); VectorVectors ( m0[2], m0[1], m0[0] ); - VectorCopy ( (&r_world_matrix[0]), m1[0] ); - VectorCopy ( (&r_world_matrix[4]), m1[1] ); - VectorCopy ( (&r_world_matrix[8]), m1[2] ); + VectorCopy ( (&r_view_matrix[0]), m1[0] ); + VectorCopy ( (&r_view_matrix[4]), m1[1] ); + VectorCopy ( (&r_view_matrix[8]), m1[2] ); Matrix3_Multiply ( m1, m0, result ); diff --git a/engine/gl/gl_ppl.c b/engine/gl/gl_ppl.c index a670044f9..30421a97a 100644 --- a/engine/gl/gl_ppl.c +++ b/engine/gl/gl_ppl.c @@ -1545,7 +1545,7 @@ void PPL_BaseTextures(model_t *model) } } } - if (!r_inmirror && mirrortexturenum>=0 && model == cl.worldmodel && r_mirroralpha.value != 1.0) + if (mirrortexturenum>=0 && model == cl.worldmodel && r_mirroralpha.value != 1.0) { t = model->textures[mirrortexturenum]; if (t) @@ -1554,7 +1554,8 @@ void PPL_BaseTextures(model_t *model) if (s) { t->texturechain = NULL; - R_MirrorChain (s); + if (!r_inmirror) + R_MirrorChain (s); } } } @@ -1749,21 +1750,10 @@ void PPL_BaseEntTextures(void) { if (currententity->flags & Q2RF_EXTERNALMODEL) continue; - - j = currententity->keynum; - while(j) - { - - if (j == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1))) - break; - - j = cl.lerpents[j].tagent; - } - if (j) - continue; - - if (cl.viewentity[r_refdef.currentplayernum] && currententity->keynum == cl.viewentity[r_refdef.currentplayernum]) + if (currententity->keynum == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1))) continue; +// if (cl.viewentity[r_refdef.currentplayernum] && currententity->keynum == cl.viewentity[r_refdef.currentplayernum]) +// continue; if (!Cam_DrawPlayer(0, currententity->keynum-1)) continue; } @@ -2481,20 +2471,10 @@ void PPL_DrawEntLighting(dlight_t *light, vec3_t colour) } else { - j = currententity->keynum; - while(j) - { - - if (j == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1))) - break; - - j = cl.lerpents[j].tagent; - } - if (j) - continue; - - if (cl.viewentity[r_refdef.currentplayernum] && currententity->keynum == cl.viewentity[r_refdef.currentplayernum]) + if (currententity->keynum == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1))) continue; +// if (cl.viewentity[r_refdef.currentplayernum] && currententity->keynum == cl.viewentity[r_refdef.currentplayernum]) +// continue; if (!Cam_DrawPlayer(0, currententity->keynum-1)) continue; } diff --git a/engine/gl/gl_rmain.c b/engine/gl/gl_rmain.c index f3979e67f..2d92e42b9 100644 --- a/engine/gl/gl_rmain.c +++ b/engine/gl/gl_rmain.c @@ -78,8 +78,8 @@ vec3_t vpn; vec3_t vright; vec3_t r_origin; -float r_world_matrix[16]; -float r_base_world_matrix[16]; +float r_projection_matrix[16]; +float r_view_matrix[16]; // // screen size info @@ -416,7 +416,7 @@ mspriteframe_t *R_GetSpriteFrame (entity_t *currententity) if ((frame >= psprite->numframes) || (frame < 0)) { - Con_Printf ("R_DrawSprite: no such frame %d (%s)\n", frame, currententity->model->name); + Con_DPrintf ("R_DrawSprite: no such frame %d (%s)\n", frame, currententity->model->name); frame = 0; } @@ -436,7 +436,7 @@ mspriteframe_t *R_GetSpriteFrame (entity_t *currententity) numframes = pspritegroup->numframes; fullinterval = pintervals[numframes-1]; - time = cl.time + currententity->syncbase; + time = currententity->frame1time; // when loading in Mod_LoadSpriteGroup, we guaranteed all interval values // are positive, so we don't have to worry about division by 0 @@ -758,20 +758,10 @@ void GLR_DrawEntitiesOnList (void) } else { - j = currententity->keynum; - while(j) - { - - if (j == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1))) - break; - - j = cl.lerpents[j].tagent; - } - if (j) - continue; - - if (cl.viewentity[r_refdef.currentplayernum] && currententity->keynum == cl.viewentity[r_refdef.currentplayernum]) + if (currententity->keynum == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1))) continue; +// if (cl.viewentity[r_refdef.currentplayernum] && currententity->keynum == cl.viewentity[r_refdef.currentplayernum]) +// continue; if (!Cam_DrawPlayer(0, currententity->keynum-1)) continue; } @@ -842,20 +832,10 @@ void GLR_DrawEntitiesOnList (void) } else { - j = currententity->keynum; - while(j) - { - - if (j == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1))) - break; - - j = cl.lerpents[j].tagent; - } - if (j) - continue; - - if (cl.viewentity[r_refdef.currentplayernum] && currententity->keynum == cl.viewentity[r_refdef.currentplayernum]) + if (currententity->keynum == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1))) continue; +// if (cl.viewentity[r_refdef.currentplayernum] && currententity->keynum == cl.viewentity[r_refdef.currentplayernum]) +// continue; if (!Cam_DrawPlayer(0, currententity->keynum-1)) continue; } @@ -1125,8 +1105,46 @@ int SignbitsForPlane (mplane_t *out) } return bits; } +#if 1 +void R_SetFrustum (void) +{ + float scale; + int i; + float mvp[16]; + if ((int)r_novis.value & 4) + return; + Matrix4_Multiply(r_projection_matrix, r_view_matrix, mvp); + + for (i = 0; i < 4; i++) + { + if (i & 1) + { + frustum[i].normal[0] = mvp[3] + mvp[0+i/2]; + frustum[i].normal[1] = mvp[7] + mvp[4+i/2]; + frustum[i].normal[2] = mvp[11] + mvp[8+i/2]; + frustum[i].dist = mvp[15] + mvp[12+i/2]; + } + else + { + frustum[i].normal[0] = mvp[3] - mvp[0+i/2]; + frustum[i].normal[1] = mvp[7] - mvp[4+i/2]; + frustum[i].normal[2] = mvp[11] - mvp[8+i/2]; + frustum[i].dist = mvp[15] - mvp[12+i/2]; + } + + scale = 1/sqrt(DotProduct(frustum[i].normal, frustum[i].normal)); + frustum[i].normal[0] *= scale; + frustum[i].normal[1] *= scale; + frustum[i].normal[2] *= scale; + frustum[i].dist *= -scale; + + frustum[i].type = PLANE_ANYZ; + frustum[i].signbits = SignbitsForPlane (&frustum[i]); + } +} +#else void R_SetFrustum (void) { int i; @@ -1166,7 +1184,7 @@ void R_SetFrustum (void) frustum[i].signbits = SignbitsForPlane (&frustum[i]); } } - +#endif /* =============== R_SetupFrame @@ -1179,15 +1197,18 @@ void GLR_SetupFrame (void) if (!cls.allow_watervis) r_wateralphaval = 1; - GLR_AnimateLight (); + if (!mirror) + { + GLR_AnimateLight (); - r_framecount++; + // build the transformation matrix for the given view angles -// build the transformation matrix for the given view angles + AngleVectors (r_refdef.viewangles, vpn, vright, vup); + + r_framecount++; + } VectorCopy (r_refdef.vieworg, r_origin); - AngleVectors (r_refdef.viewangles, vpn, vright, vup); - // current viewleaf if (r_refdef.flags & 1) { @@ -1284,10 +1305,6 @@ void GLR_SetupFrame (void) void MYgluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar ) { -#if 1 //for the sake of the d3d... -#else - GLfloat matrix[16]; -#endif GLdouble xmin, xmax, ymin, ymax; ymax = zNear * tan( fovy * M_PI / 360.0 ); @@ -1296,39 +1313,30 @@ void MYgluPerspective( GLdouble fovy, GLdouble aspect, xmin = ymin * aspect; xmax = ymax * aspect; -#if 1 //for the sake of the d3d... - qglFrustum( xmin, xmax, ymin, ymax, zNear, zFar ); -#else + r_projection_matrix[0] = (2*zNear) / (xmax - xmin); + r_projection_matrix[4] = 0; + r_projection_matrix[8] = (xmax + xmin) / (xmax - xmin); + r_projection_matrix[12] = 0; - matrix[0] = (2*zNear) / (xmax - xmin); - matrix[4] = 0; - matrix[8] = (xmax + xmin) / (xmax - xmin); - matrix[12] = 0; + r_projection_matrix[1] = 0; + r_projection_matrix[5] = (2*zNear) / (ymax - ymin); + r_projection_matrix[9] = (ymax + ymin) / (ymax - ymin); + r_projection_matrix[13] = 0; - matrix[1] = 0; - matrix[5] = (2*zNear) / (ymax - ymin); - matrix[9] = (ymax + ymin) / (ymax - ymin); - matrix[13] = 0; - - matrix[2] = 0; - matrix[6] = 0; - matrix[10] = - (zFar+zNear)/(zFar-zNear); - matrix[14] = - (2.0f*zFar*zNear)/(zFar-zNear); + r_projection_matrix[2] = 0; + r_projection_matrix[6] = 0; + r_projection_matrix[10] = - (zFar+zNear)/(zFar-zNear); + r_projection_matrix[14] = - (2.0f*zFar*zNear)/(zFar-zNear); - matrix[3] = 0; - matrix[7] = 0; - matrix[11] = -1; - matrix[15] = 0; - - qglMultMatrixf(matrix); -#endif + r_projection_matrix[3] = 0; + r_projection_matrix[7] = 0; + r_projection_matrix[11] = -1; + r_projection_matrix[15] = 0; } void GL_InfinatePerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear) { - GLfloat matrix[16]; - // nudge infinity in just slightly for lsb slop GLfloat nudge = 1;// - 1.0 / (1<<23); @@ -1340,27 +1348,25 @@ void GL_InfinatePerspective( GLdouble fovy, GLdouble aspect, xmin = ymin * aspect; xmax = ymax * aspect; - matrix[0] = (2*zNear) / (xmax - xmin); - matrix[4] = 0; - matrix[8] = (xmax + xmin) / (xmax - xmin); - matrix[12] = 0; + r_projection_matrix[0] = (2*zNear) / (xmax - xmin); + r_projection_matrix[4] = 0; + r_projection_matrix[8] = (xmax + xmin) / (xmax - xmin); + r_projection_matrix[12] = 0; - matrix[1] = 0; - matrix[5] = (2*zNear) / (ymax - ymin); - matrix[9] = (ymax + ymin) / (ymax - ymin); - matrix[13] = 0; + r_projection_matrix[1] = 0; + r_projection_matrix[5] = (2*zNear) / (ymax - ymin); + r_projection_matrix[9] = (ymax + ymin) / (ymax - ymin); + r_projection_matrix[13] = 0; - matrix[2] = 0; - matrix[6] = 0; - matrix[10] = -1 * nudge; - matrix[14] = -2*zNear * nudge; + r_projection_matrix[2] = 0; + r_projection_matrix[6] = 0; + r_projection_matrix[10] = -1 * nudge; + r_projection_matrix[14] = -2*zNear * nudge; - matrix[3] = 0; - matrix[7] = 0; - matrix[11] = -1; - matrix[15] = 0; - - qglMultMatrixf(matrix); + r_projection_matrix[3] = 0; + r_projection_matrix[7] = 0; + r_projection_matrix[11] = -1; + r_projection_matrix[15] = 0; } @@ -1404,10 +1410,9 @@ void R_SetupGL (void) qglViewport (glx + x, gly + y2, w, h); qglMatrixMode(GL_PROJECTION); - qglLoadIdentity (); screenaspect = (float)r_refdef.vrect.width/r_refdef.vrect.height; - if ((!r_shadows.value || !gl_canstencil) && gl_maxdist.value>0)//gl_nv_range_clamp) + if ((!r_shadows.value || !gl_canstencil) && gl_maxdist.value>256)//gl_nv_range_clamp) { // yfov = 2*atan((float)r_refdef.vrect.height/r_refdef.vrect.width)*180/M_PI; // yfov = (2.0 * tan (scr_fov.value/360*M_PI)) / screenaspect; @@ -1419,13 +1424,14 @@ void R_SetupGL (void) { GL_InfinatePerspective(r_refdef.fov_y, screenaspect, 4); } + qglLoadMatrixf(r_projection_matrix); if (mirror) { - if (mirror_plane->normal[2]) - qglScalef (1, -1, 1); - else - qglScalef (-1, 1, 1); +// if (mirror_plane->normal[2]) +// qglScalef (1, -1, 1); +// else +// qglScalef (-1, 1, 1); qglCullFace(GL_BACK); } else @@ -1444,8 +1450,8 @@ void R_SetupGL (void) qglMatrixMode(GL_MODELVIEW); - ML_ModelViewMatrixFromAxis(r_world_matrix, vpn, vright, vup, r_refdef.vieworg); - qglLoadMatrixf(r_world_matrix); + ML_ModelViewMatrixFromAxis(r_view_matrix, vpn, vright, vup, r_refdef.vieworg); + qglLoadMatrixf(r_view_matrix); // @@ -1505,15 +1511,14 @@ void R_RenderScene (void) if (!cl.worldmodel) r_refdef.flags |= Q2RDF_NOWORLDMODEL; - if (!mirror) GLR_SetupFrame (); - TRACE(("dbg: calling R_SetFrustrum\n")); - R_SetFrustum (); - TRACE(("dbg: calling R_SetupGL\n")); R_SetupGL (); + TRACE(("dbg: calling R_SetFrustrum\n")); + R_SetFrustum (); + if (!(r_refdef.flags & 1)) { #ifdef DOOMWADS @@ -1732,6 +1737,7 @@ void R_Mirror (void) mplane_t *mirror_plane; vec3_t oldangles, oldorg, oldvpn, oldvright, oldvup; //cache - for rear view mirror and stuff. + float base_view_matrix[16]; if (!mirror) { @@ -1746,92 +1752,181 @@ void R_Mirror (void) memcpy(oldvpn, vpn, sizeof(vec3_t)); memcpy(oldvright, vright, sizeof(vec3_t)); memcpy(oldvup, vup, sizeof(vec3_t)); - memcpy (r_base_world_matrix, r_world_matrix, sizeof(r_base_world_matrix)); + memcpy (base_view_matrix, r_view_matrix, sizeof(base_view_matrix)); + + s = r_mirror_chain; + while(s) //okay, so this is a hack + { + s->nextalphasurface = s->texturechain; + s = s->nextalphasurface; + } + cl.worldmodel->textures[mirrortexturenum]->texturechain = NULL; while(r_mirror_chain) { s = r_mirror_chain; - r_mirror_chain = r_mirror_chain->texturechain; + r_mirror_chain = r_mirror_chain->nextalphasurface; +#if 0 + s->nextalphasurface = NULL; + +#else //this loop figures out all surfaces with the same plane. //yes, this can mean that the list is reversed a few times, but we do have depth testing to solve that anyway. - for(prevs = s,prevr=NULL,rejects=NULL;r_mirror_chain;r_mirror_chain=r_mirror_chain->texturechain) + for(prevs = s,prevr=NULL,rejects=NULL;r_mirror_chain;r_mirror_chain=r_mirror_chain->nextalphasurface) { if (s->plane->dist != r_mirror_chain->plane->dist || s->plane->signbits != r_mirror_chain->plane->signbits || s->plane->normal[0] != r_mirror_chain->plane->normal[0] || s->plane->normal[1] != r_mirror_chain->plane->normal[1] || s->plane->normal[2] != r_mirror_chain->plane->normal[2]) { //reject if (prevr) - prevr->texturechain = r_mirror_chain; + prevr->nextalphasurface = r_mirror_chain; else rejects = r_mirror_chain; prevr = r_mirror_chain; } else { //matches - prevs->texturechain = r_mirror_chain; + prevs->nextalphasurface = r_mirror_chain; prevs = r_mirror_chain; } } - prevs->texturechain = NULL; + prevs->nextalphasurface = NULL; if (prevr) - prevr->texturechain = NULL; + prevr->nextalphasurface = NULL; r_mirror_chain = rejects; - +#endif mirror_plane = s->plane; //enable stencil writing qglClearStencil(0); qglClear(GL_STENCIL_BUFFER_BIT); qglDisable(GL_ALPHA_TEST); + qglDisable(GL_STENCIL_TEST); qglEnable(GL_STENCIL_TEST); qglStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); //replace where it passes qglStencilFunc( GL_ALWAYS, 1, ~0 ); //always pass (where z passes set to 1) - - qglColorMask( GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE ); + qglDisable(GL_TEXTURE_2D); + qglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); qglDepthMask( GL_FALSE ); + qglEnableClientState( GL_VERTEX_ARRAY ); - for (prevs = s; s; s=s->texturechain) //write the polys to the stencil buffer. + for (prevs = s; s; s=s->nextalphasurface) //write the polys to the stencil buffer. { qglVertexPointer(3, GL_FLOAT, 0, s->mesh->xyz_array); qglDrawElements(GL_TRIANGLES, s->mesh->numindexes, GL_UNSIGNED_INT, s->mesh->indexes); } - qglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); - qglDepthMask( GL_TRUE ); qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); qglStencilFunc( GL_EQUAL, 1, ~0 ); //pass if equal to 1 +//now clear the depth buffer where the stencil passed +//we achieve this by changing the projection matrix underneath. +//the stencil only shows where the final surface will appear, and only where not obscured +//we rewrite the depth with the blending pass after. + qglEnable(GL_DEPTH_TEST); //use only the stencil test + qglDepthRange(1, 1); + qglDepthFunc (GL_ALWAYS); + qglDepthMask( GL_TRUE ); + qglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); -// oldvisents = cl_numvisedicts; -// R_MirrorAddPlayerModels(); //we need to add the player model. Invisible in mirror otherwise. + qglMatrixMode(GL_PROJECTION); + qglLoadIdentity(); + qglOrtho (0, 1, 1, 0, -99999, 99999); + qglMatrixMode(GL_MODELVIEW); + qglLoadIdentity (); - d = DotProduct (oldorg, mirror_plane->normal) - mirror_plane->dist; - VectorMA (oldorg, -2*d, mirror_plane->normal, r_refdef.vieworg); - memcpy(r_origin, r_refdef.vieworg, sizeof(vec3_t)); + qglBegin(GL_QUADS); + qglVertex3f(0, 0, -99999); + qglVertex3f(1, 0, -99999); + qglVertex3f(1, 1, -99999); + qglVertex3f(0, 1, -99999); + qglEnd(); - d = DotProduct (oldvpn, mirror_plane->normal); - VectorMA (oldvpn, -2*d, mirror_plane->normal, vpn); - - d = DotProduct (oldvright, mirror_plane->normal); - VectorMA (oldvright, -2*d, mirror_plane->normal, vright); - - d = DotProduct (oldvup, mirror_plane->normal); - VectorMA (oldvup, -2*d, mirror_plane->normal, vup); - - r_refdef.viewangles[0] = -asin (vpn[2])/M_PI*180; - r_refdef.viewangles[1] = atan2 (vpn[1], vpn[0])/M_PI*180; - r_refdef.viewangles[2] = -oldangles[2]; - - vpn[0]*=0.001; - vpn[1]*=0.001; - vpn[2]*=0.001; + qglEnable(GL_DEPTH_TEST); //use only the stencil test + qglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); /* - r_refdef.vieworg[0] = 400; - r_refdef.vieworg[1] = 575; - r_refdef.vieworg[2] = 64; +Thus the final mirror matrix for any given plane p*+k=0 is: + +| 1-2*nx*nx -2*nx*ny -2*nx*nz -2*nx*k | + +| -2*ny*nx 1-2*ny*ny -2*ny*nz -2*ny*k | + +| -2*nz*nx -2*nz*ny 1-2*nz*nz -2*nz*k | + +| 0 0 0 1 | */ - AngleVectors (r_refdef.viewangles, vpn, vright, vup); + { + float mirror[16]; + float view[16]; + float result[16]; + float nx = mirror_plane->normal[0]; + float ny = mirror_plane->normal[1]; + float nz = mirror_plane->normal[2]; + float k = -mirror_plane->dist; + + mirror[0] = 1-2*nx*nx; + mirror[1] = -2*nx*ny; + mirror[2] = -2*nx*nz; + mirror[3] = 0; + + mirror[4] = -2*ny*nx; + mirror[5] = 1-2*ny*ny; + mirror[6] = -2*ny*nz; + mirror[7] = 0; + + mirror[8] = -2*nz*nx; + mirror[9] = -2*nz*ny; + mirror[10] = 1-2*nz*nz; + mirror[11] = 0; + + mirror[12] = -2*nx*k; + mirror[13] = -2*ny*k; + mirror[14] = -2*nz*k; + mirror[15] = 1; + + view[0] = oldvpn[0]; + view[1] = oldvpn[1]; + view[2] = oldvpn[2]; + view[3] = 0; + + view[4] = -oldvright[0]; + view[5] = -oldvright[1]; + view[6] = -oldvright[2]; + view[7] = 0; + + view[8] = oldvup[0]; + view[9] = oldvup[1]; + view[10] = oldvup[2]; + view[11] = 0; + + view[12] = oldorg[0]; + view[13] = oldorg[1]; + view[14] = oldorg[2]; + view[15] = 1; + + Matrix4_Multiply(mirror, view, result); + + vpn[0] = result[0]; + vpn[1] = result[1]; + vpn[2] = result[2]; + + vright[0] = -result[4]; + vright[1] = -result[5]; + vright[2] = -result[6]; + + vup[0] = result[8]; + vup[1] = result[9]; + vup[2] = result[10]; + + r_refdef.vieworg[0] = result[12]; + r_refdef.vieworg[1] = result[13]; + r_refdef.vieworg[2] = result[14]; + } + + r_refdef.viewangles[0] = 0; + r_refdef.viewangles[1] = 0; + r_refdef.viewangles[2] = 0; gldepthmin = 0.5; @@ -1841,7 +1936,7 @@ void R_Mirror (void) R_RenderScene (); - GLR_DrawWaterSurfaces (); +// GLR_DrawWaterSurfaces (); gldepthmin = 0; @@ -1853,36 +1948,32 @@ void R_Mirror (void) memcpy(r_refdef.viewangles, oldangles, sizeof(vec3_t)); memcpy(r_refdef.vieworg, oldorg, sizeof(vec3_t)); - qglMatrixMode(GL_PROJECTION); - if (mirror_plane->normal[2]) - qglScalef (1,-1,1); - else - qglScalef (-1,1,1); qglCullFace(GL_FRONT); qglMatrixMode(GL_MODELVIEW); - qglLoadMatrixf (r_base_world_matrix); + qglLoadMatrixf (base_view_matrix); qglDisable(GL_STENCIL_TEST); // blend on top qglDisable(GL_ALPHA_TEST); qglEnable (GL_BLEND); + qglEnable(GL_TEXTURE_2D); qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); qglColor4f (1,1,1,r_mirroralpha.value); - - for ( ; s ; s=s->texturechain) +qglDisable(GL_STENCIL_TEST); +qglPolygonOffset(1, 0); +qglEnable(GL_POLYGON_OFFSET_FILL); + for (s=prevs ; s ; s=s->nextalphasurface) { qglEnable (GL_BLEND); R_RenderBrushPoly (s); } - cl.worldmodel->textures[mirrortexturenum]->texturechain = NULL; +qglDisable(GL_POLYGON_OFFSET_FILL); +qglPolygonOffset(0, 0); + qglEnable(GL_TEXTURE_2D); qglDisable (GL_BLEND); qglColor4f (1,1,1,1); - - //put things back for rear views - qglCullFace(GL_BACK); -// cl_numvisedicts = oldvisents; } qglDisable(GL_STENCIL_TEST); @@ -2016,8 +2107,8 @@ void GLR_RenderView (void) // render normal view R_RenderScene (); GLR_DrawViewModel (); - GLR_DrawWaterSurfaces (); - GLR_DrawAlphaSurfaces (); +// GLR_DrawWaterSurfaces (); +// GLR_DrawAlphaSurfaces (); // render mirror view R_Mirror (); diff --git a/engine/gl/gl_rsurf.c b/engine/gl/gl_rsurf.c index 9dd35febf..d1b7947d3 100644 --- a/engine/gl/gl_rsurf.c +++ b/engine/gl/gl_rsurf.c @@ -1746,40 +1746,6 @@ void GL_EnableMultitexture(void) } } -/* -================ -DrawGLWaterPoly - -Warp the vertex coordinates -================ -*/ -static void DrawGLWaterPoly (mesh_t *p) -{ - Sys_Error("DrawGLWaterPoly needs work"); -/* - int i; - float *v; - vec3_t nv; - - - GL_DisableMultitexture(); - - qglBegin (GL_TRIANGLE_FAN); - v = p->verts[0]; - for (i=0 ; inumverts ; i++, v+= VERTEXSIZE) - { - qglTexCoord2f (v[3], v[4]); - - nv[0] = v[0] + 8*sin(v[1]*0.05+realtime)*sin(v[2]*0.05+realtime); - nv[1] = v[1] + 8*sin(v[0]*0.05+realtime)*sin(v[2]*0.05+realtime); - nv[2] = v[2]; - - qglVertex3fv (nv); - } - qglEnd (); -*/ -} - /* ================ DrawGLPoly @@ -1788,8 +1754,14 @@ DrawGLPoly static void DrawGLPoly (mesh_t *mesh) { // GL_DrawAliasMesh +#ifdef Q3SHADERS + R_UnlockArrays(); +#endif + qglVertexPointer(3, GL_FLOAT, 0, mesh->xyz_array); qglEnableClientState( GL_VERTEX_ARRAY ); + qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); + qglTexCoordPointer(2, GL_FLOAT, 0, mesh->st_array); qglDrawElements(GL_TRIANGLES, mesh->numindexes, GL_UNSIGNED_INT, mesh->indexes); R_IBrokeTheArrays(); @@ -1938,13 +1910,7 @@ void R_RenderBrushPoly (msurface_t *fa) return; } -//moved so lightmap is made first. - if (((r_viewleaf->contents==Q1CONTENTS_EMPTY && (fa->flags & SURF_UNDERWATER)) || - (r_viewleaf->contents!=Q1CONTENTS_EMPTY && !(fa->flags & SURF_UNDERWATER))) - && !(fa->flags & SURF_DONTWARP)) - DrawGLWaterPoly (fa->mesh); - else - DrawGLPoly (fa->mesh); + DrawGLPoly (fa->mesh); } /* @@ -2090,7 +2056,7 @@ void GLR_DrawWaterSurfaces (void) // go back to the world matrix // - qglLoadMatrixf (r_world_matrix); + qglLoadMatrixf (r_view_matrix); if (r_wateralphaval < 1.0) { qglEnable (GL_BLEND); @@ -2232,7 +2198,7 @@ void GLR_DrawAlphaSurfaces (void) // go back to the world matrix // - qglLoadMatrixf (r_world_matrix); + qglLoadMatrixf (r_view_matrix); GL_TexEnv(GL_MODULATE); qglEnable(GL_ALPHA_TEST); @@ -2932,14 +2898,14 @@ start: R_RenderDynamicLightmaps (surf); // if sorting by texture, just store it out - if (surf->flags & SURF_DRAWALPHA) +/* if (surf->flags & SURF_DRAWALPHA) { // add to the translucent chain surf->nextalphasurface = r_alpha_surfaces; r_alpha_surfaces = surf; surf->ownerent = &r_worldentity; } else - { +*/ { surf->texturechain = surf->texinfo->texture->texturechain; surf->texinfo->texture->texturechain = surf; } diff --git a/engine/gl/glquake.h b/engine/gl/glquake.h index a69984155..04e5fc9c4 100644 --- a/engine/gl/glquake.h +++ b/engine/gl/glquake.h @@ -207,7 +207,8 @@ extern int mirrortexturenum; // quake texturenum, not gltexturenum extern qboolean mirror; extern mplane_t *mirror_plane; -extern float r_world_matrix[16]; +extern float r_projection_matrix[16]; +extern float r_view_matrix[16]; extern const char *gl_vendor; extern const char *gl_renderer; diff --git a/engine/http/webgen.c b/engine/http/webgen.c index 114d6ab0d..36bc83d9a 100644 --- a/engine/http/webgen.c +++ b/engine/http/webgen.c @@ -229,7 +229,7 @@ void IWeb_GenerateIndexFile (char *parms, char *content, int contentlength) IWeb_Generate(hostname.string); IWeb_Generate(""); - IWeb_Generate("Server website

"); + IWeb_Generate("Engine website

"); if (Rank_OpenRankings()) IWeb_Generate("Click here to see ranked players.

"); diff --git a/engine/qclib/pr_edict.c b/engine/qclib/pr_edict.c index 1243e1349..ce3e204a1 100644 --- a/engine/qclib/pr_edict.c +++ b/engine/qclib/pr_edict.c @@ -573,7 +573,7 @@ char *PR_UglyValueString (progfuncs_t *progfuncs, etype_t type, eval_t *val) static char line[256]; fdef_t *fielddef; dfunction_t *f; - int i; + int i, j; #ifdef DEF_SAVEGLOBAL type &= ~DEF_SAVEGLOBAL; @@ -591,19 +591,28 @@ char *PR_UglyValueString (progfuncs_t *progfuncs, etype_t type, eval_t *val) sprintf (line, "unions cannot yet be saved"); break; case ev_string: - _snprintf (line, sizeof(line), "%s", val->string+progfuncs->stringtable); + if ((unsigned)val->_int > (unsigned)addressableused) + _snprintf (line, sizeof(line), "CORRUPT STRING"); + else + _snprintf (line, sizeof(line), "%s", val->string+progfuncs->stringtable); break; case ev_entity: sprintf (line, "%i", val->_int); break; case ev_function: - i = (val->function & 0xff000000)>>24; - if (i > maxprogs) + i = (val->function & 0xff000000)>>24; //progs number + if (i > maxprogs || !pr_progstate[i].progs) sprintf (line, "BAD FUNCTION INDEX: %i", val->function); else { - f = pr_progstate[(val->function & 0xff000000)>>24].functions + (val->function & ~0xff000000); - sprintf (line, "%i:%s", (val->function & 0xff000000)>>24, f->s_name+progfuncs->stringtable); + j = (val->function & ~0xff000000); //function number + if ((unsigned)j > pr_progstate[i].progs->numfunctions) + sprintf(line, "%i:%s", i, "CORRUPT FUNCTION POINTER"); + else + { + f = pr_progstate[i].functions + j; + sprintf (line, "%i:%s", i, f->s_name+progfuncs->stringtable); + } } break; case ev_field: diff --git a/engine/qclib/pr_exec.c b/engine/qclib/pr_exec.c index 6c23b5ecb..a561db74c 100644 --- a/engine/qclib/pr_exec.c +++ b/engine/qclib/pr_exec.c @@ -111,7 +111,7 @@ void PR_StackTrace (progfuncs_t *progfuncs) printf ("<%s>\n", pr_progstate[progs].filename); } if (!f->s_file) - printf ("stripped : %s\n", f->s_name); + printf ("stripped : %s\n", f->s_name+progfuncs->stringtable); else printf ("%12s : %s\n", f->s_file+progfuncs->stringtable, f->s_name+progfuncs->stringtable); diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index 3914975e7..e029fc7b6 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -6044,13 +6044,13 @@ void QCC_Marshal_Locals(int first, int laststatement) QCC_def_t *local; unsigned int newofs; - if (!opt_overlaptemps) //clear these after each function. we arn't overlapping them so why do we need to keep track of them? - { - temp_t *t; - for (t = functemps; t; t = t->next) - QCC_FreeOffset(t->ofs, t->size); - functemps = NULL; - } +// if (!opt_overlaptemps) //clear these after each function. we arn't overlapping them so why do we need to keep track of them? +// { +// temp_t *t; +// for (t = functemps; t; t = t->next) +// QCC_FreeOffset(t->ofs, t->size); +// functemps = NULL; +// } if (!pr.localvars) //nothing to marshal { diff --git a/engine/server/net_preparse.c b/engine/server/net_preparse.c index 5baedd4ee..503b3be32 100644 --- a/engine/server/net_preparse.c +++ b/engine/server/net_preparse.c @@ -421,7 +421,7 @@ void NPP_NQWriteByte(int dest, qbyte data) //replacement write func (nq to qw) multicasttype=MULTICAST_PVS; break; - case 76: + case DPTE_TEI_G3: protocollen = sizeofcoord*9+sizeof(qbyte)*2; multicastpos = 2; multicasttype=MULTICAST_PHS; @@ -433,7 +433,7 @@ void NPP_NQWriteByte(int dest, qbyte data) //replacement write func (nq to qw) multicasttype=MULTICAST_PHS; break; - case 79: + case DPTE_TEI_PLASMAHIT: protocollen = sizeofcoord*6+sizeof(qbyte)*3; multicastpos = 2; multicasttype=MULTICAST_PHS; diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 3d79949df..8e3306ab5 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -1333,9 +1333,9 @@ void PR_ClientUserInfoChanged(char *name, char *oldivalue, char *newvalue) pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player); - G_INT(OFS_PARM0) = (int)PR_SetString(svprogfuncs, name); - G_INT(OFS_PARM1) = (int)PR_SetString(svprogfuncs, oldivalue); - G_INT(OFS_PARM2) = (int)PR_SetString(svprogfuncs, newvalue); + G_INT(OFS_PARM0) = PR_TempString(svprogfuncs, name); + G_INT(OFS_PARM1) = PR_TempString(svprogfuncs, oldivalue); + G_INT(OFS_PARM2) = PR_TempString(svprogfuncs, newvalue); PR_ExecuteProgram (svprogfuncs, UserInfo_Changed); } @@ -1351,9 +1351,9 @@ void PR_LocalInfoChanged(char *name, char *oldivalue, char *newvalue) pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv.edicts); - G_INT(OFS_PARM0) = (int)PR_SetString(svprogfuncs, name); - G_INT(OFS_PARM1) = (int)PR_SetString(svprogfuncs, oldivalue); - G_INT(OFS_PARM2) = (int)PR_SetString(svprogfuncs, newvalue); + G_INT(OFS_PARM0) = PR_TempString(svprogfuncs, name); + G_INT(OFS_PARM1) = PR_TempString(svprogfuncs, oldivalue); + G_INT(OFS_PARM2) = PR_TempString(svprogfuncs, newvalue); PR_ExecuteProgram (svprogfuncs, localinfoChanged); } @@ -2233,7 +2233,7 @@ PF_particle particle(origin, color, count) ================= */ -void PF_particle (progfuncs_t *prinst, globalvars_t *pr_globals) //I said it was for compatability only. +static void PF_particle (progfuncs_t *prinst, globalvars_t *pr_globals) //I said it was for compatability only. { float *org, *dir; float color; @@ -2359,7 +2359,7 @@ PF_particle2 - hexen2 particle(origin, dmin, dmax, color, effect, count) ================= */ -void PF_particle2 (progfuncs_t *prinst, globalvars_t *pr_globals) +static void PF_particle2 (progfuncs_t *prinst, globalvars_t *pr_globals) { float *org, *dmin, *dmax; float color; @@ -2399,7 +2399,7 @@ PF_particle3 - hexen2 particle(origin, box, color, effect, count) ================= */ -void PF_particle3 (progfuncs_t *prinst, globalvars_t *pr_globals) +static void PF_particle3 (progfuncs_t *prinst, globalvars_t *pr_globals) { float *org, *box; float color; @@ -2434,7 +2434,7 @@ PF_particle4 - hexen2 particle(origin, radius, color, effect, count) ================= */ -void PF_particle4 (progfuncs_t *prinst, globalvars_t *pr_globals) +static void PF_particle4 (progfuncs_t *prinst, globalvars_t *pr_globals) { float *org; float radius; @@ -3283,6 +3283,13 @@ char *PF_TempStr(progfuncs_t *prinst) return prinst->tempstringbase + (prinst->tempstringnum++)*MAXTEMPBUFFERLEN; } +string_t PR_TempString(progfuncs_t *prinst, char *str) +{ + char *tmp = PF_TempStr(prinst); + Q_strncpyz(tmp, str, MAXTEMPBUFFERLEN); + return tmp - prinst->tempstringbase; +} + void PF_InitTempStrings(progfuncs_t *prinst) { prinst->tempstringbase = prinst->AddString(prinst, "", MAXTEMPBUFFERLEN*MAX_TEMPSTRS); @@ -3920,7 +3927,8 @@ void PF_pointcontents (progfuncs_t *prinst, struct globalvars_s *pr_globals) v = G_VECTOR(OFS_PARM0); - cont = SV_PointContents (v); + cont = SV_Move(v, vec3_origin, vec3_origin, v, MOVE_NOMONSTERS, NULL).contents; +// cont = SV_PointContents (v); if (cont & FTECONTENTS_SOLID) G_FLOAT(OFS_RETURN) = Q1CONTENTS_SOLID; else if (cont & FTECONTENTS_SKY) @@ -4110,7 +4118,7 @@ void PF_changeyaw (progfuncs_t *prinst, struct globalvars_s *pr_globals) } //void() changepitch = #63; -void PF_changepitch (progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_changepitch (progfuncs_t *prinst, struct globalvars_s *pr_globals) { edict_t *ent; float ideal, current, move, speed; @@ -4851,11 +4859,13 @@ void PF_makestatic (progfuncs_t *prinst, struct globalvars_s *pr_globals) state->effects = ent->v->effects; state->hexen2flags = ent->v->drawflags; state->abslight = (int)(ent->v->abslight*255) & 255; - state->trans = ent->v->alpha; - if (!state->trans) - state->trans = 1; + state->trans = ent->v->alpha*255; + if (!ent->v->alpha) + state->trans = 255; state->fatness = ent->v->fatness; - state->scale = ent->v->scale; + state->scale = ent->v->scale*16.0; + if (!ent->v->scale) + state->scale = 1*16; if (progstype != PROG_QW) //don't send extra nq effects to a qw client. state->effects &= EF_BRIGHTLIGHT | EF_DIMLIGHT; @@ -6974,7 +6984,7 @@ void PF_randomvec (progfuncs_t *prinst, struct globalvars_s *pr_globals) //void(vector dir) vectorvectors = #432 //Writes new values for v_forward, v_up, and v_right based on the given forward vector -void PF_vectorvectors (progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_vectorvectors (progfuncs_t *prinst, struct globalvars_s *pr_globals) { VectorCopy(G_VECTOR(OFS_PARM0), P_VEC(v_forward)); VectorNormalize(P_VEC(v_forward)); @@ -7953,7 +7963,7 @@ void PF_te_bloodshower(progfuncs_t *prinst, struct globalvars_s *pr_globals) //DP_SV_EFFECT //void(vector org, string modelname, float startframe, float endframe, float framerate) effect = #404; -void PF_effect(progfuncs_t *prinst, struct globalvars_s *pr_globals) +static void PF_effect(progfuncs_t *prinst, struct globalvars_s *pr_globals) { float *org = G_VECTOR(OFS_PARM0); char *name = PR_GetStringOfs(prinst, OFS_PARM1); @@ -8413,24 +8423,19 @@ void PF_setattachment(progfuncs_t *prinst, struct globalvars_s *pr_globals) edict_t *tagentity = G_EDICT(prinst, OFS_PARM1); char *tagname = PR_GetStringOfs(prinst, OFS_PARM2); - eval_t *te; - eval_t *ti; - int modelindex; - te = prinst->GetEdictFieldValue(prinst, e, "tag_entity", NULL); - ti = prinst->GetEdictFieldValue(prinst, e, "tag_index", NULL); + int tagidx; - e->tagent = tagentity->entnum; - e->tagindex = 0; + tagidx = 0; if (tagentity != sv.edicts && tagname && tagname[0]) { modelindex = (int)tagentity->v->modelindex; if (modelindex > 0 && modelindex < MAX_MODELS && sv.model_precache[modelindex]) { - e->tagindex = SV_TagForName(modelindex, tagname); - if (e->tagindex == 0) + tagidx = SV_TagForName(modelindex, tagname); + if (tagidx == 0) Con_DPrintf("setattachment(edict %i, edict %i, string \"%s\"): tried to find tag named \"%s\" on entity %i (model \"%s\") but could not find it\n", NUM_FOR_EDICT(prinst, e), NUM_FOR_EDICT(prinst, tagentity), tagname, tagname, NUM_FOR_EDICT(prinst, tagentity), sv.models[modelindex]->name); } else @@ -8438,18 +8443,8 @@ void PF_setattachment(progfuncs_t *prinst, struct globalvars_s *pr_globals) } - //fix me, move to somewhere nicer. - MSG_WriteByte(&sv.multicast, svc_setattachment); - MSG_WriteShort(&sv.multicast, e->entnum); - MSG_WriteShort(&sv.multicast, e->tagent); - MSG_WriteShort(&sv.multicast, e->tagindex); - - SV_MulticastProtExt(vec3_origin, MULTICAST_ALL_R, 0xffffffff, PEXT_SETATTACHMENT, 0); - - if (te) - te->edict = EDICT_TO_PROG(prinst,EDICT_NUM(prinst, e->tagent)); - if (ti) - te->_float = e->tagindex; + e->v->tag_entity = EDICT_TO_PROG(prinst,tagentity); + e->v->tag_index = tagidx; } void PF_clientstat(progfuncs_t *prinst, struct globalvars_s *pr_globals) @@ -9166,6 +9161,9 @@ void PR_RegisterFields(void) //it's just easier to do it this way. fieldentity(viewmodelforclient); fieldentity(exteriormodeltoclient); + fieldentity(tag_entity); + fieldfloat(tag_index); + fieldfloat(glow_size); fieldfloat(glow_color); fieldfloat(glow_trail); diff --git a/engine/server/progdefs.h b/engine/server/progdefs.h index 9a66e23ac..b876cbfc9 100644 --- a/engine/server/progdefs.h +++ b/engine/server/progdefs.h @@ -185,6 +185,9 @@ typedef struct entvars_s int viewmodelforclient; int exteriormodeltoclient; + int tag_entity; + float tag_index; + float glow_size; float glow_color; float glow_trail; diff --git a/engine/server/progs.h b/engine/server/progs.h index f662f6518..5b2078043 100644 --- a/engine/server/progs.h +++ b/engine/server/progs.h @@ -84,10 +84,6 @@ typedef struct edict_s entity_state_t baseline; qbyte solidtype; //relinks entities if thier solidity changed - - unsigned short tagent; - unsigned short tagindex; - // other fields from progs come immediately after } edict_t; diff --git a/engine/server/sv_ccmds.c b/engine/server/sv_ccmds.c index 1c8caa1e3..9883132ec 100644 --- a/engine/server/sv_ccmds.c +++ b/engine/server/sv_ccmds.c @@ -902,7 +902,13 @@ void SV_Status_f (void) pak = (float)svs.stats.latched_packets/ STATFRAMES; if (net_local_sv_ipadr.type != NA_LOOPBACK) - Con_Printf ("ip address : %s\n",NET_AdrToString (net_local_sv_ipadr)); + { + extern cvar_t pr_imitatemvdsv; + if (pr_imitatemvdsv.value) + Con_Printf ("net address : %s\n",NET_AdrToString (net_local_sv_ipadr)); + else + Con_Printf ("ip address : %s\n",NET_AdrToString (net_local_sv_ipadr)); + } Con_Printf ("cpu utilization : %3i%%\n",(int)cpu); Con_Printf ("avg response time: %i ms\n",(int)avg); Con_Printf ("packets/frame : %5.2f\n", pak); //not relevent as a limit. @@ -1187,6 +1193,8 @@ void SV_Localinfo_f (void) Info_SetValueForKey (localinfo, Cmd_Argv(1), Cmd_Argv(2), MAX_LOCALINFO_STRING); PR_LocalInfoChanged(Cmd_Argv(1), old, Cmd_Argv(2)); + + Con_DPrintf("Localinfo %s changed (%s -> %s)\n", Cmd_Argv(1), old, Cmd_Argv(2)); } void SV_SaveInfo(FILE *f, char *info, char *commandname) @@ -1399,6 +1407,11 @@ void SV_Snap (int uid) Con_TPrintf (STL_USERDOESNTEXIST); return; } + if (!ISQWCLIENT(cl)) + { + Con_Printf("Can only snap QW clients\n"); + return; + } sprintf(pcxname, "%d-00.pcx", uid); @@ -1428,7 +1441,7 @@ void SV_Snap (int uid) cl->remote_snap = false; ClientReliableWrite_Begin (cl, svc_stufftext, 24); - ClientReliableWrite_String (cl, "cmd snap"); + ClientReliableWrite_String (cl, "cmd snap\n"); Con_TPrintf (STL_SNAPREQUEST, uid); } diff --git a/engine/server/sv_ents.c b/engine/server/sv_ents.c index ad69e754f..8d129ab6b 100644 --- a/engine/server/sv_ents.c +++ b/engine/server/sv_ents.c @@ -524,12 +524,15 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb if ( to->abslight != from->abslight && protext & PEXT_HEXEN2) evenmorebits |= U_ABSLIGHT; - if (to->glowsize) + if (to->glowsize != from->glowsize) to->dpflags |= 4; - if (to->dpflags) + if (to->dpflags != from->dpflags) evenmorebits |= U_DPFLAGS; + if (to->tagentity != from->tagentity || to->tagindex != from->tagindex) + evenmorebits |= U_TAGINFO; + if (evenmorebits&0xff00) evenmorebits |= U_YETMORE; if (evenmorebits&0x00ff) @@ -594,15 +597,15 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb #ifdef U_SCALE if (evenmorebits & U_SCALE) - MSG_WriteByte (msg, (qbyte)(to->scale*100.0)); + MSG_WriteByte (msg, (qbyte)(to->scale)); #endif #ifdef U_TRANS if (evenmorebits & U_TRANS) - MSG_WriteByte (msg, (qbyte)(to->trans*255)); + MSG_WriteByte (msg, (qbyte)(to->trans)); #endif #ifdef U_FATNESS if (evenmorebits & U_FATNESS) - MSG_WriteChar (msg, to->fatness*2); + MSG_WriteChar (msg, to->fatness); #endif if (evenmorebits & U_DRAWFLAGS) @@ -612,6 +615,13 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb if (evenmorebits & U_DPFLAGS) MSG_WriteByte (msg, to->dpflags); + + if (evenmorebits & U_TAGINFO) + { + MSG_WriteShort (msg, to->tagentity); + MSG_WriteShort (msg, to->tagindex); + } + } /* @@ -781,12 +791,18 @@ void SV_EmitPacketEntities (client_t *client, packet_entities_t *to, sizebuf_t * void SVDP_EmitEntity(entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean isnew) { int bits; - if (!memcmp(from, to, sizeof(entity_state_t))) + if (!isnew && !memcmp(from, to, sizeof(entity_state_t))) + { + to->bitmask = 0; return; //didn't change + } bits = 0; if (isnew) + { bits |= E5_FULLUPDATE; + to->bitmask = 0; //no point... + } if (!VectorCompare(from->origin, to->origin)) bits |= E5_ORIGIN; @@ -800,20 +816,20 @@ void SVDP_EmitEntity(entity_state_t *from, entity_state_t *to, sizebuf_t *msg, q bits |= E5_SKIN; if (from->effects != to->effects) bits |= E5_EFFECTS; - if (from->flags != to->flags) + if (from->dpflags != to->dpflags) bits |= E5_FLAGS; if (from->trans != to->trans) bits |= E5_ALPHA; -// if (from->scale != to->scale) -// bits |= E5_SCALE; + if (from->scale != to->scale) + bits |= E5_SCALE; if (from->colormap != to->colormap) bits |= E5_COLORMAP; -// if (from->tagentity != to->tagentity || o->tagindex != to->tagindex) -// bits |= E5_ATTACHMENT; + if (from->tagentity != to->tagentity || from->tagindex != to->tagindex) + bits |= E5_ATTACHMENT; // if (from->light[0] != to->light[0] || o->light[1] != to->light[1] || o->light[2] != to->light[2] || o->light[3] != to->light[3] || o->lightstyle != to->lightstyle || o->lightpflags != to->lightpflags) // bits |= E5_LIGHT; -// if (from->glowsize != to->glowsize || o->glowcolor != to->glowcolor) -// bits |= E5_GLOW; + if (from->glowsize != to->glowsize || from->glowcolour != to->glowcolour) + bits |= E5_GLOW; // if (from->colormod[0] != to->colormod[0] || o->colormod[1] != to->colormod[1] || o->colormod[2] != to->colormod[2]) // bits |= E5_COLORMOD; @@ -839,7 +855,8 @@ void SVDP_EmitEntity(entity_state_t *from, entity_state_t *to, sizebuf_t *msg, q if (bits >= 16777216) bits |= E5_EXTEND3; - to->bitmask |= bits; + bits |= to->bitmask; + to->bitmask = bits; if (!bits) return; @@ -853,7 +870,7 @@ void SVDP_EmitEntity(entity_state_t *from, entity_state_t *to, sizebuf_t *msg, q if (bits & E5_EXTEND3) MSG_WriteByte(msg, (bits >> 24) & 0xFF); if (bits & E5_FLAGS) - MSG_WriteByte(msg, to->flags); + MSG_WriteByte(msg, to->dpflags); if (bits & E5_ORIGIN) { if (bits & E5_ORIGIN32) @@ -910,16 +927,16 @@ void SVDP_EmitEntity(entity_state_t *from, entity_state_t *to, sizebuf_t *msg, q MSG_WriteByte(msg, to->effects); } if (bits & E5_ALPHA) - MSG_WriteByte(msg, to->trans*255); + MSG_WriteByte(msg, to->trans); if (bits & E5_SCALE) MSG_WriteByte(msg, to->scale); if (bits & E5_COLORMAP) MSG_WriteByte(msg, to->colormap); -// if (bits & E5_ATTACHMENT) -// { -// MSG_WriteShort(msg, to->tagentity); -// MSG_WriteByte(msg, to->tagindex); -// } + if (bits & E5_ATTACHMENT) + { + MSG_WriteShort(msg, to->tagentity); + MSG_WriteByte(msg, to->tagindex); + } // if (bits & E5_LIGHT) // { // MSG_WriteShort(msg, to->light[0]); @@ -929,11 +946,11 @@ void SVDP_EmitEntity(entity_state_t *from, entity_state_t *to, sizebuf_t *msg, q // MSG_WriteByte(msg, to->lightstyle); // MSG_WriteByte(msg, to->lightpflags); // } -// if (bits & E5_GLOW) -// { -// MSG_WriteByte(msg, to->glowsize); -// MSG_WriteByte(msg, to->glowcolor); -// } + if (bits & E5_GLOW) + { + MSG_WriteByte(msg, to->glowsize); + MSG_WriteByte(msg, to->glowcolour); + } // if (bits & E5_COLORMOD) // { // MSG_WriteByte(msg, to->colormod[0]); @@ -942,6 +959,7 @@ void SVDP_EmitEntity(entity_state_t *from, entity_state_t *to, sizebuf_t *msg, q // } } +entity_state_t defaultstate; void SVDP_EmitEntitiesUpdate (client_t *client, packet_entities_t *to, sizebuf_t *msg) { edict_t *ent; @@ -951,19 +969,14 @@ void SVDP_EmitEntitiesUpdate (client_t *client, packet_entities_t *to, sizebuf_t int oldnum, newnum; int oldmax; + client->netchan.incoming_sequence++; + // this is the frame that we are going to delta update from - if (client->delta_sequence != -1) - { - fromframe = &client->frames[client->delta_sequence & UPDATE_MASK]; - from = &fromframe->entities; - oldmax = from->num_entities; - } - else - { - oldmax = 0; // no delta update - from = NULL; - } - client->delta_sequence++; + fromframe = &client->frames[(client->netchan.incoming_sequence-2) & UPDATE_MASK]; + from = &fromframe->entities; + oldmax = from->num_entities; + +// Con_Printf ("frame %i\n", client->netchan.incoming_sequence); MSG_WriteByte(msg, svcdp_entities); MSG_WriteLong(msg, 0); @@ -972,6 +985,7 @@ void SVDP_EmitEntitiesUpdate (client_t *client, packet_entities_t *to, sizebuf_t for (newindex = 0; newindex < to->num_entities; newindex++) to->entities[newindex].bitmask = 0; + //add in the bitmasks of dropped packets. newindex = 0; oldindex = 0; @@ -992,10 +1006,10 @@ void SVDP_EmitEntitiesUpdate (client_t *client, packet_entities_t *to, sizebuf_t } if (newnum < oldnum) - { // this is a new entity, send it from the baseline + { // this is a new entity, send it from the baseline... as far as dp understands it... ent = EDICT_NUM(svprogfuncs, newnum); //Con_Printf ("baseline %i\n", newnum); - SVDP_EmitEntity (&ent->baseline, &to->entities[newindex], msg, true); + SVDP_EmitEntity (&defaultstate, &to->entities[newindex], msg, true); newindex++; continue; } @@ -1140,19 +1154,19 @@ void SV_WritePlayerToClient(sizebuf_t *msg, clstate_t *ent) #ifdef PEXT_SCALE //this is graphics, not physics if (ent->fteext & PEXT_SCALE) { - if (ent->scale) pflags |= (zext&Z_EXT_PM_TYPE)?PF_SCALE_Z:PF_SCALE_NOZ; + if (ent->scale) pflags |= PF_SCALE_Z; } #endif #ifdef PEXT_TRANS if (ent->fteext & PEXT_TRANS) { - if (ent->transparency) pflags |= (zext&Z_EXT_PM_TYPE)?PF_TRANS_Z:PF_TRANS_NOZ; + if (ent->transparency) pflags |= PF_TRANS_Z; } #endif #ifdef PEXT_FATNESS if (ent->fteext & PEXT_FATNESS) { - if (ent->fatness) pflags |= (zext&Z_EXT_PM_TYPE)?PF_FATNESS_Z:PF_FATNESS_NOZ; + if (ent->fatness) pflags |= PF_FATNESS_Z; } #endif } @@ -1161,7 +1175,7 @@ void SV_WritePlayerToClient(sizebuf_t *msg, clstate_t *ent) { hullnumber = SV_HullNumForPlayer(ent->hull, ent->mins, ent->maxs); if (hullnumber != 1) - pflags |= (zext&Z_EXT_PM_TYPE)?PF_HULLSIZE_Z:PF_HULLSIZE_NOZ; + pflags |= PF_HULLSIZE_Z; } else hullnumber=1; @@ -1288,44 +1302,22 @@ void SV_WritePlayerToClient(sizebuf_t *msg, clstate_t *ent) if (pflags & PF_WEAPONFRAME) MSG_WriteByte (msg, ent->weaponframe); - if (zext&Z_EXT_PM_TYPE) - { #ifdef PEXT_SCALE - if (pflags & PF_SCALE_Z) - MSG_WriteByte (msg, ent->scale*100); + if (pflags & PF_SCALE_Z) + MSG_WriteByte (msg, ent->scale*50); #endif #ifdef PEXT_TRANS - if (pflags & PF_TRANS_Z) - MSG_WriteByte (msg, (qbyte)(ent->transparency*255)); + if (pflags & PF_TRANS_Z) + MSG_WriteByte (msg, (qbyte)(ent->transparency*255)); #endif #ifdef PEXT_FATNESS - if (pflags & PF_FATNESS_Z) - MSG_WriteChar (msg, ent->fatness*2); + if (pflags & PF_FATNESS_Z) + MSG_WriteChar (msg, ent->fatness*2); #endif #ifdef PEXT_HULLSIZE //shrunken or crouching in halflife levels. (possibly enlarged) - if (pflags & PF_HULLSIZE_Z) - MSG_WriteChar (msg, hullnumber + (ent->onladder?128:0)); //physics. + if (pflags & PF_HULLSIZE_Z) + MSG_WriteChar (msg, hullnumber + (ent->onladder?128:0)); //physics. #endif - } - else - { -#ifdef PEXT_SCALE - if (pflags & PF_SCALE_NOZ) - MSG_WriteByte (msg, ent->scale*100); -#endif -#ifdef PEXT_TRANS - if (pflags & PF_TRANS_NOZ) - MSG_WriteByte (msg, (qbyte)(ent->transparency*255)); -#endif -#ifdef PEXT_FATNESS - if (pflags & PF_FATNESS_NOZ) - MSG_WriteChar (msg, ent->fatness*2); -#endif -#ifdef PEXT_HULLSIZE //shrunken or crouching in halflife levels. (possibly enlarged) - if (pflags & PF_HULLSIZE_NOZ) - MSG_WriteChar (msg, hullnumber + (ent->onladder?128:0)); //physics. -#endif - } } #endif @@ -2412,15 +2404,17 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore state->abslight = clent->v->abslight; #ifdef PEXT_SCALE - state->scale = clent->v->scale; + state->scale = clent->v->scale*16; + if (!clent->v->scale) + clent->v->scale = 1*16; #endif #ifdef PEXT_TRANS - state->trans = clent->v->alpha; - if (!state->trans) - state->trans = 1; + state->trans = clent->v->alpha*255; + if (!clent->v->alpha) + clent->v->alpha = 255; #endif #ifdef PEXT_FATNESS - state->fatness = clent->v->fatness; + state->fatness = clent->v->fatness*2; #endif if (state->effects & QWEF_FLAG1) @@ -2478,13 +2472,13 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore { //unconditional } - else if (ent->tagent) + else if (ent->v->tag_entity) { edict_t *p = ent; int c = 10; - while(p->tagent&&c-->0) + while(p->v->tag_entity&&c-->0) { - p = EDICT_NUM(svprogfuncs, p->tagent); + p = EDICT_NUM(svprogfuncs, p->v->tag_entity); } if (!sv.worldmodel->funcs.EdictInFatPVS(p)) continue; @@ -2635,7 +2629,7 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore if (ent->v->exteriormodeltoclient) { if (ent->v->exteriormodeltoclient == EDICT_TO_PROG(svprogfuncs, client->edict)) - state->dpflags |= RENDER_VIEWMODEL; + state->dpflags |= RENDER_EXTERIORMODEL; //everyone else sees it normally. } @@ -2650,6 +2644,8 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore state->effects = ent->v->effects; state->hexen2flags = ent->v->drawflags; state->abslight = (int)(ent->v->abslight*255) & 255; + state->tagentity = ent->v->tag_entity; + state->tagindex = ent->v->tag_index; if ((int)ent->v->flags & FL_CLASS_DEPENDENT && client->playerclass) { char modname[MAX_QPATH]; @@ -2667,7 +2663,7 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore { state->hexen2flags |= MLS_FULLBRIGHT; } - if (progstype != PROG_QW && state->effects) //don't send extra nq effects to a qw client. + if (progstype != PROG_QW && state->effects && ISQWCLIENT(client)) //don't send extra nq effects to a qw client. { //EF_NODRAW doesn't draw the model. //The client still needs to know about it though, as it might have other effects on it. @@ -2685,16 +2681,21 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore state->effects &= EF_BRIGHTLIGHT | EF_DIMLIGHT | NQEF_ADDATIVE | EF_RED | EF_BLUE; } -#ifdef PEXT_SCALE - state->scale = ent->v->scale; -#endif -#ifdef PEXT_TRANS - state->trans = ent->v->alpha; - if (!ent->v->alpha) - state->trans = 1; - state->glowsize = ent->v->glow_size*0.25; state->glowcolour = ent->v->glow_color; + if (ent->v->glow_trail) + state->dpflags |= RENDER_GLOWTRAIL; + + +#ifdef PEXT_SCALE + state->scale = ent->v->scale*16; + if (!ent->v->scale) + state->scale = 1*16; +#endif +#ifdef PEXT_TRANS + state->trans = ent->v->alpha*255; + if (!ent->v->alpha) + state->trans = 255; //QSG_DIMENSION_PLANES - if the only shared dimensions are ghost dimensions, Set half alpha. if (client->edict) @@ -2708,18 +2709,23 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore } #endif #ifdef PEXT_FATNESS - state->fatness = ent->v->fatness; + state->fatness = ent->v->fatness*2; #endif } #ifdef NQPROT - if (client->protocol == SCP_NETQUAKE) - return; - - if (client->protocol == SCP_DARKPLACES6 || client->protocol == SCP_DARKPLACES7) + if (ISNQCLIENT(client)) { - SVDP_EmitEntitiesUpdate(client, pack, msg); - SV_EmitCSQCUpdate(client, msg); - return; + if (client->protocol == SCP_DARKPLACES6 || client->protocol == SCP_DARKPLACES7) + { + SVDP_EmitEntitiesUpdate(client, pack, msg); + SV_EmitCSQCUpdate(client, msg); + return; + } + else + { + client->netchan.incoming_sequence++; + return; + } } #endif diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index 716601400..f48ba5948 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -210,10 +210,10 @@ void SVNQ_CreateBaseline (void) svent->baseline.number = entnum; #ifdef PEXT_SCALE - svent->baseline.scale = 1; + svent->baseline.scale = 1*16; #endif #ifdef PEXT_TRANS - svent->baseline.trans = 1; + svent->baseline.trans = 255; #endif if (svent->isfree) diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 7e3d1bc05..8cd68f498 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -376,7 +376,8 @@ void SV_DropClient (client_t *drop) if (pr_nqglobal_struct->SetChangeParms) PR_ExecuteProgram (svprogfuncs, pr_global_struct->SetChangeParms); for (j=0 ; jrankid, &rs); } } @@ -2066,6 +2067,8 @@ void SVNQ_ConnectionlessPacket(void) if (sv_listen.value < 2) return; + if (sv_bigcoords.value) + return; //no, start using dp7 instead. MSG_BeginReading(); header = BigLong(MSG_ReadLong()); @@ -2677,6 +2680,7 @@ SV_Frame */ void SV_Frame (float time) { + extern cvar_t pr_imitatemvdsv; static double start, end; start = Sys_DoubleTime (); @@ -2744,6 +2748,13 @@ void SV_MVDStream_Poll(void); // get packets SV_ReadPackets (); + if (pr_imitatemvdsv.value) + { + Cbuf_Execute (); + if (sv.state < ss_active) //whoops... + return; + } + if (sv.multicast.cursize) { Con_Printf("Unterminated multicast\n"); @@ -2771,8 +2782,10 @@ void SV_MVDStream_Poll(void); SV_GetConsoleCommands (); // process console commands + if (!pr_imitatemvdsv.value) Cbuf_Execute (); } + if (sv.state < ss_active) //whoops... return; @@ -3588,6 +3601,14 @@ void SV_Init (quakeparms_t *parms) // if a map wasn't specified on the command line, spawn start.map if (sv.state == ss_dead) Cmd_ExecuteString ("map start", RESTRICT_LOCAL); + if (sv.state == ss_dead) + { + cvar_t *ml; + ml = Cvar_Get("g_maplist", "dm1 dm2 dm3 dm4 dm5 dm6", 0, ""); + Cmd_TokenizeString(ml->string, false, false); + if (Cmd_Argc()) + Cmd_ExecuteString(va("map %s", Cmd_Argv(rand()%Cmd_Argc())), RESTRICT_LOCAL); + } if (sv.state == ss_dead) SV_Error ("Couldn't spawn a server"); diff --git a/engine/server/sv_mvd.c b/engine/server/sv_mvd.c index 0c90bfdcb..dc91948ee 100644 --- a/engine/server/sv_mvd.c +++ b/engine/server/sv_mvd.c @@ -1367,7 +1367,7 @@ static qboolean SV_MVD_Record (mvddest_t *dest) n = 0; s = sv.model_precache[n+1]; - while (*s) + while (s) { MSG_WriteString (&buf, s); if (buf.cursize > MAX_QWMSGLEN/2) diff --git a/engine/server/sv_phys.c b/engine/server/sv_phys.c index fd410e504..80dfe5466 100644 --- a/engine/server/sv_phys.c +++ b/engine/server/sv_phys.c @@ -1680,7 +1680,8 @@ void SV_RunEntity (edict_t *ent) // pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, ent); - PR_ExecuteProgram (svprogfuncs, pr_global_struct->PlayerPreThink); + if (pr_global_struct->PlayerPreThink) + PR_ExecuteProgram (svprogfuncs, pr_global_struct->PlayerPreThink); if (readyforjump) //qw progs can't jump for themselves... { @@ -1780,7 +1781,8 @@ void SV_RunEntity (edict_t *ent) pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, ent); - PR_ExecuteProgram (svprogfuncs, pr_global_struct->PlayerPostThink); + if (pr_global_struct->PlayerPostThink) + PR_ExecuteProgram (svprogfuncs, pr_global_struct->PlayerPostThink); } } diff --git a/engine/server/sv_send.c b/engine/server/sv_send.c index e7fc8b709..838b61c7a 100644 --- a/engine/server/sv_send.c +++ b/engine/server/sv_send.c @@ -967,7 +967,7 @@ void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg) MSG_WriteByte (msg, svc_time); MSG_WriteFloat(msg, sv.physicstime); client->nextservertimeupdate = sv.physicstime; - Con_Printf("%f\n", sv.physicstime); +// Con_Printf("%f\n", sv.physicstime); bits = 0; diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index 2b08cc98a..df6ce3c20 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -929,14 +929,6 @@ void SV_PreSpawn_f (void) ent = EDICT_NUM(svprogfuncs, buf - bufs - sv.numextrastatics); - if (ent->tagent) - { - MSG_WriteByte(&host_client->netchan.message, svc_setattachment); - MSG_WriteShort(&host_client->netchan.message, ent->entnum); - MSG_WriteShort(&host_client->netchan.message, ent->tagent); - MSG_WriteShort(&host_client->netchan.message, ent->tagindex); - } - state = &ent->baseline; if (!state->number || !state->modelindex) { //ent doesn't have a baseline @@ -2267,16 +2259,16 @@ void SV_SetInfo_f (void) sv_player->v->team = atoi(Cmd_Argv(2))+1; } - PR_ClientUserInfoChanged(Cmd_Argv(1), oldval, Cmd_Argv(2)); + if (*Cmd_Argv(1) != '_') + { + i = host_client - svs.clients; + MSG_WriteByte (&sv.reliable_datagram, svc_setinfo); + MSG_WriteByte (&sv.reliable_datagram, i); + MSG_WriteString (&sv.reliable_datagram, Cmd_Argv(1)); + MSG_WriteString (&sv.reliable_datagram, Info_ValueForKey(host_client->userinfo, Cmd_Argv(1))); + } - if (*Cmd_Argv(1) == '_') - return; - - i = host_client - svs.clients; - MSG_WriteByte (&sv.reliable_datagram, svc_setinfo); - MSG_WriteByte (&sv.reliable_datagram, i); - MSG_WriteString (&sv.reliable_datagram, Cmd_Argv(1)); - MSG_WriteString (&sv.reliable_datagram, Info_ValueForKey(host_client->userinfo, Cmd_Argv(1))); + PR_ClientUserInfoChanged(Cmd_Argv(1), oldval, Info_ValueForKey(host_client->userinfo, Cmd_Argv(1))); } /* @@ -2611,7 +2603,7 @@ void Cmd_Fly_f (void) /* ==================== Host_SetPos_f UDC -By Alex Shadowalker +By Alex Shadowalker (and added to fte because he kept winging) ==================== */ void Cmd_SetPos_f(void) @@ -2652,7 +2644,7 @@ void SetUpClientEdict (client_t *cl, edict_t *ent) ent->v->netname = PR_SetString(svprogfuncs, cl->name); if (pr_teamfield) - ((string_t *)&ent->v)[pr_teamfield] = (string_t)PR_SetString(svprogfuncs, cl->team); + ((string_t *)ent->v)[pr_teamfield] = (string_t)PR_SetString(svprogfuncs, cl->team); ent->v->gravity = cl->entgravity = 1.0; @@ -3424,7 +3416,7 @@ ucmd_t nqucmds[] = {"playermodel", NULL}, {"playerskin", NULL}, - {"rate", NULL}, + {"rate", SV_Rate_f}, #ifdef SVRANKING {"topten", Rank_ListTop10_f}, diff --git a/engine/server/world.c b/engine/server/world.c index 86afdeb1a..b1ea15a45 100644 --- a/engine/server/world.c +++ b/engine/server/world.c @@ -1429,7 +1429,7 @@ void SV_ClipMoveToEntities ( moveclip_t *clip ) int headnode; float *angles; - int passed = EDICT_TO_PROG(svprogfuncs, clip->passedict); + int passed = clip->passedict?EDICT_TO_PROG(svprogfuncs, clip->passedict):NULL; num = SV_AreaEdicts (clip->boxmins, clip->boxmaxs, touchlist , MAX_EDICTS, AREA_SOLID); @@ -1600,12 +1600,18 @@ void SV_ClipToLinks ( areanode_t *node, moveclip_t *clip ) if (clip->type & MOVE_NOMONSTERS && touch->v->solid != SOLID_BSP) continue; - // don't clip corpse against character - if (clip->passedict->v->solid == SOLID_CORPSE && (touch->v->solid == SOLID_SLIDEBOX || touch->v->solid == SOLID_CORPSE)) - continue; - // don't clip character against corpse - if (clip->passedict->v->solid == SOLID_SLIDEBOX && touch->v->solid == SOLID_CORPSE) - continue; + if (clip->passedict) + { + // don't clip corpse against character + if (clip->passedict->v->solid == SOLID_CORPSE && (touch->v->solid == SOLID_SLIDEBOX || touch->v->solid == SOLID_CORPSE)) + continue; + // don't clip character against corpse + if (clip->passedict->v->solid == SOLID_SLIDEBOX && touch->v->solid == SOLID_CORPSE) + continue; + + if (!((int)clip->passedict->v->dimension_hit & (int)touch->v->dimension_solid)) + continue; + } if (clip->boxmins[0] > touch->v->absmax[0] || clip->boxmins[1] > touch->v->absmax[1] @@ -1618,9 +1624,6 @@ void SV_ClipToLinks ( areanode_t *node, moveclip_t *clip ) if (clip->passedict && clip->passedict->v->size[0] && !touch->v->size[0]) continue; // points never interact - if (!((int)clip->passedict->v->dimension_hit & (int)touch->v->dimension_solid)) - continue; - // might intersect, so do an exact clip if (clip->trace.allsolid) return; @@ -1778,7 +1781,7 @@ trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, e memset ( &clip, 0, sizeof ( moveclip_t ) ); - if (passedict->v->hull) + if (passedict && passedict->v->hull) hullnum = passedict->v->hull; else if (sv_compatablehulls.value) hullnum = 0; diff --git a/engine/sw/r_alias.c b/engine/sw/r_alias.c index 10db8107e..f9bd83976 100644 --- a/engine/sw/r_alias.c +++ b/engine/sw/r_alias.c @@ -657,7 +657,7 @@ void R_AliasSetupSkin (void) numskins = paliasskingroup->numskins; fullskininterval = pskinintervals[numskins-1]; - skintime = cl.time + currententity->syncbase; + skintime = cl.time;// + currententity->syncbase; // when loading in Mod_LoadAliasSkinGroup, we guaranteed all interval // values are positive, so we don't have to worry about division by 0 @@ -809,7 +809,7 @@ void R_AliasSetupFrame (void) numframes = paliasgroup->numframes; fullinterval = pintervals[numframes-1]; - time = cl.time + currententity->syncbase; + time = currententity->frame1time; // // when loading in Mod_LoadAliasGroup, we guaranteed all interval values @@ -840,7 +840,7 @@ void R_AliasSetupFrame (void) numframes = paliasgroup->numframes; fullinterval = pintervals[numframes-1]; - time = cl.time + currententity->syncbase; + time = currententity->frame1time; // // when loading in Mod_LoadAliasGroup, we guaranteed all interval values diff --git a/engine/sw/r_main.c b/engine/sw/r_main.c index 491168e4c..7452b95ca 100644 --- a/engine/sw/r_main.c +++ b/engine/sw/r_main.c @@ -681,18 +681,10 @@ void SWR_DrawEntitiesOnList (void) currententity = &cl_visedicts[i]; { - j = currententity->keynum; - while(j) - { - if (j == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1))) - break; - j = cl.lerpents[j].tagent; - } - if (j) - continue; - - if (cl.viewentity[r_refdef.currentplayernum] && currententity->keynum == cl.viewentity[r_refdef.currentplayernum]) + if (currententity->keynum == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1))) continue; +// if (cl.viewentity[r_refdef.currentplayernum] && currententity->keynum == cl.viewentity[r_refdef.currentplayernum]) +// continue; if (!Cam_DrawPlayer(0, currententity->keynum-1)) continue; } diff --git a/engine/sw/r_sprite.c b/engine/sw/r_sprite.c index 5362835b8..8db30db67 100644 --- a/engine/sw/r_sprite.c +++ b/engine/sw/r_sprite.c @@ -259,7 +259,7 @@ mspriteframe_t *R_GetSpriteframe (msprite_t *psprite) numframes = pspritegroup->numframes; fullinterval = pintervals[numframes-1]; - time = cl.time + currententity->syncbase; + time = currententity->frame1time; // when loading in Mod_LoadSpriteGroup, we guaranteed all interval values // are positive, so we don't have to worry about division by 0