From e75cbadc11b96bcc93be84b45ddd114bd2236260 Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 31 Mar 2014 17:06:41 +0000 Subject: [PATCH] fix iqm models. rename some things. don't reload filesystem(twice) when quitting. add savegame_legacy command for saved games that can be loaded in vanilla engines. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4628 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_ents.c | 26 ++-- engine/client/cl_main.c | 1 - engine/client/cl_parse.c | 8 +- engine/client/cl_tent.c | 10 +- engine/client/cl_ui.c | 10 +- engine/client/clq2_ents.c | 14 +- engine/client/m_options.c | 43 +++++- engine/client/pr_csqc.c | 16 +-- engine/client/r_2d.c | 2 +- engine/client/r_surf.c | 14 +- engine/client/view.c | 6 +- engine/common/com_mesh.c | 2 + engine/common/fs.c | 30 ++-- engine/common/protocol.h | 48 +++---- engine/d3d/d3d11_backend.c | 4 +- engine/d3d/d3d_backend.c | 4 +- engine/d3d/vid_d3d.c | 4 +- engine/d3d/vid_d3d11.c | 2 +- engine/dotnet2005/ftequake.vcproj | 2 +- engine/gl/gl_alias.c | 28 ++-- engine/gl/gl_backend.c | 4 +- engine/gl/gl_heightmap.c | 4 +- engine/gl/gl_hlmdl.c | 4 +- engine/gl/gl_rmain.c | 17 +-- engine/gl/glquake.h | 2 - engine/qclib/execloop.h | 29 ++-- engine/qclib/pr_edict.c | 31 ++-- engine/qclib/pr_exec.c | 231 ++++++++++++++++++------------ engine/qclib/progsint.h | 4 +- engine/qclib/qcc_cmdlib.c | 12 +- engine/server/savegame.c | 101 ++++++------- engine/server/sv_main.c | 6 +- engine/sw/sw_rast.c | 2 +- 33 files changed, 418 insertions(+), 303 deletions(-) diff --git a/engine/client/cl_ents.c b/engine/client/cl_ents.c index 60a08f96a..2c73d6e0b 100644 --- a/engine/client/cl_ents.c +++ b/engine/client/cl_ents.c @@ -1627,9 +1627,9 @@ void CL_RotateAroundTag(entity_t *ent, int entnum, int parenttagent, int parentt /*inherit certain properties from the parent entity*/ if (ps->dpflags & RENDER_VIEWMODEL) - ent->flags |= Q2RF_WEAPONMODEL|Q2RF_MINLIGHT|Q2RF_DEPTHHACK; + ent->flags |= RF_WEAPONMODEL|Q2RF_MINLIGHT|RF_DEPTHHACK; if ((ps->dpflags & RENDER_EXTERIORMODEL) || r_refdef.playerview->viewentity == ps->number) - ent->flags |= Q2RF_EXTERNALMODEL; + ent->flags |= RF_EXTERNALMODEL; if (ent->playerindex == -1 && ps->colormap > 0 && ps->colormap <= cl.allocated_client_slots) { @@ -2733,7 +2733,7 @@ void CLQ1_AddPowerupShell(entity_t *ent, qboolean viewweap, unsigned int effects shell->shaderRGBAf[2] *= (effects & EF_BLUE)?1:0; shell->shaderRGBAf[3] *= v_powerupshell.value; /*let the shader do all the work*/ - shell->flags &= ~Q2RF_TRANSLUCENT|Q2RF_ADDITIVE; + shell->flags &= ~RF_TRANSLUCENT|RF_ADDITIVE; } static void CL_LerpNetFrameState(int fsanim, framestate_t *fs, lerpents_t *le) @@ -3409,17 +3409,17 @@ void CL_LinkPacketEntities (void) ent->flags = 0; if (state->dpflags & RENDER_VIEWMODEL) - ent->flags |= Q2RF_WEAPONMODEL|Q2RF_MINLIGHT|Q2RF_DEPTHHACK; + ent->flags |= RF_WEAPONMODEL|Q2RF_MINLIGHT|RF_DEPTHHACK; if ((state->dpflags & RENDER_EXTERIORMODEL) || r_refdef.playerview->viewentity == state->number) - ent->flags |= Q2RF_EXTERNALMODEL; + ent->flags |= RF_EXTERNALMODEL; if (state->effects & NQEF_ADDITIVE) - ent->flags |= Q2RF_ADDITIVE; + ent->flags |= RF_ADDITIVE; if (state->effects & EF_NODEPTHTEST) ent->flags |= RF_NODEPTHTEST; if (state->effects & DPEF_NOSHADOW) ent->flags |= RF_NOSHADOW; if (state->trans != 0xff) - ent->flags |= Q2RF_TRANSLUCENT; + ent->flags |= RF_TRANSLUCENT; /* if (le->origin[2] < r_refdef.waterheight != le->lastorigin[2] < r_refdef.waterheight) { @@ -4451,7 +4451,7 @@ void CL_LinkPlayers (void) ent->shaderRGBAf[2] = state->colourmod[2]/32.0f; ent->shaderRGBAf[3] = state->alpha/255.0f; if (state->alpha != 255) - ent->flags |= Q2RF_TRANSLUCENT; + ent->flags |= RF_TRANSLUCENT; ent->fatness = state->fatness; // @@ -4463,7 +4463,7 @@ void CL_LinkPlayers (void) angles[ROLL] = V_CalcRoll (angles, state->velocity)*4; if (j+1 == r_refdef.playerview->viewentity || (cl.spectator && r_refdef.playerview->cam_locked && r_refdef.playerview->cam_spec_track == j)) - ent->flags |= Q2RF_EXTERNALMODEL; + ent->flags |= RF_EXTERNALMODEL; // the player object gets added with flags | 2 for (pnum = 0; pnum < cl.splitclients; pnum++) { @@ -4637,7 +4637,7 @@ void CL_LinkViewModel(void) ent.shaderRGBAf[3] = alpha; if (alpha != 1) { - ent.flags |= Q2RF_TRANSLUCENT; + ent.flags |= RF_TRANSLUCENT; } ent.model = cl.model_precache[pv->stats[STAT_WEAPON]]; @@ -4675,7 +4675,7 @@ void CL_LinkViewModel(void) ent.framestate.g[FS_REG].lerpfrac = bound(0, ent.framestate.g[FS_REG].lerpfrac, 1); } - ent.flags |= Q2RF_WEAPONMODEL|Q2RF_DEPTHHACK|RF_NOSHADOW; + ent.flags |= RF_WEAPONMODEL|RF_DEPTHHACK|RF_NOSHADOW; plnum = -1; if (cl.spectator) @@ -4700,11 +4700,11 @@ void CL_LinkViewModel(void) "}\n" ); ent.shaderRGBAf[3] = 1; - ent.flags &= ~Q2RF_TRANSLUCENT; + ent.flags &= ~RF_TRANSLUCENT; V_AddEntity(&ent); ent.forcedshader = NULL; ent.shaderRGBAf[3] = alpha; - ent.flags |= Q2RF_TRANSLUCENT; + ent.flags |= RF_TRANSLUCENT; } } diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 54df0659f..2723e65ad 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -342,7 +342,6 @@ void CL_Quit_f (void) M_Menu_Quit_f (); return; }*/ - CL_Disconnect (); Sys_Quit (); } diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index 767d777c0..67eca8949 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -3716,17 +3716,17 @@ void CL_ParseStatic (int version) ent->flags = 0; if (es.dpflags & RENDER_VIEWMODEL) - ent->flags |= Q2RF_WEAPONMODEL|Q2RF_MINLIGHT|Q2RF_DEPTHHACK; + ent->flags |= RF_WEAPONMODEL|Q2RF_MINLIGHT|RF_DEPTHHACK; if (es.dpflags & RENDER_EXTERIORMODEL) - ent->flags |= Q2RF_EXTERNALMODEL; + ent->flags |= RF_EXTERNALMODEL; if (es.effects & NQEF_ADDITIVE) - ent->flags |= Q2RF_ADDITIVE; + ent->flags |= RF_ADDITIVE; if (es.effects & EF_NODEPTHTEST) ent->flags |= RF_NODEPTHTEST; if (es.effects & DPEF_NOSHADOW) ent->flags |= RF_NOSHADOW; if (es.trans != 0xff) - ent->flags |= Q2RF_TRANSLUCENT; + ent->flags |= RF_TRANSLUCENT; VectorCopy (es.origin, ent->origin); VectorCopy (es.angles, ent->angles); diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index 33d89541f..2faf43d48 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -2174,7 +2174,7 @@ void CL_SmokeAndFlash(vec3_t origin) VectorClear(ex->angles); // ex->type = ex_misc; ex->numframes = 4; - ex->flags = Q2RF_TRANSLUCENT; + ex->flags = RF_TRANSLUCENT; ex->alpha = 1; ex->start = cl.time; ex->model = Mod_ForName (q2tentmodels[q2cl_mod_smoke].modelname, MLV_WARN); @@ -2199,7 +2199,7 @@ void CL_Laser (vec3_t start, vec3_t end, int colors) ex->skinnum = (colors >> ((rand() % 4)*8)) & 0xff; VectorCopy (start, ex->origin); VectorCopy (end, ex->oldorigin); - ex->flags = Q2RF_TRANSLUCENT | Q2RF_BEAM; + ex->flags = RF_TRANSLUCENT | Q2RF_BEAM; ex->start = cl.time; ex->framerate = 100; // smoother fading } @@ -2350,7 +2350,7 @@ void CLQ2_ParseTEnt (void) ex->model = Mod_ForName (q2tentmodels[q2cl_mod_explode].modelname, MLV_WARN); ex->firstframe = 0; ex->numframes = 4; - ex->flags = Q2RF_FULLBRIGHT|Q2RF_ADDITIVE|RF_NOSHADOW|Q2RF_TRANSLUCENT; + ex->flags = Q2RF_FULLBRIGHT|RF_ADDITIVE|RF_NOSHADOW|RF_TRANSLUCENT; ex->alpha = 1; ex->angles[0] = acos(dir[2])/M_PI*180; @@ -2438,7 +2438,7 @@ void CLQ2_ParseTEnt (void) ex->model = Mod_ForName (q2tentmodels[q2cl_mod_explo4].modelname, MLV_WARN); ex->firstframe = 30; ex->alpha = 1; - ex->flags |= Q2RF_TRANSLUCENT; + ex->flags |= RF_TRANSLUCENT; ex->numframes = 19; } break; @@ -2532,7 +2532,7 @@ void CLQ2_ParseTEnt (void) ex->start = cl.time; ex->model = Mod_ForName (q2tentmodels[q2cl_mod_explo4].modelname, MLV_WARN); ex->alpha = 1; - ex->flags |= Q2RF_TRANSLUCENT; + ex->flags |= RF_TRANSLUCENT; if (rand()&1) ex->firstframe = 15; else diff --git a/engine/client/cl_ui.c b/engine/client/cl_ui.c index 6ceaa0d70..e6e964dd9 100644 --- a/engine/client/cl_ui.c +++ b/engine/client/cl_ui.c @@ -420,11 +420,11 @@ void VQ3_AddEntity(const q3refEntity_t *q3) ent.forcedshader = VM_FROMSHANDLE(q3->customShader); ent.shaderTime = q3->shaderTime; if (q3->renderfx & Q3RF_FIRST_PERSON) - ent.flags |= Q2RF_WEAPONMODEL; + ent.flags |= RF_WEAPONMODEL; if (q3->renderfx & Q3RF_DEPTHHACK) - ent.flags |= Q2RF_DEPTHHACK; + ent.flags |= RF_DEPTHHACK; if (q3->renderfx & Q3RF_THIRD_PERSON) - ent.flags |= Q2RF_EXTERNALMODEL; + ent.flags |= RF_EXTERNALMODEL; if (q3->renderfx & Q3RF_NOSHADOW) ent.flags |= RF_NOSHADOW; @@ -586,9 +586,9 @@ void VQ3_RenderView(const q3refdef_t *ref) VectorCopy(ref->viewaxis[1], r_refdef.viewaxis[1]); VectorCopy(ref->viewaxis[2], r_refdef.viewaxis[2]); if (ref->rdflags & 1) - r_refdef.flags |= Q2RDF_NOWORLDMODEL; + r_refdef.flags |= RDF_NOWORLDMODEL; else - r_refdef.flags &= ~Q2RDF_NOWORLDMODEL; + r_refdef.flags &= ~RDF_NOWORLDMODEL; r_refdef.fov_x = ref->fov_x; r_refdef.fov_y = ref->fov_y; r_refdef.vrect.x = ref->x; diff --git a/engine/client/clq2_ents.c b/engine/client/clq2_ents.c index 1e283c304..4fc1bb70a 100644 --- a/engine/client/clq2_ents.c +++ b/engine/client/clq2_ents.c @@ -1359,7 +1359,7 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) } // only used for black hole model right now, FIXME: do better - if (renderfx == Q2RF_TRANSLUCENT) + if (renderfx == RF_TRANSLUCENT) ent.shaderRGBAf[3] = 0.70; // render effects (fullbright, translucent, etc) @@ -1408,7 +1408,7 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) { // VectorCopy(cl.predicted_origin, ent.origin); // VectorCopy(cl.predicted_origin, ent.oldorigin); - ent.flags |= Q2RF_EXTERNALMODEL; // only draw from mirrors + ent.flags |= RF_EXTERNALMODEL; // only draw from mirrors if (effects & Q2EF_FLAG1) V_AddLight (ent.keynum, ent.origin, 225, 0.2, 0.05, 0.05); @@ -1426,20 +1426,20 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) if (effects & Q2EF_BFG) { - ent.flags |= Q2RF_TRANSLUCENT; + ent.flags |= RF_TRANSLUCENT; ent.shaderRGBAf[3] = 0.30; } // RAFAEL if (effects & Q2EF_PLASMA) { - ent.flags |= Q2RF_TRANSLUCENT; + ent.flags |= RF_TRANSLUCENT; ent.shaderRGBAf[3] = 0.6; } if (effects & Q2EF_SPHERETRANS) { - ent.flags |= Q2RF_TRANSLUCENT; + ent.flags |= RF_TRANSLUCENT; // PMM - *sigh* yet more EF overloading if (effects & Q2EF_TRACKERTRAIL) ent.shaderRGBAf[3] = 0.6; @@ -1514,7 +1514,7 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) // ent.skin = NULL; // never use a custom skin on others ent.skinnum = 0; - ent.flags &= Q2RF_EXTERNALMODEL; + ent.flags &= RF_EXTERNALMODEL; ent.shaderRGBAf[3] = 1; // duplicate for linked models @@ -1809,7 +1809,7 @@ void CLQ2_AddViewWeapon (q2player_state_t *ps, q2player_state_t *ops) else gun.framestate.g[FS_REG].frame[1] = ops->gunframe; - gun.flags = Q2RF_MINLIGHT | Q2RF_DEPTHHACK | Q2RF_WEAPONMODEL; + gun.flags = Q2RF_MINLIGHT | RF_DEPTHHACK | RF_WEAPONMODEL; gun.framestate.g[FS_REG].lerpfrac = 1-cl.lerpfrac; VectorCopy (gun.origin, gun.oldorigin); // don't lerp at all V_AddEntity (&gun); diff --git a/engine/client/m_options.c b/engine/client/m_options.c index b8b532286..2bdeb2acf 100644 --- a/engine/client/m_options.c +++ b/engine/client/m_options.c @@ -2461,6 +2461,7 @@ void M_Menu_Video_f (void) menu->event = CheckCustomMode; } +#ifndef MINIMAL typedef struct { int skingroup; @@ -2503,6 +2504,20 @@ static unsigned int genhsv(float h_, float s, float v) const char *Mod_FrameNameForNum(model_t *model, int num); const char *Mod_SkinNameForNum(model_t *model, int num); +#include "com_mesh.h" +static void M_BoneDisplay(galiasbone_t *b, int *y, int depth, int parent, int first, int last) +{ + int i; + for (i = first; i < last; i++) + { + if (b[i].parent == parent) + { + Draw_FunString(depth*16, *y, va("%i: %s", i, b[i].name)); + *y += 8; + M_BoneDisplay(b, y, depth+1, i, i+1, last); + } + } +} static void M_ModelViewerDraw(int x, int y, struct menucustom_s *c, struct menu_s *m) { static playerview_t pv; @@ -2525,7 +2540,7 @@ static void M_ModelViewerDraw(int x, int y, struct menucustom_s *c, struct menu_ r_refdef.grect.y = 0; r_refdef.time = realtime; - r_refdef.flags = Q2RDF_NOWORLDMODEL; + r_refdef.flags = RDF_NOWORLDMODEL; r_refdef.afov = 60; r_refdef.fov_x = 0; @@ -2557,7 +2572,6 @@ static void M_ModelViewerDraw(int x, int y, struct menucustom_s *c, struct menu_ } // ent.fatness = sin(realtime)*5; ent.playerindex = -1; - ent.scale = 33.3333; ent.skinnum = mods->skingroup; ent.shaderTime = realtime; ent.framestate.g[FS_REG].frame[0] = mods->framegroup; @@ -2569,14 +2583,29 @@ static void M_ModelViewerDraw(int x, int y, struct menucustom_s *c, struct menu_ V_ApplyRefdef(); R_RenderView(); + y = 0; + fname = Mod_FrameNameForNum(ent.model, mods->framegroup); if (!fname) fname = "Unknown Frame"; - Draw_FunString(0, 0, va("%i: %s", mods->framegroup, fname)); + Draw_FunString(0, y, va("%i: %s", mods->framegroup, fname)); + y+=8; fname = Mod_SkinNameForNum(ent.model, mods->skingroup); if (!fname) fname = "Unknown Skin"; - Draw_FunString(0, 8, va("%i: %s", mods->skingroup, fname)); + Draw_FunString(0, y, va("%i: %s", mods->skingroup, fname)); + y+=8; + + { + int bonecount; + galiasbone_t *b = Mod_GetBoneInfo(ent.model, &bonecount); + if (b && bonecount) + { + Draw_FunString(0, y, va("Bones: ", mods->skingroup, fname)); + y+=8; + M_BoneDisplay(b, &y, 0, -1, 0, bonecount); + } + } } static qboolean M_ModelViewerKey(struct menucustom_s *c, struct menu_s *m, int key) { @@ -2643,6 +2672,12 @@ void M_Menu_ModelViewer_f(void) Q_strncpyz(mv->modelname, Cmd_Argv(1), sizeof(mv->modelname)); Q_strncpyz(mv->forceshader, Cmd_Argv(2), sizeof(mv->forceshader)); } +#else +void M_Menu_ModelViewer_f(void) +{ + Con_Printf("no.\n"); +} +#endif typedef struct { diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index a6d74ebd6..d385a88c3 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -617,13 +617,13 @@ static qboolean CopyCSQCEdictToEntity(csqcedict_t *in, entity_t *out) { rflags = in->xv->renderflags; if (rflags & CSQCRF_VIEWMODEL) - out->flags |= Q2RF_DEPTHHACK|Q2RF_WEAPONMODEL; + out->flags |= RF_DEPTHHACK|RF_WEAPONMODEL; if (rflags & CSQCRF_EXTERNALMODEL) - out->flags |= Q2RF_EXTERNALMODEL; + out->flags |= RF_EXTERNALMODEL; if (rflags & CSQCRF_DEPTHHACK) - out->flags |= Q2RF_DEPTHHACK; + out->flags |= RF_DEPTHHACK; if (rflags & CSQCRF_ADDITIVE) - out->flags |= Q2RF_ADDITIVE; + out->flags |= RF_ADDITIVE; //CSQCRF_USEAXIS is below if (rflags & CSQCRF_NOSHADOW) out->flags |= RF_NOSHADOW; @@ -635,7 +635,7 @@ static qboolean CopyCSQCEdictToEntity(csqcedict_t *in, entity_t *out) effects = in->v->effects; if (effects & NQEF_ADDITIVE) - out->flags |= Q2RF_ADDITIVE; + out->flags |= RF_ADDITIVE; if (effects & DPEF_NOSHADOW) out->flags |= RF_NOSHADOW; if (effects & EF_NODEPTHTEST) @@ -711,7 +711,7 @@ static qboolean CopyCSQCEdictToEntity(csqcedict_t *in, entity_t *out) } else { - out->flags |= Q2RF_TRANSLUCENT; + out->flags |= RF_TRANSLUCENT; out->shaderRGBAf[3] = in->xv->alpha; } @@ -1381,7 +1381,7 @@ static void QCBUILTIN PF_R_GetViewFlag(pubprogfuncs_t *prinst, struct globalvars break; case VF_DRAWWORLD: - *r = !(r_refdef.flags&Q2RDF_NOWORLDMODEL); + *r = !(r_refdef.flags&RDF_NOWORLDMODEL); break; case VF_ENGINESBAR: *r = r_refdef.drawsbar; @@ -1531,7 +1531,7 @@ static void QCBUILTIN PF_R_SetViewFlag(pubprogfuncs_t *prinst, struct globalvars break; case VF_DRAWWORLD: - r_refdef.flags = (r_refdef.flags&~Q2RDF_NOWORLDMODEL) | (*p?0:Q2RDF_NOWORLDMODEL); + r_refdef.flags = (r_refdef.flags&~RDF_NOWORLDMODEL) | (*p?0:RDF_NOWORLDMODEL); break; case VF_ENGINESBAR: r_refdef.drawsbar = !!*p; diff --git a/engine/client/r_2d.c b/engine/client/r_2d.c index a4c592190..3e83eef24 100644 --- a/engine/client/r_2d.c +++ b/engine/client/r_2d.c @@ -916,7 +916,7 @@ void R2D_PolyBlend (void) if (!sw_blend[3]) return; - if (r_refdef.flags & Q2RDF_NOWORLDMODEL) + if (r_refdef.flags & RDF_NOWORLDMODEL) return; R2D_ImageColours (sw_blend[0], sw_blend[1], sw_blend[2], sw_blend[3]); diff --git a/engine/client/r_surf.c b/engine/client/r_surf.c index c2e8588c9..992d99d38 100644 --- a/engine/client/r_surf.c +++ b/engine/client/r_surf.c @@ -1977,7 +1977,7 @@ void Surf_SetupFrame(void) } r_viewcontents = 0; - if (r_refdef.flags & Q2RDF_NOWORLDMODEL) + if (r_refdef.flags & RDF_NOWORLDMODEL) { } else if (!cl.worldmodel || cl.worldmodel->needload || cl.worldmodel->fromgame == fg_doom3 ) @@ -2086,7 +2086,7 @@ void Surf_SetupFrame(void) } #ifdef TERRAIN - if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL) && cl.worldmodel && cl.worldmodel->terrain) + if (!(r_refdef.flags & RDF_NOWORLDMODEL) && cl.worldmodel && cl.worldmodel->terrain) { r_viewcontents |= Heightmap_PointContents(cl.worldmodel, NULL, pvsorg); } @@ -2201,14 +2201,14 @@ void Surf_GenBrushBatches(batch_t **batches, entity_t *ent) } bef = BEF_PUSHDEPTH; - if (ent->flags & Q2RF_ADDITIVE) + if (ent->flags & RF_ADDITIVE) bef |= BEF_FORCEADDITIVE; else if (ent->drawflags & DRF_TRANSLUCENT && r_wateralpha.value != 1) { bef |= BEF_FORCETRANSPARENT; ent->shaderRGBAf[3] = r_wateralpha.value; } - else if (ent->flags & Q2RF_TRANSLUCENT && cls.protocol != CP_QUAKE3) + else if (ent->flags & RF_TRANSLUCENT && cls.protocol != CP_QUAKE3) bef |= BEF_FORCETRANSPARENT; if (ent->flags & RF_NODEPTHTEST) bef |= BEF_FORCENODEPTH; @@ -2265,9 +2265,9 @@ void Surf_DrawWorld (void) qbyte frustumvis_[MAX_MAP_LEAFS/8]; RSpeedLocals(); - if (r_refdef.flags & Q2RDF_NOWORLDMODEL) + if (r_refdef.flags & RDF_NOWORLDMODEL) { - r_refdef.flags |= Q2RDF_NOWORLDMODEL; + r_refdef.flags |= RDF_NOWORLDMODEL; BE_DrawWorld(false, NULL); return; } @@ -2365,7 +2365,7 @@ void Surf_DrawWorld (void) } } - if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL)) + if (!(r_refdef.flags & RDF_NOWORLDMODEL)) { CL_LinkStaticEntities(entvis); TRACE(("dbg: calling R_DrawParticles\n")); diff --git a/engine/client/view.c b/engine/client/view.c index 544c6a076..7d624b380 100644 --- a/engine/client/view.c +++ b/engine/client/view.c @@ -1168,11 +1168,11 @@ int CL_EditExternalModels(int newviewentity, entity_t *viewentities, int maxview for (i = 0; i < cl_numvisedicts; ) { if (cl_visedicts[i].keynum == newviewentity && newviewentity) - cl_visedicts[i].flags |= Q2RF_EXTERNALMODEL; + cl_visedicts[i].flags |= RF_EXTERNALMODEL; else - cl_visedicts[i].flags &= ~Q2RF_EXTERNALMODEL; + cl_visedicts[i].flags &= ~RF_EXTERNALMODEL; - if (cl_visedicts[i].flags & Q2RF_WEAPONMODEL) + if (cl_visedicts[i].flags & RF_WEAPONMODEL) { if (viewents < maxviewenties) viewentities[viewents++] = cl_visedicts[i]; diff --git a/engine/common/com_mesh.c b/engine/common/com_mesh.c index 4199ea1e8..82fe33f54 100644 --- a/engine/common/com_mesh.c +++ b/engine/common/com_mesh.c @@ -2473,6 +2473,8 @@ shader_t *Mod_LoadSkinFile(char *defaultshadername, galiasinfo_t *surf, int skin Q_strncpyz(shadername, defaultshadername?defaultshadername:surf->surfacename, sizeof(shadername)); shader = Mod_ShaderFromQ3SkinFile(shadername, surf, loadmodel->name, skinnumber, outskinname); + if (!shader) + shader = R_RegisterSkin(defaultshadername, loadmodel->name); if (!shader) shader = R_RegisterSkin(surf->surfacename, loadmodel->name); if (shader) diff --git a/engine/common/fs.c b/engine/common/fs.c index 9e93fbf35..112bfa1e4 100644 --- a/engine/common/fs.c +++ b/engine/common/fs.c @@ -1372,10 +1372,14 @@ vfsfile_t *FS_OpenVFS(const char *filename, const char *mode, enum fs_relative r if (vfs) return vfs; } - snprintf(fullname, sizeof(fullname), "%s%s/%s", com_gamepath, gamedirfile, filename); - if (*mode == 'w') - COM_CreatePath(fullname); - return VFSOS_Open(fullname, mode); + if (*gamedirfile) + { + snprintf(fullname, sizeof(fullname), "%s%s/%s", com_gamepath, gamedirfile, filename); + if (*mode == 'w') + COM_CreatePath(fullname); + return VFSOS_Open(fullname, mode); + } + return NULL; case FS_GAME: //load from paks in preference to system paths. overwriting be damned. case FS_PUBBASEGAMEONLY: //load from paks in preference to system paths. overwriting be damned. FS_NativePath(filename, relativeto, fullname, sizeof(fullname)); @@ -2533,6 +2537,13 @@ void FS_PureMode(int puremode, char *packagenames, char *packagecrcs, int purese { qboolean pureflush; + if (puremode == fs_puremode && fs_pureseed == pureseed) + { + if ((!packagenames && !fs_purenames) || !strcmp(fs_purenames?fs_purenames:"", packagenames?packagenames:"")) + if ((!packagecrcs && !fs_purecrcs) || !strcmp(fs_purecrcs?fs_purecrcs:"", packagecrcs?packagecrcs:"")) + return; + } + Z_Free(fs_purenames); Z_Free(fs_purecrcs); @@ -3663,11 +3674,14 @@ qboolean FS_ChangeGame(ftemanifest_t *man, qboolean allowreloadconfigs) } } - if (!builtingame && !fixedbasedir && !FS_DirHasAPackage(newbasedir, man)) - if (Sys_FindGameData(man->formalname, man->installation, realpath, sizeof(realpath))) - Q_strncpyz (newbasedir, realpath, sizeof(newbasedir)); + if (allowreloadconfigs) + { + if (!builtingame && !fixedbasedir && !FS_DirHasAPackage(newbasedir, man)) + if (Sys_FindGameData(man->formalname, man->installation, realpath, sizeof(realpath))) + Q_strncpyz (newbasedir, realpath, sizeof(newbasedir)); - Q_strncpyz (com_gamepath, newbasedir, sizeof(com_gamepath)); + Q_strncpyz (com_gamepath, newbasedir, sizeof(com_gamepath)); + } //make sure it has a trailing slash, or is empty. woo. FS_CleanDir(com_gamepath, sizeof(com_gamepath)); diff --git a/engine/common/protocol.h b/engine/common/protocol.h index 81d7bb115..ef94a29ea 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -1124,40 +1124,40 @@ typedef struct q1usercmd_s // entity_state_t->renderfx flags -#define Q2RF_MINLIGHT 1 // always have some light (viewmodel) -#define Q2RF_EXTERNALMODEL 2 // don't draw through eyes, only mirrors -#define Q2RF_WEAPONMODEL 4 // only draw through eyes -#define Q2RF_FULLBRIGHT 8 // always draw full intensity -#define Q2RF_DEPTHHACK 16 // for view weapon Z crunching -#define Q2RF_TRANSLUCENT 32 -#define Q2RF_FRAMELERP 64 -#define Q2RF_BEAM 128 +#define Q2RF_MINLIGHT (1u<<0) //ni always have some light (viewmodel) +#define RF_EXTERNALMODEL (1u<<1) //i don't draw through eyes, only mirrors +#define RF_WEAPONMODEL (1u<<2) //i only draw through eyes +#define Q2RF_FULLBRIGHT (1u<<3) //i always draw full intensity +#define RF_DEPTHHACK (1u<<4) //i for view weapon Z crunching +#define RF_TRANSLUCENT (1u<<5) //forces shader sort order and BEF_FORCETRANSPARENT +#define Q2RF_FRAMELERP (1u<<6) //q2only +#define Q2RF_BEAM (1u<<7) //mostly q2only -#define Q2RF_CUSTOMSKIN 256 // skin is an index in image_precache -#define Q2RF_GLOW 512 // pulse lighting for bonus items -#define Q2RF_SHELL_RED 1024 -#define Q2RF_SHELL_GREEN 2048 -#define Q2RF_SHELL_BLUE 4096 +#define Q2RF_CUSTOMSKIN (1u<<8) //not even in q2 skin is an index in image_precache +#define Q2RF_GLOW (1u<<9) //i pulse lighting for bonus items +#define Q2RF_SHELL_RED (1u<<10) //q2only +#define Q2RF_SHELL_GREEN (1u<<11) //q2only +#define Q2RF_SHELL_BLUE (1u<<12) //q2only //ROGUE -#define Q2RF_IR_VISIBLE 0x00008000 // 32768 -#define Q2RF_SHELL_DOUBLE 0x00010000 // 65536 -#define Q2RF_SHELL_HALF_DAM 0x00020000 -#define Q2RF_USE_DISGUISE 0x00040000 +#define Q2RF_IR_VISIBLE (1u<<15) // shows red with Q2RDF_IRGOGGLES +#define Q2RF_SHELL_DOUBLE (1u<<16) //q2only +#define Q2RF_SHELL_HALF_DAM (1u<<17) //q2only +#define Q2RF_USE_DISGUISE (1u<<18) //ni entity is displayed with skin 'players/$MODEL/disguise.pcx' instead //ROGUE -#define Q2RF_ADDITIVE 0x00080000 -#define RF_NOSHADOW 0x00100000 -#define RF_NODEPTHTEST 0x00200000 -#define RF_FORCECOLOURMOD 0x00400000 +#define RF_ADDITIVE (1u<<19) //forces shader sort order and BEF_FORCEADDITIVE +#define RF_NOSHADOW (1u<<20) //disables shadow casting +#define RF_NODEPTHTEST (1u<<21) //forces shader sort order and BEF_FORCENODEPTH +#define RF_FORCECOLOURMOD (1u<<22) //forces BEF_FORCECOLOURMOD // player_state_t->refdef flags #define Q2RDF_UNDERWATER 1 // warp the screen as apropriate -#define Q2RDF_NOWORLDMODEL 2 // used for player configuration screen +#define RDF_NOWORLDMODEL 2 // used for player configuration screen //ROGUE -#define Q2RDF_IRGOGGLES 4 -#define Q2RDF_UVGOGGLES 8 +#define Q2RDF_IRGOGGLES 4 //ents with Q2RF_IR_VISIBLE show up pure red. +#define Q2RDF_UVGOGGLES 8 //usused / reserved //ROGUE diff --git a/engine/d3d/d3d11_backend.c b/engine/d3d/d3d11_backend.c index d183a0947..6d9f9da5d 100644 --- a/engine/d3d/d3d11_backend.c +++ b/engine/d3d/d3d11_backend.c @@ -2795,7 +2795,7 @@ static void BE_RotateForEntity (const entity_t *e, const model_t *mod) VectorScale((m+8), mod->clampscale, (m+8)); } - if (e->flags & Q2RF_WEAPONMODEL) + if (e->flags & RF_WEAPONMODEL) { /*FIXME: no bob*/ float iv[16]; @@ -2861,7 +2861,7 @@ static void BE_RotateForEntity (const entity_t *e, const model_t *mod) ID3D11DeviceContext_Unmap(d3ddevctx, (ID3D11Resource*)shaderstate.ecbuffers[shaderstate.ecbufferidx], 0); - ndr = (e->flags & Q2RF_DEPTHHACK)?0.333:1; + ndr = (e->flags & RF_DEPTHHACK)?0.333:1; if (ndr != shaderstate.depthrange) { D3D11_VIEWPORT vport; diff --git a/engine/d3d/d3d_backend.c b/engine/d3d/d3d_backend.c index 3a076d60d..018e84e9d 100644 --- a/engine/d3d/d3d_backend.c +++ b/engine/d3d/d3d_backend.c @@ -2666,7 +2666,7 @@ static void BE_RotateForEntity (const entity_t *e, const model_t *mod) VectorScale((m+8), mod->clampscale, (m+8)); } - if (e->flags & Q2RF_WEAPONMODEL) + if (e->flags & RF_WEAPONMODEL) { /*FIXME: no bob*/ float iv[16]; @@ -2686,7 +2686,7 @@ static void BE_RotateForEntity (const entity_t *e, const model_t *mod) { D3DVIEWPORT9 vport; IDirect3DDevice9_GetViewport(pD3DDev9, &vport); - vport.MaxZ = (e->flags & Q2RF_DEPTHHACK)?0.333:1; + vport.MaxZ = (e->flags & RF_DEPTHHACK)?0.333:1; IDirect3DDevice9_SetViewport(pD3DDev9, &vport); } } diff --git a/engine/d3d/vid_d3d.c b/engine/d3d/vid_d3d.c index d4c842a10..25e367a81 100644 --- a/engine/d3d/vid_d3d.c +++ b/engine/d3d/vid_d3d.c @@ -1185,14 +1185,14 @@ static void (D3D9_R_RenderView) (void) D3D9_SetupViewPortProjection(); - if (r_clear.ival && !(r_refdef.flags & Q2RDF_NOWORLDMODEL)) + if (r_clear.ival && !(r_refdef.flags & RDF_NOWORLDMODEL)) d3d9error(IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,0,0), 1, 0)); else d3d9error(IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1, 0)); R_SetFrustum (r_refdef.m_projection, r_refdef.m_view); RQ_BeginFrame(); - if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL)) + if (!(r_refdef.flags & RDF_NOWORLDMODEL)) { if (cl.worldmodel) P_DrawParticles (); diff --git a/engine/d3d/vid_d3d11.c b/engine/d3d/vid_d3d11.c index 68ce7bb0a..89a134ac2 100644 --- a/engine/d3d/vid_d3d11.c +++ b/engine/d3d/vid_d3d11.c @@ -1388,7 +1388,7 @@ static void (D3D11_R_RenderView) (void) // P_DrawParticles (); // } - if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL)) + if (!(r_refdef.flags & RDF_NOWORLDMODEL)) if (!r_worldentity.model || r_worldentity.model->needload || !cl.worldmodel) { D3D11_Set2D (); diff --git a/engine/dotnet2005/ftequake.vcproj b/engine/dotnet2005/ftequake.vcproj index b43122362..a6f9f711e 100644 --- a/engine/dotnet2005/ftequake.vcproj +++ b/engine/dotnet2005/ftequake.vcproj @@ -1479,7 +1479,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="../libs/speex;..\client;../libs/freetype2/include;../common;../server;../gl;../sw;../qclib;../libs;../libs/dxsdk9/include;../libs/dxsdk7/include" - PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;GLQUAKE;D3D9QUAKE;D3D11QUAKE;SWQUAKE;MULTITHREAD" + PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;GLQUAKE;D3D9QUAKE;D3D11QUAKE;SWQUAKE;MULTITHREAD;USE_MSVCRT_DEBUG" BasicRuntimeChecks="3" RuntimeLibrary="1" FloatingPointModel="2" diff --git a/engine/gl/gl_alias.c b/engine/gl/gl_alias.c index 257b83414..a5fc91e30 100644 --- a/engine/gl/gl_alias.c +++ b/engine/gl/gl_alias.c @@ -1123,9 +1123,9 @@ qboolean R_CalcModelLighting(entity_t *e, model_t *clmodel) return e->light_known-1; } - if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL)) + if (!(r_refdef.flags & RDF_NOWORLDMODEL)) { - if (e->flags & Q2RF_WEAPONMODEL) + if (e->flags & RF_WEAPONMODEL) { cl.worldmodel->funcs.LightPointValues(cl.worldmodel, r_refdef.vieworg, shadelight, ambientlight, lightdir); for (i = 0; i < 3; i++) @@ -1255,7 +1255,7 @@ qboolean R_CalcModelLighting(entity_t *e, model_t *clmodel) e->light_dir[1] = DotProduct(lightdir, e->axis[1]); e->light_dir[2] = DotProduct(lightdir, e->axis[2]); - if (e->flags & Q2RF_WEAPONMODEL) + if (e->flags & RF_WEAPONMODEL) { vec3_t temp; temp[0] = DotProduct(e->light_dir, vpn); @@ -1340,7 +1340,7 @@ void R_GAlias_GenerateBatches(entity_t *e, batch_t **batches) texnums_t *skin; - if ((r_refdef.externalview || r_refdef.recurse) && e->flags & Q2RF_WEAPONMODEL) + if ((r_refdef.externalview || r_refdef.recurse) && e->flags & RF_WEAPONMODEL) return; clmodel = e->model; @@ -1355,7 +1355,7 @@ void R_GAlias_GenerateBatches(entity_t *e, batch_t **batches) } } - if (!(e->flags & Q2RF_WEAPONMODEL) + if (!(e->flags & RF_WEAPONMODEL) #ifdef SKELETALMODELS && !e->framestate.bonestate #endif @@ -1415,13 +1415,13 @@ void R_GAlias_GenerateBatches(entity_t *e, batch_t **batches) sort = shader->sort; if (e->flags & RF_FORCECOLOURMOD) b->flags |= BEF_FORCECOLOURMOD; - if (e->flags & Q2RF_ADDITIVE) + if (e->flags & RF_ADDITIVE) { b->flags |= BEF_FORCEADDITIVE; if (sort < SHADER_SORT_ADDITIVE) sort = SHADER_SORT_ADDITIVE; } - if (e->flags & Q2RF_TRANSLUCENT) + if (e->flags & RF_TRANSLUCENT) { b->flags |= BEF_FORCETRANSPARENT; if (SHADER_SORT_PORTAL < sort && sort < SHADER_SORT_BLEND) @@ -2051,7 +2051,7 @@ static void R_DB_Sprite(batch_t *batch) return; } - if (e->flags & Q2RF_WEAPONMODEL && r_refdef.playerview->viewentity > 0) + if (e->flags & RF_WEAPONMODEL && r_refdef.playerview->viewentity > 0) { sprorigin[0] = r_refdef.playerview->vw_origin[0]; sprorigin[1] = r_refdef.playerview->vw_origin[1]; @@ -2089,7 +2089,7 @@ static void R_DB_Sprite(batch_t *batch) { case SPR_ORIENTED: // bullet marks on walls - if ((e->flags & Q2RF_WEAPONMODEL) && r_refdef.playerview->viewentity > 0) + if ((e->flags & RF_WEAPONMODEL) && r_refdef.playerview->viewentity > 0) { vec3_t ea[3]; AngleVectors (e->angles, ea[0], ea[1], ea[2]); @@ -2217,13 +2217,13 @@ static void R_Sprite_GenerateBatch(entity_t *e, batch_t **batches, void (*drawfu b->flags = 0; sort = shader->sort; - if (e->flags & Q2RF_ADDITIVE) + if (e->flags & RF_ADDITIVE) { b->flags |= BEF_FORCEADDITIVE; if (sort < SHADER_SORT_ADDITIVE) sort = SHADER_SORT_ADDITIVE; } - if (e->flags & Q2RF_TRANSLUCENT || (gl_blendsprites.ival && drawfunc == R_DB_Sprite)) + if (e->flags & RF_TRANSLUCENT || (gl_blendsprites.ival && drawfunc == R_DB_Sprite)) { b->flags |= BEF_FORCETRANSPARENT; if (SHADER_SORT_PORTAL < sort && sort < SHADER_SORT_BLEND) @@ -2322,7 +2322,7 @@ void BE_GenModelBatches(batch_t **batches, const dlight_t *dl, unsigned int bemo batches[i] = NULL; #if defined(TERRAIN) - if (cl.worldmodel && cl.worldmodel->terrain && !(r_refdef.flags & Q2RDF_NOWORLDMODEL)) + if (cl.worldmodel && cl.worldmodel->terrain && !(r_refdef.flags & RDF_NOWORLDMODEL)) Terr_DrawTerrainModel(batches, &r_worldentity); #endif @@ -2345,12 +2345,12 @@ void BE_GenModelBatches(batch_t **batches, const dlight_t *dl, unsigned int bemo { ent = &cl_visedicts[i]; - if (!r_refdef.externalview && (ent->flags & Q2RF_EXTERNALMODEL)) + if (!r_refdef.externalview && (ent->flags & RF_EXTERNALMODEL)) continue; if (bemode == BEM_STENCIL || bemode == BEM_DEPTHONLY) { - if (ent->flags & (RF_NOSHADOW | Q2RF_ADDITIVE | RF_NODEPTHTEST | Q2RF_TRANSLUCENT)) //noshadow often isn't enough for legacy content. + if (ent->flags & (RF_NOSHADOW | RF_ADDITIVE | RF_NODEPTHTEST | RF_TRANSLUCENT)) //noshadow often isn't enough for legacy content. continue; if (ent->keynum == dl->key && ent->keynum) //shadows are not cast from the entity that owns the light. it is expected to be inside. continue; diff --git a/engine/gl/gl_backend.c b/engine/gl/gl_backend.c index 1fa76cdd7..a1b0126e9 100644 --- a/engine/gl/gl_backend.c +++ b/engine/gl/gl_backend.c @@ -3367,7 +3367,7 @@ void GLBE_SelectEntity(entity_t *ent) if (qglLoadMatrixf) qglLoadMatrixf(shaderstate.modelviewmatrix); - if (shaderstate.curentity->flags & Q2RF_DEPTHHACK) + if (shaderstate.curentity->flags & RF_DEPTHHACK) nd = 0.3; else nd = 1; @@ -3812,7 +3812,7 @@ static void DrawMeshes(void) { if (!shaderstate.allblackshader) { - char *defs[] = {NULL}; + const char *defs[] = {NULL}; shaderstate.allblackshader = GLSlang_CreateProgram("allblackprogram", gl_config.gles?100:110, defs, "#include \"sys/skeletal.h\"\nvoid main(){gl_Position = skeletaltransform();}", "void main(){gl_FragColor=vec4(0.0,0.0,0.0,1.0);}", false, NULL); shaderstate.allblack_mvp = qglGetUniformLocationARB(shaderstate.allblackshader, "m_modelviewprojection"); } diff --git a/engine/gl/gl_heightmap.c b/engine/gl/gl_heightmap.c index 558adf213..6c96c73a6 100644 --- a/engine/gl/gl_heightmap.c +++ b/engine/gl/gl_heightmap.c @@ -2624,10 +2624,10 @@ void Terr_DrawInBounds(struct tdibctx *ctx, int x, int y, int w, int h) if (a >= 1) { a = 1; - s->ents[i].flags &= ~Q2RF_TRANSLUCENT; + s->ents[i].flags &= ~RF_TRANSLUCENT; } else - s->ents[i].flags |= Q2RF_TRANSLUCENT; + s->ents[i].flags |= RF_TRANSLUCENT; s->ents[i].shaderRGBAf[3] = a; switch(model->type) { diff --git a/engine/gl/gl_hlmdl.c b/engine/gl/gl_hlmdl.c index 9959380fe..b42d6b314 100644 --- a/engine/gl/gl_hlmdl.c +++ b/engine/gl/gl_hlmdl.c @@ -730,13 +730,13 @@ void R_HalfLife_WalkMeshes(entity_t *rent, batch_t *b, batch_t **batches) //fixme: we probably need to force some blend modes based on the surface flags. if (rent->flags & RF_FORCECOLOURMOD) b->flags |= BEF_FORCECOLOURMOD; - if (rent->flags & Q2RF_ADDITIVE) + if (rent->flags & RF_ADDITIVE) { b->flags |= BEF_FORCEADDITIVE; if (sort < SHADER_SORT_ADDITIVE) sort = SHADER_SORT_ADDITIVE; } - if (rent->flags & Q2RF_TRANSLUCENT) + if (rent->flags & RF_TRANSLUCENT) { b->flags |= BEF_FORCETRANSPARENT; if (SHADER_SORT_PORTAL < sort && sort < SHADER_SORT_BLEND) diff --git a/engine/gl/gl_rmain.c b/engine/gl/gl_rmain.c index 8e86e6f1f..bf2163fb4 100644 --- a/engine/gl/gl_rmain.c +++ b/engine/gl/gl_rmain.c @@ -230,7 +230,7 @@ void GL_SetupSceneProcessingTextures (void) void R_RotateForEntity (float *m, float *modelview, const entity_t *e, const model_t *mod) { - if ((e->flags & Q2RF_WEAPONMODEL) && r_refdef.playerview->viewentity > 0) + if ((e->flags & RF_WEAPONMODEL) && r_refdef.playerview->viewentity > 0) { float em[16]; float vm[16]; @@ -464,10 +464,7 @@ void R_SetupGL (float stereooffset) } else { - if (gl_maxdist.value>=1) - Matrix4x4_CM_Orthographic(r_refdef.m_projection, -fov_x/2, fov_x/2, -fov_y/2, fov_y/2, -gl_maxdist.value, gl_maxdist.value); - else - Matrix4x4_CM_Orthographic(r_refdef.m_projection, -fov_x/2, fov_x/2, -fov_y/2, fov_y/2, -9999, 9999); + Matrix4x4_CM_Orthographic(r_refdef.m_projection, -fov_x/2, fov_x/2, -fov_y/2, fov_y/2, 0, gl_maxdist.value>=1?gl_maxdist.value:9999); } newa[0] = r_refdef.viewangles[0]; @@ -522,7 +519,7 @@ void R_RenderScene (void) int i; int tmpvisents = cl_numvisedicts; /*world rendering is allowed to add additional ents, but we don't want to keep them for recursive views*/ if (!cl.worldmodel || (!cl.worldmodel->nodes && cl.worldmodel->type != mod_heightmap)) - r_refdef.flags |= Q2RDF_NOWORLDMODEL; + r_refdef.flags |= RDF_NOWORLDMODEL; stereomode = r_stereo_method.ival; if (stereomode == 1) @@ -1174,7 +1171,7 @@ void R_Clear (void) /*tbh, this entire function should be in the backend*/ GL_ForceDepthWritable(); { - if (r_clear.ival && R_GameRectIsFullscreen() && !(r_refdef.flags & Q2RDF_NOWORLDMODEL)) + if (r_clear.ival && R_GameRectIsFullscreen() && !(r_refdef.flags & RDF_NOWORLDMODEL)) { qglClearColor(1, 0, 0, 0); qglClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -1485,7 +1482,7 @@ void GLR_RenderView (void) if (r_norefresh.value || !vid.pixelwidth || !vid.pixelheight) return; - if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL)) + if (!(r_refdef.flags & RDF_NOWORLDMODEL)) { //FIXME: fbo stuff if (!r_worldentity.model || r_worldentity.model->needload || !cl.worldmodel) @@ -1570,7 +1567,7 @@ void GLR_RenderView (void) time1 = Sys_DoubleTime (); } - if (!dofbo && !(r_refdef.flags & Q2RDF_NOWORLDMODEL) && R_RenderScene_Cubemap()) + if (!dofbo && !(r_refdef.flags & RDF_NOWORLDMODEL) && R_RenderScene_Cubemap()) { } @@ -1611,7 +1608,7 @@ void GLR_RenderView (void) //FIXME: support bloom+waterwarp even when drawing to an fbo? //FIXME: force waterwarp to a temp fbo always - if ((r_refdef.flags & Q2RDF_NOWORLDMODEL) || dofbo) + if ((r_refdef.flags & RDF_NOWORLDMODEL) || dofbo) return; if (!R_GameRectIsFullscreen()) diff --git a/engine/gl/glquake.h b/engine/gl/glquake.h index b5873f18a..fa87779b7 100644 --- a/engine/gl/glquake.h +++ b/engine/gl/glquake.h @@ -72,8 +72,6 @@ extern r_config_t r_config; #define GLclampd GLclampf #define GLdouble GLfloat #define GL_NONE 0 - - #define GL_QUADS (Sys_Error("GL_QUADS was used"),0) #elif defined(__MACOSX__) //apple, you suck. #include diff --git a/engine/qclib/execloop.h b/engine/qclib/execloop.h index a8c9c1990..9da0b53fa 100644 --- a/engine/qclib/execloop.h +++ b/engine/qclib/execloop.h @@ -646,6 +646,8 @@ reeval: progfuncs->funcs.callargc = OPCODE - OP_CALL0; fnum = OPA->function; + glob = NULL; //try to derestrict it. + callerprogs=pr_typecurrent; //so we can revert to the right caller. newpr = (fnum & 0xff000000)>>24; //this is the progs index of the callee fnum &= ~0xff000000; //the callee's function index. @@ -678,6 +680,8 @@ reeval: /*calling a builtin in another progs may affect that other progs' globals instead, is the theory anyway, so args and stuff need to move over*/ if (pr_typecurrent != 0) { + //builtins quite hackily refer to only a single global. + //for builtins to affect the globals of other progs, we need to first switch to the progs that it will affect, so they'll be correct when we switch back PR_SwitchProgsParms(progfuncs, 0); } i = -newf->first_statement; @@ -710,18 +714,17 @@ reeval: // memcpy(&pr_progstate[p].globals[OFS_RETURN], ¤t_progstate->globals[OFS_RETURN], sizeof(vec3_t)); PR_SwitchProgsParms(progfuncs, (progsnum_t)callerprogs); - //#ifndef DEBUGABLE //decide weather non debugger wants to start debugging. + //decide weather non debugger wants to start debugging. s = st-pr_statements; - goto restart; - //#endif - // break; + return s; } // PR_SwitchProgsParms((OPA->function & 0xff000000)>>24); s = PR_EnterFunction (progfuncs, newf, callerprogs); st = &pr_statements[s]; } - goto restart; + //resume at the new statement, which might be in a different progs + return s; // break; case OP_DONE: @@ -729,9 +732,9 @@ reeval: RUNAWAYCHECK(); - pr_globals[OFS_RETURN] = pr_globals[st->a]; - pr_globals[OFS_RETURN+1] = pr_globals[st->a+1]; - pr_globals[OFS_RETURN+2] = pr_globals[st->a+2]; + glob[OFS_RETURN] = glob[st->a]; + glob[OFS_RETURN+1] = glob[st->a+1]; + glob[OFS_RETURN+2] = glob[st->a+2]; /* { static char buffer[1024*1024*8]; @@ -743,9 +746,9 @@ reeval: st = &pr_statements[s]; if (pr_depth == prinst.exitdepth) { - return; // all done + return -1; // all done } - goto restart; + return s; // break; case OP_STATE: @@ -913,7 +916,7 @@ reeval: { PR_RunError(&progfuncs->funcs, "array index out of bounds: %s[%d] (max %d)", PR_GlobalStringNoContents(progfuncs, st->a), i, ((eval_t *)&glob[st->a-1])->_int); } - t = (eval_t *)&pr_globals[(uofs)st->a + i]; + t = (eval_t *)&glob[(uofs)st->a + i]; OPC->_int = t->_int; break; case OP_FETCH_GBL_V: @@ -923,7 +926,7 @@ reeval: pr_xstatement = st-pr_statements; PR_RunError(&progfuncs->funcs, "array index out of bounds: %s[%d]", PR_GlobalStringNoContents(progfuncs, st->a), i); } - t = (eval_t *)&pr_globals[(uofs)st->a + i*3]; + t = (eval_t *)&glob[(uofs)st->a + i*3]; OPC->_vector[0] = t->_vector[0]; OPC->_vector[1] = t->_vector[1]; OPC->_vector[2] = t->_vector[2]; @@ -1227,7 +1230,7 @@ reeval: if (st == pr_statements + s) PR_RunError(&progfuncs->funcs, "unable to resume boundcheck"); st = pr_statements + s; - goto restart; + return s; } break; /* case OP_PUSH: diff --git a/engine/qclib/pr_edict.c b/engine/qclib/pr_edict.c index 26873aff9..9251c41e5 100644 --- a/engine/qclib/pr_edict.c +++ b/engine/qclib/pr_edict.c @@ -727,48 +727,49 @@ char *PR_UglyOldValueString (progfuncs_t *progfuncs, etype_t type, eval_t *val) switch (type) { case ev_struct: - sprintf (line, "structures cannot yet be saved"); + QC_snprintfz (line, sizeof(line), "structures cannot yet be saved"); break; case ev_union: - sprintf (line, "unions cannot yet be saved"); + QC_snprintfz (line, sizeof(line), "unions cannot yet be saved"); break; case ev_string: - sprintf (line, "%s", PR_StringToNative(&progfuncs->funcs, val->string)); + //FIXME: we should probably add markup. vanilla does _not_, so we can expect problems reloading anyway. + QC_snprintfz (line, sizeof(line), "%s", PR_StringToNative(&progfuncs->funcs, val->string)); break; case ev_entity: - sprintf (line, "%i", NUM_FOR_EDICT(progfuncs, (struct edict_s *)PROG_TO_EDICT(progfuncs, val->edict))); + QC_snprintfz (line, sizeof(line), "%i", NUM_FOR_EDICT(progfuncs, (struct edict_s *)PROG_TO_EDICT(progfuncs, val->edict))); break; case ev_function: f = pr_progstate[(val->function & 0xff000000)>>24].functions + (val->function & ~0xff000000); - sprintf (line, "%s", f->s_name+progfuncs->funcs.stringtable); + QC_snprintfz (line, sizeof(line), "%s", f->s_name+progfuncs->funcs.stringtable); break; case ev_field: fielddef = ED_FieldAtOfs (progfuncs, val->_int ); - sprintf (line, "%s", fielddef->name); + QC_snprintfz (line, sizeof(line), "%s", fielddef->name); break; case ev_void: - sprintf (line, "void"); + QC_snprintfz (line, sizeof(line), "void"); break; case ev_float: if (val->_float == (int)val->_float) - sprintf (line, "%i", (int)val->_float); //an attempt to cut down on the number of .000000 vars.. + QC_snprintfz (line, sizeof(line), "%i", (int)val->_float); //an attempt to cut down on the number of .000000 vars.. else - sprintf (line, "%f", val->_float); + QC_snprintfz (line, sizeof(line), "%f", val->_float); break; case ev_integer: - sprintf (line, "%i", val->_int); + QC_snprintfz (line, sizeof(line), "%i", val->_int); break; case ev_vector: if (val->_vector[0] == (int)val->_vector[0] && val->_vector[1] == (int)val->_vector[1] && val->_vector[2] == (int)val->_vector[2]) - sprintf (line, "%i %i %i", (int)val->_vector[0], (int)val->_vector[1], (int)val->_vector[2]); + QC_snprintfz (line, sizeof(line), "%i %i %i", (int)val->_vector[0], (int)val->_vector[1], (int)val->_vector[2]); else - sprintf (line, "%f %f %f", val->_vector[0], val->_vector[1], val->_vector[2]); + QC_snprintfz (line, sizeof(line), "%f %f %f", val->_vector[0], val->_vector[1], val->_vector[2]); break; case ev_pointer: QC_snprintfz (line, sizeof(line), "%#x", val->_int); break; default: - sprintf (line, "bad type %i", type); + QC_snprintfz (line, sizeof(line), "bad type %i", type); break; } @@ -1578,7 +1579,7 @@ char *SaveCallStack (progfuncs_t *progfuncs, char *buf, int *bufofs, int bufmax) { #define AddS(str) PR_Cat(buf, str, bufofs, bufmax) char buffer[8192]; - dfunction_t *f; + const dfunction_t *f; int i; int progs; @@ -1707,7 +1708,7 @@ char *PDECL PR_SaveEnts(pubprogfuncs_t *ppf, char *buf, int *bufofs, int bufmax, AddS ("{\n"); - if (!ed->isfree) + if (!ed->isfree) //free entities write a {} with no data. the loader detects this specifically. ED_WriteEdict(progfuncs, ed, buf, bufofs, bufmax, true); AddS ("}\n"); diff --git a/engine/qclib/pr_exec.c b/engine/qclib/pr_exec.c index 452aacb8f..5e0b91219 100644 --- a/engine/qclib/pr_exec.c +++ b/engine/qclib/pr_exec.c @@ -2,6 +2,14 @@ #include "progsint.h" //#include "editor.h" +#if __STDC_VERSION__ >= 199901L + #define fte_restrict restrict +#elif defined(_MSC_VER) + #define fte_restrict __restrict +#else + #define fte_restrict +#endif + #define HunkAlloc BADGDFG sdfhhsf FHS @@ -234,7 +242,7 @@ char *QC_ucase(char *str) void PDECL PR_StackTrace (pubprogfuncs_t *ppf) { progfuncs_t *progfuncs = (progfuncs_t *)ppf; - dfunction_t *f; + const dfunction_t *f; int i; int progs; @@ -414,7 +422,7 @@ PR_EnterFunction Returns the new program statement counter ==================== */ -int ASMCALL PR_EnterFunction (progfuncs_t *progfuncs, dfunction_t *f, int progsnum) +int ASMCALL PR_EnterFunction (progfuncs_t *progfuncs, const dfunction_t *f, int progsnum) { int i, j, c, o; @@ -888,7 +896,7 @@ void SetExecutionToLine(progfuncs_t *progfuncs, int linenum) { int pn = pr_typecurrent; int snum; - dfunction_t *f = pr_xfunction; + const dfunction_t *f = pr_xfunction; switch(current_progstate->structtype) { @@ -1096,7 +1104,7 @@ static char *lastfile = 0; int pn = pr_typecurrent; int i; - dfunction_t *f = pr_xfunction; + const dfunction_t *f = pr_xfunction; if (!externs->useeditor) { @@ -1150,28 +1158,126 @@ static char *lastfile = 0; return statement; } -//DMW: all pointer functions are modified to be absoloute pointers from NULL not sv_edicts +#define RUNAWAYCHECK() \ + if (!--*runaway) \ + { \ + pr_xstatement = st-pr_statements; \ + PR_RunError (&progfuncs->funcs, "runaway loop error\n");\ + PR_StackTrace(&progfuncs->funcs); \ + printf ("runaway loop error\n"); \ + while(pr_depth > prinst.exitdepth) \ + PR_LeaveFunction(progfuncs); \ + pr_spushed = 0; \ + return -1; \ + } + +static int PR_ExecuteCode16 (progfuncs_t *fte_restrict progfuncs, int s, int *fte_restrict runaway) +{ + eval_t *t, *swtch=NULL; + + int swtchtype = 0; //warning about not being initialized before use + dstatement16_t *fte_restrict st16; + dfunction_t *fte_restrict newf; + int i; + edictrun_t *ed; + eval_t *ptr; + + float *fte_restrict glob = pr_globals; + float tmpf; + int tmpi; + +#define OPA ((eval_t *)&glob[st->a]) +#define OPB ((eval_t *)&glob[st->b]) +#define OPC ((eval_t *)&glob[st->c]) + +#define INTSIZE 16 + st16 = &pr_statements16[s]; + while (progfuncs->funcs.pr_trace || prinst.watch_ptr) + { +#ifdef FTE_TARGET_WEB + //this can generate huge functions, so disable it on systems that can't realiably cope with such things (IE initiates an unwanted denial-of-service attack when pointed our javascript, and firefox prints a warning too) + pr_xstatement = st-pr_statements; + PR_RunError (&progfuncs->funcs, "runaway loop error\n"); + PR_StackTrace(&progfuncs->funcs); + return -1; +#else + #define DEBUGABLE + #ifdef SEPARATEINCLUDES + #include "execloop16d.h" + #else + #include "execloop.h" + #endif + #undef DEBUGABLE +#endif + } + + while(1) + { + #include "execloop.h" + } +#undef INTSIZE +} + +static int PR_ExecuteCode32 (progfuncs_t *fte_restrict progfuncs, int s, int *fte_restrict runaway) +{ + eval_t *t, *swtch=NULL; + + int swtchtype = 0; //warning about not being initialized before use + const dstatement32_t *fte_restrict st32; + const dfunction_t *fte_restrict newf; + int i; + edictrun_t *ed; + eval_t *ptr; + + float *fte_restrict glob = pr_globals; + float tmpf; + int tmpi; + +#define OPA ((eval_t *)&glob[st->a]) +#define OPB ((eval_t *)&glob[st->b]) +#define OPC ((eval_t *)&glob[st->c]) + +#define INTSIZE 32 + st32 = &pr_statements32[s]; + while (progfuncs->funcs.pr_trace || prinst.watch_ptr) + { +#ifdef FTE_TARGET_WEB + //this can generate huge functions, so disable it on systems that can't realiably cope with such things (IE initiates an unwanted denial-of-service attack when pointed our javascript, and firefox prints a warning too) + pr_xstatement = st-pr_statements; + PR_RunError (&progfuncs->funcs, "runaway loop error\n"); + PR_StackTrace(&progfuncs->funcs); + return -1; +#else + #define DEBUGABLE + #ifdef SEPARATEINCLUDES + #include "execloop32d.h" + #else + #include "execloop.h" + #endif + #undef DEBUGABLE +#endif + } + + while(1) + { + #ifdef SEPARATEINCLUDES + #include "execloop32.h" + #else + #include "execloop.h" + #endif + } +#undef INTSIZE +} + /* ==================== PR_ExecuteProgram ==================== */ -void PR_ExecuteCode (progfuncs_t *progfuncs, int s) +static void PR_ExecuteCode (progfuncs_t *progfuncs, int s) { - eval_t *t, *swtch=NULL; - int swtchtype = 0; //warning about not being initialized before use - dstatement16_t *st16; - dstatement32_t *st32; - dfunction_t *newf; int runaway; - int i; - edictrun_t *ed; - eval_t *ptr; - - float *glob; - float tmpf; - int tmpi; if (prinst.watch_ptr && prinst.watch_ptr->_int != prinst.watch_old._int) { @@ -1207,78 +1313,25 @@ void PR_ExecuteCode (progfuncs_t *progfuncs, int s) runaway = 100000000; -#define PRBOUNDSCHECK -#define RUNAWAYCHECK() \ - if (!--runaway) \ - { \ - pr_xstatement = st-pr_statements; \ - PR_RunError (&progfuncs->funcs, "runaway loop error\n");\ - PR_StackTrace(&progfuncs->funcs); \ - printf ("runaway loop error\n"); \ - while(pr_depth > prinst.exitdepth) \ - PR_LeaveFunction(progfuncs); \ - pr_spushed = 0; \ - return; \ - } - -#define OPA ((eval_t *)&glob[st->a]) -#define OPB ((eval_t *)&glob[st->b]) -#define OPC ((eval_t *)&glob[st->c]) - -restart: //jumped to when the progs might have changed. - glob = pr_globals; - switch (current_progstate->structtype) + for(;;) { - case PST_DEFAULT: - case PST_QTEST: -#define INTSIZE 16 - st16 = &pr_statements16[s]; - while (progfuncs->funcs.pr_trace || prinst.watch_ptr) + switch (current_progstate->structtype) { - #define DEBUGABLE - #ifdef SEPARATEINCLUDES - #include "execloop16d.h" - #else - #include "execloop.h" - #endif - #undef DEBUGABLE + case PST_DEFAULT: + case PST_QTEST: + s = PR_ExecuteCode16(progfuncs, s, &runaway); + if (s == -1) + return; + continue; + case PST_KKQWSV: + case PST_FTE32: + s = PR_ExecuteCode32(progfuncs, s, &runaway); + if (s == -1) + return; + continue; + default: + Sys_Error("PR_ExecuteProgram - bad structtype"); } - - while(1) - { - #include "execloop.h" - } -#undef INTSIZE - Sys_Error("PR_ExecuteProgram - should be unreachable"); - break; - case PST_KKQWSV: - case PST_FTE32: -#define INTSIZE 32 - st32 = &pr_statements32[s]; - while (progfuncs->funcs.pr_trace || prinst.watch_ptr) - { - #define DEBUGABLE - #ifdef SEPARATEINCLUDES - #include "execloop32d.h" - #else - #include "execloop.h" - #endif - #undef DEBUGABLE - } - - while(1) - { - #ifdef SEPARATEINCLUDES - #include "execloop32.h" - #else - #include "execloop.h" - #endif - } -#undef INTSIZE - Sys_Error("PR_ExecuteProgram - should be unreachable"); - break; - default: - Sys_Error("PR_ExecuteProgram - bad structtype"); } } @@ -1395,7 +1448,7 @@ struct qcthread_s *PDECL PR_ForkStack(pubprogfuncs_t *ppf) int ed = prinst.exitdepth; int localsoffset, baselocalsoffset; qcthread_t *thread = externs->memalloc(sizeof(qcthread_t)); - dfunction_t *f; + const dfunction_t *f; //copy out the functions stack. for (i = 0,localsoffset=0; i < ed; i++) @@ -1460,7 +1513,7 @@ struct qcthread_s *PDECL PR_ForkStack(pubprogfuncs_t *ppf) void PDECL PR_ResumeThread (pubprogfuncs_t *ppf, struct qcthread_s *thread) { progfuncs_t *progfuncs = (progfuncs_t*)ppf; - dfunction_t *f, *oldf; + const dfunction_t *f, *oldf; int i,l,ls; progsnum_t initial_progs; int oldexitdepth; diff --git a/engine/qclib/progsint.h b/engine/qclib/progsint.h index 93c1d5870..7d330d86b 100644 --- a/engine/qclib/progsint.h +++ b/engine/qclib/progsint.h @@ -61,7 +61,7 @@ typedef struct sharedvar_s typedef struct { int s; - dfunction_t *f; + const dfunction_t *f; int progsnum; int pushed; } prstack_t; @@ -129,7 +129,7 @@ int reorganisefields; int continuestatement; int exitdepth; - dfunction_t *pr_xfunction; + const dfunction_t *pr_xfunction; #define pr_xfunction prinst.pr_xfunction int pr_xstatement; #define pr_xstatement prinst.pr_xstatement diff --git a/engine/qclib/qcc_cmdlib.c b/engine/qclib/qcc_cmdlib.c index 645dc5f3e..0d9e3a936 100644 --- a/engine/qclib/qcc_cmdlib.c +++ b/engine/qclib/qcc_cmdlib.c @@ -261,12 +261,22 @@ skipwhite: c = '\n'; data++; } + else if (c=='\\' && *data == 'r') + { // and do mac lines while we're at it. + c = '\r'; + data++; + } + else if (c=='\\' && *data == 't') + { // and do tabs while we're at it. + c = '\t'; + data++; + } else if (c=='\"') { qcc_token[len] = 0; return (char*)data; } - else if (c=='\0'||c=='\n') + else if (c=='\0') //\n does not terminate the string. that would break compatibility with vanilla saved games { qcc_token[len] = 0; return (char*)data; diff --git a/engine/server/savegame.c b/engine/server/savegame.c index c135e5d10..3d04bc95a 100644 --- a/engine/server/savegame.c +++ b/engine/server/savegame.c @@ -2,15 +2,13 @@ #ifndef CLIENTONLY -//#ifdef _DEBUG -#define NEWSAVEFORMAT -//#endif - extern cvar_t skill; extern cvar_t deathmatch; extern cvar_t coop; extern cvar_t teamplay; +void SV_Savegame_f (void); + //Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current void SV_SavegameComment (char *text) { @@ -333,8 +331,7 @@ void SV_Loadgame_Legacy(char *filename, vfsfile_t *f, int version) } } -#ifndef NEWSAVEFORMAT -void SV_Savegame_f (void) +void SV_LegacySavegame_f (void) { int len; char *s = NULL; @@ -343,14 +340,15 @@ void SV_Savegame_f (void) int version = SAVEGAME_VERSION; - char name[256]; - FILE *f; + char native[MAX_OSPATH]; + char name[MAX_QPATH]; + vfsfile_t *f; int i; char comment[SAVEGAME_COMMENT_LENGTH+1]; if (Cmd_Argc() != 2) { - Con_Printf ("save : save a game\n"); + Con_TPrintf ("save : save a game\n"); return; } @@ -362,25 +360,35 @@ void SV_Savegame_f (void) if (sv.state != ss_active) { - Con_Printf("Can't apply: Server isn't running or is still loading\n"); + Con_TPrintf("Can't apply: Server isn't running or is still loading\n"); return; } - sprintf (name, "%s/saves/%s", com_gamedir, Cmd_Argv(1)); - COM_DefaultExtension (name, ".sav"); + if (sv.allocated_client_slots != 1 || svs.clients->state != cs_spawned) + { + //we don't care about fte-format legacy. + Con_TPrintf("Unable to use legacy savegame format to save multiplayer games\n"); + SV_Savegame_f(); + return; + } - Con_TPrintf ("Saving game to %s...\n", name); - f = fopen (name, "w"); + sprintf (name, "%s", Cmd_Argv(1)); + COM_DefaultExtension (name, ".sav", sizeof(name)); + + if (!FS_NativePath(name, FS_GAMEONLY, native, sizeof(native))) + return; + Con_TPrintf (U8("Saving game to %s...\n"), native); + f = FS_OpenVFS(name, "wb", FS_GAMEONLY); if (!f) { - Con_TPrintf ("ERROR: couldn't open %s.\n", filename); + Con_TPrintf ("ERROR: couldn't open %s.\n", name); return; } //if there are 1 of 1 players connected - if (sv.allocated_client_slots == 1 && svs.clients->state < cs_spawned) + if (sv.allocated_client_slots == 1 && svs.clients->state == cs_spawned) {//try to go for nq/zq compatability as this is a single player game. - s = PR_SaveEnts(svprogfuncs, NULL, &len, 2); //get the entity state now, so that we know if we can get the full state in a q1 format. + s = PR_SaveEnts(svprogfuncs, NULL, &len, 0, 2); //get the entity state now, so that we know if we can get the full state in a q1 format. if (s) { if (progstype == PROG_QW) @@ -391,61 +399,58 @@ void SV_Savegame_f (void) } - fprintf (f, "%i\n", version); + VFS_PRINTF(f, "%i\n", version); SV_SavegameComment (comment); - fprintf (f, "%s\n", comment); + VFS_PRINTF(f, "%s\n", comment); if (version != SAVEGAME_VERSION) { - for (i=0; ispawn_parms[i]); //client 1. - fprintf (f, "%f\n", skill.value); + //only 16 spawn parms. + for (i=0; i < 16; i++) + VFS_PRINTF(f, "%f\n", svs.clients->spawn_parms[i]); //client 1. + VFS_PRINTF(f, "%f\n", skill.value); } else { - fprintf(f, "%i\n", sv.allocated_client_slots); + VFS_PRINTF(f, "%i\n", sv.allocated_client_slots); for (cl = svs.clients, clnum=0; clnum < sv.allocated_client_slots; cl++,clnum++) { if (cl->state < cs_spawned && !cl->istobeloaded) //don't save if they are still connecting { - fprintf(f, "\"\"\n"); + VFS_PRINTF(f, "\"\"\n"); continue; } - fprintf(f, "\"%s\"\n", cl->name); + VFS_PRINTF(f, "\"%s\"\n", cl->name); for (i=0; ispawn_parms[i]); + VFS_PRINTF(f, "%f\n", cl->spawn_parms[i]); } - fprintf (f, "%i\n", progstype); - fprintf (f, "%f\n", skill.value); - fprintf (f, "%f\n", deathmatch.value); - fprintf (f, "%f\n", coop.value); - fprintf (f, "%f\n", teamplay.value); + VFS_PRINTF(f, "%i\n", progstype); + VFS_PRINTF(f, "%f\n", skill.value); + VFS_PRINTF(f, "%f\n", deathmatch.value); + VFS_PRINTF(f, "%f\n", coop.value); + VFS_PRINTF(f, "%f\n", teamplay.value); } - fprintf (f, "%s\n", sv.name); - fprintf (f, "%f\n",sv.time); + VFS_PRINTF(f, "%s\n", sv.name); + VFS_PRINTF(f, "%f\n",sv.time); -// write the light styles - - for (i=0 ; iparms->memfree(s); - fclose (f); - Con_TPrintf (STL_SAVEDONE); - - SV_BroadcastTPrintf(2, STL_GAMESAVED); + VFS_CLOSE(f); } -#endif @@ -963,8 +968,6 @@ void SV_SaveLevelCache(char *savedir, qboolean dontharmgame) VFS_CLOSE (f); } -#ifdef NEWSAVEFORMAT - #define FTESAVEGAME_VERSION 25000 void SV_Savegame (char *savename) @@ -1336,5 +1339,3 @@ void SV_Loadgame_f (void) sv.spawned_client_slots += loadzombies; } #endif - -#endif diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 4ac970d48..df1ad1ea9 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef CLIENTONLY #define Q2EDICT_NUM(i) (q2edict_t*)((char *)ge->edicts+i*ge->edict_size) +void SV_LegacySavegame_f(void); void SV_Savegame_f (void); void SV_Loadgame_f (void); #define INVIS_CHAR1 12 @@ -3128,9 +3129,9 @@ client_t *SVC_DirectConnect(void) if (((!strcmp(cl->name, name) || !*cl->name) && (!*cl->guid || !strcmp(guid, cl->guid))) || sv.allocated_client_slots <= 1) //named, or first come first serve. { if (cl->istobeloaded) - Con_Printf("%s:Using loadzombie\n", sv.name); + Con_DPrintf("%s:Using loadzombie\n", sv.name); else - Con_Printf("%s:Using parmzombie\n", sv.name); + Con_DPrintf("%s:Using parmzombie\n", sv.name); newcl = cl; preserveparms = true; temp.istobeloaded = cl->istobeloaded; @@ -5255,6 +5256,7 @@ void SV_InitLocal (void) Cmd_AddCommand ("openroute", SV_OpenRoute_f); + Cmd_AddCommand ("savegame_legacy", SV_LegacySavegame_f); Cmd_AddCommand ("savegame", SV_Savegame_f); Cmd_AddCommand ("loadgame", SV_Loadgame_f); Cmd_AddCommand ("save", SV_Savegame_f); diff --git a/engine/sw/sw_rast.c b/engine/sw/sw_rast.c index 2b04dce23..621dbf134 100644 --- a/engine/sw/sw_rast.c +++ b/engine/sw/sw_rast.c @@ -847,7 +847,7 @@ void SW_R_RenderView(void) vec3_t newa; int tmpvisents = cl_numvisedicts; /*world rendering is allowed to add additional ents, but we don't want to keep them for recursive views*/ if (!cl.worldmodel || (!cl.worldmodel->nodes && cl.worldmodel->type != mod_heightmap)) - r_refdef.flags |= Q2RDF_NOWORLDMODEL; + r_refdef.flags |= RDF_NOWORLDMODEL; // R_SetupGL ();