From a5f08a4734a056fa35adae01e80fceddca2da0f3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 11 Jan 2020 18:50:38 +0100 Subject: [PATCH 01/51] - fixed Shadow Warrior save game loading from the main menu. --- source/sw/src/save.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/sw/src/save.cpp b/source/sw/src/save.cpp index 3ee26f112..22447e94a 100644 --- a/source/sw/src/save.cpp +++ b/source/sw/src/save.cpp @@ -1278,10 +1278,10 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) + LoadGameOutsideMoveLoop = TRUE; if (!InMenuLevel) { ready2send = 1; - LoadGameOutsideMoveLoop = TRUE; } else ExitLevel = TRUE; return true; From 17eddda36ccef028d4914b4031dcebb634735f24 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 11 Jan 2020 19:40:35 +0100 Subject: [PATCH 02/51] - added date and play time display to savegames. --- source/common/menu/savegamemanager.cpp | 4 ++-- source/common/savegamehelp.cpp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/common/menu/savegamemanager.cpp b/source/common/menu/savegamemanager.cpp index d57af7785..fb2334d19 100644 --- a/source/common/menu/savegamemanager.cpp +++ b/source/common/menu/savegamemanager.cpp @@ -379,8 +379,8 @@ unsigned FSavegameManager::ExtractSaveData(int index) FString comment = sjson_get_string(root, "Creation Time", ""); FString fcomment = sjson_get_string(root, "Map Label", ""); FString ncomment = sjson_get_string(root, "Map Name", ""); - FStringf pcomment("%s - %s\n", fcomment.GetChars(), ncomment.GetChars()); - comment += pcomment; + FString mtime = sjson_get_string(root, "Map Time", ""); + comment.AppendFormat("\n%s - %s\n%s", fcomment.GetChars(), ncomment.GetChars(), mtime.GetChars()); SaveCommentString = comment; // Extract pic (todo: let the renderer write a proper PNG file instead of a raw canvas dunp of the software renderer - and make it work for all games.) diff --git a/source/common/savegamehelp.cpp b/source/common/savegamehelp.cpp index 29d6e7025..84f681e2e 100644 --- a/source/common/savegamehelp.cpp +++ b/source/common/savegamehelp.cpp @@ -143,9 +143,13 @@ void G_WriteSaveHeader(const char *name) sjson_put_string(ctx, root, "Engine", savesig.savesig); sjson_put_string(ctx, root, "Game Resource", fileSystem.GetResourceFileName(1)); sjson_put_string(ctx, root, "Map Name", currentLevel->DisplayName()); + sjson_put_string(ctx, root, "Creation Time", myasctime()); sjson_put_string(ctx, root, "Title", name); sjson_put_string(ctx, root, "Map File", currentLevel->fileName); sjson_put_string(ctx, root, "Map Label", currentLevel->labelName); + auto gs = gi->getStats(); + FStringf timeStr("%02d:%02d", gs.timesecnd / 60, gs.timesecnd % 60); + sjson_put_string(ctx, root, "Map Time", timeStr); const char *fn = currentLevel->fileName; if (*fn == '/') fn++; if (strncmp(fn, "file://", 7) != 0) // this only has meaning for non-usermaps From 55dab6d3d31043bfc162896f07651288032d3198 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 11 Jan 2020 22:18:06 +0100 Subject: [PATCH 03/51] - hooked up the high color texture colorization code. Not tested and probably still not working correctly, the entire feature was a nearly impenetrable mess of convoluted code. This definitely needs verification with multiple mods using it. --- source/blood/src/view.cpp | 36 +++++------ source/build/include/hightile.h | 18 ++---- source/build/src/hightile.cpp | 14 ++--- source/build/src/mdsprite.cpp | 2 - source/build/src/polymost.cpp | 35 +++-------- source/build/src/voxmodel.cpp | 3 - source/duke3d/src/screens.cpp | 24 +++---- source/glbackend/gl_renderstate.h | 3 + source/glbackend/gl_shader.cpp | 3 + source/glbackend/gl_shader.h | 4 ++ source/glbackend/gl_texture.cpp | 19 +++++- source/glbackend/glbackend.cpp | 3 + source/glbackend/glbackend.h | 8 ++- source/rr/src/screens.cpp | 24 +++---- wadsrc/static/engine/shaders/glsl/polymost.fp | 63 +++++++++++-------- 15 files changed, 131 insertions(+), 128 deletions(-) diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index e8ca71404..87a1b9c97 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -2877,29 +2877,29 @@ void UpdateDacs(int nPalette, bool bNoTint) { case 0: default: - tint->r = 255; - tint->g = 255; - tint->b = 255; + tint->tint.r = 255; + tint->tint.g = 255; + tint->tint.b = 255; break; case 1: - tint->r = 132; - tint->g = 164; - tint->b = 255; + tint->tint.r = 132; + tint->tint.g = 164; + tint->tint.b = 255; break; case 2: - tint->r = 255; - tint->g = 126; - tint->b = 105; + tint->tint.r = 255; + tint->tint.g = 126; + tint->tint.b = 105; break; case 3: - tint->r = 162; - tint->g = 186; - tint->b = 15; + tint->tint.r = 162; + tint->tint.g = 186; + tint->tint.b = 15; break; case 4: - tint->r = 255; - tint->g = 255; - tint->b = 255; + tint->tint.r = 255; + tint->tint.g = 255; + tint->tint.b = 255; break; } if (!bNoTint) @@ -3709,9 +3709,9 @@ void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b) #ifdef USE_OPENGL // XXX: this makes us also load all hightile textures tinted with the crosshair color! polytint_t & crosshairtint = hictinting[CROSSHAIR_PAL]; - crosshairtint.r = CrosshairColors.r; - crosshairtint.g = CrosshairColors.g; - crosshairtint.b = CrosshairColors.b; + crosshairtint.tint.r = CrosshairColors.r; + crosshairtint.tint.g = CrosshairColors.g; + crosshairtint.tint.b = CrosshairColors.b; crosshairtint.f = HICTINT_USEONART | HICTINT_GRAYSCALE; #endif tileInvalidate(kCrosshairTile, -1, -1); diff --git a/source/build/include/hightile.h b/source/build/include/hightile.h index 8168cd669..c3e26e24f 100644 --- a/source/build/include/hightile.h +++ b/source/build/include/hightile.h @@ -1,21 +1,16 @@ #ifndef HIGHTILE_PRIV_H #define HIGHTILE_PRIV_H +#include "palentry.h" + typedef struct { polytintflags_t f; - uint8_t r, g, b; - uint8_t sr, sg, sb; + PalEntry tint; + PalEntry shade; } polytint_t; extern polytint_t hictinting[MAXPALOOKUPS]; -static inline void globaltinting_apply(float *color) -{ - color[0] *= (float)globalr * (1.f/255.f); - color[1] *= (float)globalg * (1.f/255.f); - color[2] *= (float)globalb * (1.f/255.f); -} - // replacement flags enum @@ -39,11 +34,8 @@ enum HICTINT_BLEND_HARDLIGHT = 3<<6, HICTINT_BLENDMASK = 64|128, - + HICTINT_ALWAYSUSEART = 256, HICTINT_PRECOMPUTED = HICTINT_COLORIZE | HICTINT_BLENDMASK, - HICTINT_IN_MEMORY = HICTINT_PRECOMPUTED | HICTINT_GRAYSCALE | HICTINT_INVERT, - - HICTINT_MEMORY_COMBINATIONS = 1<<5, }; #endif diff --git a/source/build/src/hightile.cpp b/source/build/src/hightile.cpp index 8708850f2..a2d6a7ded 100644 --- a/source/build/src/hightile.cpp +++ b/source/build/src/hightile.cpp @@ -24,7 +24,7 @@ void hicinit(void) for (i=0; i= (uint32_t)MAXPALOOKUPS) return; polytint_t & tint = hictinting[palnum]; - tint.r = r; - tint.g = g; - tint.b = b; - tint.sr = sr; - tint.sg = sg; - tint.sb = sb; + tint.tint.r = r; + tint.tint.g = g; + tint.tint.b = b; + tint.shade.r = sr; + tint.shade.g = sg; + tint.shade.b = sb; tint.f = effect; } diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index 6e3dd2059..4ff6a24b8 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -1591,8 +1591,6 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) // tinting pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * hw_shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades; - auto h = hictinting[globalpal]; - GLInterface.SetTinting(h.f, PalEntry(h.sr, h.sg, h.sb), PalEntry(h.r, h.g, h.b)); pc[3] = (tspr->cstat&2) ? glblend[tspr->blend].def[!!(tspr->cstat&512)].alpha : 1.0f; pc[3] *= 1.0f - sext->alpha; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index e61f006c1..9b42e38de 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -532,7 +532,6 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 else if (drawpoly_trepeat) sampleroverride = SamplerClampX; else sampleroverride = SamplerClampXY; - bool success = GLInterface.SetTexture(globalpicnum, TileFiles.tiles[globalpicnum], globalpal, method, sampleroverride); if (!success) { @@ -560,16 +559,6 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 GLInterface.SetNpotEmulation(false, 1.f, 0.f); } - vec2f_t hacksc = { 1.f, 1.f }; - -#if 0 - if (pth->flags & PTH_HIGHTILE) - { - hacksc = pth->scale; - tsiz = pth->siz; - } -#endif - vec2_t tsiz2 = tsiz; @@ -580,28 +569,18 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 float pc[4]; - polytint_t const& tint = hictinting[globalpal]; - // This makes no sense. - pc[0] = 1.f;// (1.f - (tint.sr * (1.f / 255.f))) + (tint.sr * (1.f / 255.f)); - pc[1] = 1.f;// (1.f - (tint.sg * (1.f / 255.f))) + (tint.sg * (1.f / 255.f)); - pc[2] = 1.f;// (1.f - (tint.sb * (1.f / 255.f))) + (tint.sb * (1.f / 255.f)); - - // spriteext full alpha control - pc[3] = float_trans(method & DAMETH_MASKPROPS, drawpoly_blend) * (1.f - drawpoly_alpha); - - // tinting - auto& h = hictinting[globalpal]; - - GLInterface.SetTinting(h.f, PalEntry(h.sr, h.sg, h.sb), PalEntry(h.r, h.g, h.b)); - - globaltinting_apply(pc); + // The shade rgb from the tint is ignored here. + pc[0] = (float)globalr * (1.f / 255.f); + pc[1] = (float)globalg * (1.f / 255.f); + pc[2] = (float)globalb * (1.f / 255.f); + pc[3] = float_trans(method & DAMETH_MASKPROPS, drawpoly_blend) * (1.f - drawpoly_alpha); if (skyzbufferhack_pass) pc[3] = 0.01f; GLInterface.SetColor(pc[0], pc[1], pc[2], pc[3]); - vec2f_t const scale = { 1.f / tsiz2.x * hacksc.x, 1.f / tsiz2.y * hacksc.y }; + vec2f_t const scale = { 1.f / tsiz2.x, 1.f / tsiz2.y }; auto data = GLInterface.AllocVertices(npoints); auto vt = data.second; for (bssize_t i = 0; i < npoints; ++i, vt++) @@ -3237,7 +3216,7 @@ void polymost_drawrooms() // This is a global setting for the entire scene, so let's do it here, right at the start. auto& hh = hictinting[MAXPALOOKUPS - 1]; // This sets a tinting color for global palettes, e.g. water or slime - only used for hires replacements (also an option for low-resource hardware where duplicating the textures may be problematic.) - GLInterface.SetBasepalTint(PalEntry(hh.r, hh.g, hh.b)); + GLInterface.SetBasepalTint(hh.tint); polymost_outputGLDebugMessage(3, "polymost_drawrooms()"); diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 6abefb81d..af5789e13 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -1082,9 +1082,6 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * hw_shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades; - auto& h = hictinting[globalpal]; - GLInterface.SetTinting(h.f, PalEntry(h.sr, h.sg, h.sb), PalEntry(h.r, h.g, h.b)); - if (!shadowHack) { pc[3] = (tspr->cstat & 2) ? glblend[tspr->blend].def[!!(tspr->cstat & 512)].alpha : 1.0f; diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 328e87ca5..5436ed35f 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -166,9 +166,9 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b) #ifdef USE_OPENGL // XXX: this makes us also load all hightile textures tinted with the crosshair color! polytint_t & crosshairtint = hictinting[CROSSHAIR_PAL]; - crosshairtint.r = CrosshairColors.r; - crosshairtint.g = CrosshairColors.g; - crosshairtint.b = CrosshairColors.b; + crosshairtint.tint.r = CrosshairColors.r; + crosshairtint.tint.g = CrosshairColors.g; + crosshairtint.tint.b = CrosshairColors.b; crosshairtint.f = HICTINT_USEONART | HICTINT_GRAYSCALE; #endif tileInvalidate(CROSSHAIR, -1, -1); @@ -761,23 +761,23 @@ void G_DisplayRest(int32_t smoothratio) if (pp->palette == WATERPAL) { - fstint.r = 224; - fstint.g = 192; - fstint.b = 255; + fstint.tint.r = 224; + fstint.tint.g = 192; + fstint.tint.b = 255; fstint.f = 0; } else if (pp->palette == SLIMEPAL) { - fstint.r = 208; - fstint.g = 255; - fstint.b = 192; + fstint.tint.r = 208; + fstint.tint.g = 255; + fstint.tint.b = 192; fstint.f = 0; } else { - fstint.r = 255; - fstint.g = 255; - fstint.b = 255; + fstint.tint.r = 255; + fstint.tint.g = 255; + fstint.tint.b = 255; fstint.f = 0; } } diff --git a/source/glbackend/gl_renderstate.h b/source/glbackend/gl_renderstate.h index 4f623e672..997bea5bf 100644 --- a/source/glbackend/gl_renderstate.h +++ b/source/glbackend/gl_renderstate.h @@ -35,6 +35,7 @@ enum PRSFlags RF_HICTINT_BLEND_Overlay = 0x100000, RF_HICTINT_BLEND_Hardlight = 0x200000, RF_HICTINT_BLENDMASK = RF_HICTINT_BLEND_Screen | RF_HICTINT_BLEND_Overlay | RF_HICTINT_BLEND_Hardlight, + RF_HICTINT_MASK = 0x3f0000, STF_BLEND = 1, STF_COLORMASK = 2, @@ -68,6 +69,8 @@ struct PolymostRenderState bool AlphaTest = true; float Color[4] = { 1,1,1,1 }; short matrixIndex[NUMMATRICES] = { -1,-1,-1,-1,-1 }; + PalEntry fullscreenTint = 0xffffff, hictint = 0, hictint_overlay = 0xffffff; + int hictint_flags = 0; int StateFlags = STF_COLORMASK|STF_DEPTHMASK; FRenderStyle Style{}; diff --git a/source/glbackend/gl_shader.cpp b/source/glbackend/gl_shader.cpp index d8fba3470..256732a98 100644 --- a/source/glbackend/gl_shader.cpp +++ b/source/glbackend/gl_shader.cpp @@ -144,6 +144,9 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char Brightness.Init(hShader, "u_brightness"); FogColor.Init(hShader, "u_fogColor"); AlphaThreshold.Init(hShader, "u_alphaThreshold"); + TintModulate.Init(hShader, "u_tintModulate"); + TintOverlay.Init(hShader, "u_tintOverlay"); + TintFlags.Init(hShader, "u_tintFlags"); RotMatrix.Init(hShader, "u_rotMatrix"); ModelMatrix.Init(hShader, "u_modelMatrix"); diff --git a/source/glbackend/gl_shader.h b/source/glbackend/gl_shader.h index 03cbeabfa..538958f37 100644 --- a/source/glbackend/gl_shader.h +++ b/source/glbackend/gl_shader.h @@ -45,6 +45,10 @@ public: FBufferedUniform1f Brightness; FBufferedUniform1f AlphaThreshold; FBufferedUniformPalEntry FogColor; + FBufferedUniformPalEntry TintModulate; + FBufferedUniformPalEntry TintOverlay; + FBufferedUniform1i TintFlags; + FUniformMatrix4f RotMatrix; FUniformMatrix4f ModelMatrix; diff --git a/source/glbackend/gl_texture.cpp b/source/glbackend/gl_texture.cpp index ff963c068..1b36948c2 100644 --- a/source/glbackend/gl_texture.cpp +++ b/source/glbackend/gl_texture.cpp @@ -164,24 +164,37 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int int lookuppal = 0; VSMatrix texmat; - auto rep = hw_hightile? tex->FindReplacement(palette) : nullptr; + auto& h = hictinting[palette]; + bool applytint = false; + auto rep = (hw_hightile && !(h.f & HICTINT_ALWAYSUSEART)) ? tex->FindReplacement(palette) : nullptr; if (rep) { // Hightile replacements have only one texture representation and it is always the base. tex = rep->faces[0]; TextureType = TT_HICREPLACE; + if (rep->palnum != palette || (h.f & HICTINT_APPLYOVERALTPAL)) applytint = true; } else { // Only look up the palette if we really want to use it (i.e. when creating a true color texture of an ART tile.) if (TextureType == TT_TRUECOLOR) { - /*lookuppal = palmanager.LookupPalette(usepalette, usepalswap, true); - if (lookuppal< 0)*/ lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false, g_nontransparent255); + // Tinting is not used on indexed textures + if (h.f & (HICTINT_ALWAYSUSEART | HICTINT_USEONART)) + { + applytint = true; + if (!(h.f & HICTINT_APPLYOVERPALSWAP)) usepalswap = 0; + } + lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false, g_nontransparent255); } } + // This is intentionally the same value for both parameters. The shader does not use the same uniform for modulation and overlay colors. + if (applytint) GLInterface.SetTinting(h.f, h.tint, h.tint); + else GLInterface.SetTinting(-1, 0xffffff, 0xffffff); + + // Load the main texture auto mtex = LoadTexture(tex, TextureType, lookuppal); if (mtex) diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 6f5dcd9cd..3a3b91192 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -481,6 +481,9 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState) shader->AlphaThreshold.Set(AlphaTest ? AlphaThreshold : -1.f); shader->Brightness.Set(Brightness); shader->FogColor.Set(FogColor); + shader->TintFlags.Set(hictint_flags); + shader->TintModulate.Set(hictint); + shader->TintOverlay.Set(hictint_overlay); if (matrixIndex[Matrix_View] != -1) shader->RotMatrix.Set(matrixArray[matrixIndex[Matrix_View]].get()); if (matrixIndex[Matrix_Projection] != -1) diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 07467658d..6446d0a79 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -520,14 +520,16 @@ public: renderState.Brightness = 8.f / (brightness + 8.f); } - void SetTinting(int flags, PalEntry color, PalEntry modulateColor) + void SetTinting(int flags, PalEntry color, PalEntry overlayColor) { - // not yet implemented. + renderState.hictint = color; + renderState.hictint_overlay = overlayColor; + renderState.hictint_flags = flags; } void SetBasepalTint(PalEntry color) { - // not yet implemented - only relevant for hires replacements. + renderState.fullscreenTint = color; } int GetPaletteIndex(PalEntry* palette) diff --git a/source/rr/src/screens.cpp b/source/rr/src/screens.cpp index 1528248c4..ab47de266 100644 --- a/source/rr/src/screens.cpp +++ b/source/rr/src/screens.cpp @@ -159,9 +159,9 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b) #ifdef USE_OPENGL // XXX: this makes us also load all hightile textures tinted with the crosshair color! polytint_t & crosshairtint = hictinting[CROSSHAIR_PAL]; - crosshairtint.r = CrosshairColors.r; - crosshairtint.g = CrosshairColors.g; - crosshairtint.b = CrosshairColors.b; + crosshairtint.tint.r = CrosshairColors.r; + crosshairtint.tint.g = CrosshairColors.g; + crosshairtint.tint.b = CrosshairColors.b; crosshairtint.f = HICTINT_USEONART | HICTINT_GRAYSCALE; #endif tileInvalidate(CROSSHAIR, -1, -1); @@ -759,23 +759,23 @@ void G_DisplayRest(int32_t smoothratio) if (pp->palette == WATERPAL) { - fstint.r = 224; - fstint.g = 192; - fstint.b = 255; + fstint.tint.r = 224; + fstint.tint.g = 192; + fstint.tint.b = 255; fstint.f = 0; } else if (pp->palette == SLIMEPAL) { - fstint.r = 208; - fstint.g = 255; - fstint.b = 192; + fstint.tint.r = 208; + fstint.tint.g = 255; + fstint.tint.b = 192; fstint.f = 0; } else { - fstint.r = 255; - fstint.g = 255; - fstint.b = 255; + fstint.tint.r = 255; + fstint.tint.g = 255; + fstint.tint.b = 255; fstint.f = 0; } } diff --git a/wadsrc/static/engine/shaders/glsl/polymost.fp b/wadsrc/static/engine/shaders/glsl/polymost.fp index ff1d73a7a..adbb2dc29 100644 --- a/wadsrc/static/engine/shaders/glsl/polymost.fp +++ b/wadsrc/static/engine/shaders/glsl/polymost.fp @@ -9,12 +9,12 @@ const int RF_NPOTEmulation = 32; const int RF_ShadeInterpolate = 64; const int RF_FogDisabled = 128; -const int RF_HICTINT_Grayscale = 0x10000; -const int RF_HICTINT_Invert = 0x20000; -const int RF_HICTINT_Colorize = 0x40000; -const int RF_HICTINT_BLEND_Screen = 0x80000; -const int RF_HICTINT_BLEND_Overlay = 0x100000; -const int RF_HICTINT_BLEND_Hardlight = 0x200000; +const int RF_HICTINT_Grayscale = 0x1; +const int RF_HICTINT_Invert = 0x2; +const int RF_HICTINT_Colorize = 0x4; +const int RF_HICTINT_BLEND_Screen = 64; +const int RF_HICTINT_BLEND_Overlay = 128; +const int RF_HICTINT_BLEND_Hardlight = 192; const int RF_HICTINT_BLENDMASK = RF_HICTINT_BLEND_Screen | RF_HICTINT_BLEND_Overlay | RF_HICTINT_BLEND_Hardlight; @@ -36,6 +36,9 @@ uniform float u_visFactor; uniform int u_flags; uniform float u_alphaThreshold; +uniform vec4 u_tintOverlay, u_tintModulate; +uniform int u_tintFlags; + uniform float u_npotEmulationFactor; uniform float u_npotEmulationXOffset; uniform float u_brightness; @@ -81,51 +84,56 @@ float grayscale(vec4 color) // //=========================================================================== -vec4 convertColor(vec4 color, int effect, vec3 tint) +vec4 convertColor(vec4 color) { -#if 0 - - if (effect & RF_HICTINT_Grayscale) + int effect = u_tintFlags; + if ((effect & RF_HICTINT_Grayscale) != 0) { float g = grayscale(color); color = vec4(g, g, g, color.a); } - if (effect & RF_HICTINT_Invert) + if ((effect & RF_HICTINT_Invert) != 0) { - color = vec4(1.0 - color.r, 1.0 - color.g, 1.0 - color.b); + color = vec4(1.0 - color.r, 1.0 - color.g, 1.0 - color.b, color.a); } vec3 tcol = color.rgb * 255.0; // * 255.0 to make it easier to reuse the integer math. - tint *= 255.0; - if (effect & RF_HICTINT_Colorize) + // Much of this looks quite broken by design. Why is this effectively multplied by 4 if the flag is set...? :( + if ((effect & RF_HICTINT_Colorize) != 0) { - tcol.b = min(((tcol.b) * tint.r) / 64.0, 255.0); - tcol.g = min(((tcol.g) * tint.g) / 64.0, 255.0); - tcol.r = min(((tcol.r) * tint.b) / 64.0, 255.0); + tcol.b = min(((tcol.b) * u_tintModulate.r)* 4, 255.0); + tcol.g = min(((tcol.g) * u_tintModulate.g)* 4, 255.0); + tcol.r = min(((tcol.r) * u_tintModulate.b)* 4, 255.0); + } + else + { + tcol.b = min(((tcol.b) * u_tintModulate.r), 255.0); + tcol.g = min(((tcol.g) * u_tintModulate.g), 255.0); + tcol.r = min(((tcol.r) * u_tintModulate.b), 255.0); } + vec4 ov = u_tintOverlay * 255.0; switch (effect & RF_HICTINT_BLENDMASK) { case RF_HICTINT_BLEND_Screen: - tcol.b = 255.0 - (((255.0 - tcol.b) * (255.0 - tint.r)) / 256.0); - tcol.g = 255.0 - (((255.0 - tcol.g) * (255.0 - tint.g)) / 256.0); - tcol.r = 255.0 - (((255.0 - tcol.r) * (255.0 - tint.b)) / 256.0); + tcol.b = 255.0 - (((255.0 - tcol.b) * (255.0 - ov.r)) / 256.0); + tcol.g = 255.0 - (((255.0 - tcol.g) * (255.0 - ov.g)) / 256.0); + tcol.r = 255.0 - (((255.0 - tcol.r) * (255.0 - ov.b)) / 256.0); break; case RF_HICTINT_BLEND_Overlay: - tcol.b = tcol.b < 128.0? (tcol.b * tint.r) / 128.0 : 255.0 - (((255.0 - tcol.b) * (255.0 - tint.r)) / 128.0); - tcol.g = tcol.g < 128.0? (tcol.g * tint.g) / 128.0 : 255.0 - (((255.0 - tcol.g) * (255.0 - tint.g)) / 128.0); - tcol.r = tcol.r < 128.0? (tcol.r * tint.b) / 128.0 : 255.0 - (((255.0 - tcol.r) * (255.0 - tint.b)) / 128.0); + tcol.b = tcol.b < 128.0? (tcol.b * ov.r) / 128.0 : 255.0 - (((255.0 - tcol.b) * (255.0 - ov.r)) / 128.0); + tcol.g = tcol.g < 128.0? (tcol.g * ov.g) / 128.0 : 255.0 - (((255.0 - tcol.g) * (255.0 - ov.g)) / 128.0); + tcol.r = tcol.r < 128.0? (tcol.r * ov.b) / 128.0 : 255.0 - (((255.0 - tcol.r) * (255.0 - ov.b)) / 128.0); break; case RF_HICTINT_BLEND_Hardlight: - tcol.b = tint.r < 128.0 ? (tcol.b * tint.r) / 128.0 : 255.0 - (((255.0 - tcol.b) * (255.0 - r)) / 128.0); - tcol.g = tint.g < 128.0 ? (tcol.g * tint.g) / 128.0 : 255.0 - (((255.0 - tcol.g) * (255.0 - g)) / 128.0); - tcol.r = tint.b < 128.0 ? (tcol.r * tint.b) / 128.0 : 255.0 - (((255.0 - tcol.r) * (255.0 - b)) / 128.0); + tcol.b = ov.r < 128.0 ? (tcol.b * ov.r) / 128.0 : 255.0 - (((255.0 - tcol.b) * (255.0 - ov.r)) / 128.0); + tcol.g = ov.g < 128.0 ? (tcol.g * ov.g) / 128.0 : 255.0 - (((255.0 - tcol.g) * (255.0 - ov.g)) / 128.0); + tcol.r = ov.b < 128.0 ? (tcol.r * ov.b) / 128.0 : 255.0 - (((255.0 - tcol.r) * (255.0 - ov.b)) / 128.0); break; } color.rgb = tcol / 255.0; -#endif return color; } @@ -196,6 +204,7 @@ void main() } else { + if (u_tintFlags != -1) color = convertColor(color); color.rgb *= detailColor.rgb; vec3 lightcolor = v_color.rgb; From 95eb10d2a63dd8c7556701479fcf67162ed21ac2 Mon Sep 17 00:00:00 2001 From: CommonLoon102 Date: Fri, 10 Jan 2020 14:38:29 +0100 Subject: [PATCH 04/51] fix voxel positions when notmd is defined in maphack file # Conflicts: # source/blood/src/view.cpp --- source/blood/src/view.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 87a1b9c97..dc3076ba5 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -2337,7 +2337,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t break; #endif // Can be overridden by def script - if (r_voxels && gDetail >= 4 && videoGetRenderMode() != REND_POLYMER && tiletovox[pTSprite->picnum] == -1 && voxelIndex[pTSprite->picnum] != -1) + if (r_voxels && gDetail >= 4 && videoGetRenderMode() != REND_POLYMER && tiletovox[pTSprite->picnum] == -1 && voxelIndex[pTSprite->picnum] != -1 && !(spriteext[nSprite].flags&SPREXT_NOTMD)) { if ((pTSprite->flags&kHitagRespawn) == 0) { @@ -2362,7 +2362,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t nAnim--; } - if ((pTSprite->cstat&48) != 48 && r_voxels && videoGetRenderMode() != REND_POLYMER) + if ((pTSprite->cstat&48) != 48 && r_voxels && videoGetRenderMode() != REND_POLYMER && !(spriteext[nSprite].flags&SPREXT_NOTMD)) { int nAnimTile = pTSprite->picnum + animateoffs_replace(pTSprite->picnum, 32768+pTSprite->owner); From bc4a4bea237f1974fdbe7db433ffb559ec887924 Mon Sep 17 00:00:00 2001 From: CommonLoon102 Date: Tue, 31 Dec 2019 20:35:28 +0100 Subject: [PATCH 05/51] Add possibility to move voxels/models via maphacks # Conflicts: # source/build/src/engine.cpp # source/build/src/polymer.cpp # source/build/src/polymost.cpp # source/duke3d/src/lunatic/con_lang.lua # source/rr/src/lunatic/con_lang.lua --- source/build/include/build.h | 3 +- source/build/src/engine.cpp | 6 +- source/build/src/mdsprite.cpp | 22 +++---- source/build/src/mhk.cpp | 90 +++++++++++++++++++++++----- source/build/src/voxmodel.cpp | 6 +- source/duke3d/src/actors.h | 10 +++- source/duke3d/src/gamedef.h | 9 ++- source/duke3d/src/gamestructures.cpp | 9 ++- source/duke3d/src/network.cpp | 30 +++++++--- 9 files changed, 136 insertions(+), 49 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index b138a106a..432a020c8 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -329,10 +329,11 @@ typedef struct { uint32_t mdanimtims; int16_t mdanimcur; int16_t angoff, pitch, roll; - vec3_t offset; + vec3_t pivot_offset, position_offset; uint8_t flags; uint8_t xpanning, ypanning; uint8_t filler; + uint32_t filler2; float alpha; // NOTE: keep 'tspr' on an 8-byte boundary: tspriteptr_t tspr; diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 1fe231be2..567128913 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -6108,13 +6108,17 @@ draw_as_face_sprite: } } + x = tspr->x + spriteext[spritenum].position_offset.x; + y = tspr->y + spriteext[spritenum].position_offset.y; + z = tspr->z + spriteext[spritenum].position_offset.z; + i = (int32_t)tspr->ang+1536; i += spriteext[spritenum].angoff; const int32_t ceilingz = (sec->ceilingstat&3) == 0 ? sec->ceilingz : INT32_MIN; const int32_t floorz = (sec->floorstat&3) == 0 ? sec->floorz : INT32_MAX; - classicDrawVoxel(tspr->x,tspr->y,tspr->z,i,daxrepeat,(int32_t)tspr->yrepeat,vtilenum, + classicDrawVoxel(x,y,z,i,daxrepeat,(int32_t)tspr->yrepeat,vtilenum, tspr->shade,tspr->pal,lwall.Data(),swall.Data(),tspr->cstat,(tspr->cstat&48)!=48,floorz,ceilingz); } diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index 4ff6a24b8..b9abbd106 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -1428,8 +1428,8 @@ void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float float g; float k0, k1, k2, k3, k4, k5, k6, k7; - k0 = ((float)(tspr->x-globalposx))*f*(1.f/1024.f); - k1 = ((float)(tspr->y-globalposy))*f*(1.f/1024.f); + k0 = ((float)(tspr->x+spriteext[tspr->owner].position_offset.x-globalposx))*f*(1.f/1024.f); + k1 = ((float)(tspr->y+spriteext[tspr->owner].position_offset.y-globalposy))*f*(1.f/1024.f); f = gcosang2*gshang/gvrcorrection; g = gsinang2*gshang/gvrcorrection; k4 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+1024)&2047] * (1.f/16384.f); @@ -1521,7 +1521,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) a0.z = m->zadd * m->scale; // Parkar: Moved up to be able to use k0 for the y-flipping code - k0 = (float)tspr->z; + k0 = (float)tspr->z+spriteext[tspr->owner].position_offset.z; if ((globalorientation&128) && !((globalorientation&48)==32)) k0 += (float)(sizyrep<<1); @@ -1544,7 +1544,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) m0.z *= f; m1.z *= f; a0.z *= f; // floor aligned - k1 = (float)tspr->y; + k1 = (float)tspr->y+spriteext[tspr->owner].position_offset.y; if ((globalorientation&48)==32) { m0.z = -m0.z; m1.z = -m1.z; a0.z = -a0.z; @@ -1557,7 +1557,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) // calculations below again, but are needed for the base offsets. f = (65536.f*512.f)/(fxdimen*fviewingrange); g = 32.f/(fxdimen*gxyaspect); - m0.y *= f; m1.y *= f; a0.y = (((float)(tspr->x-globalposx))* (1.f/1024.f) + a0.y)*f; + m0.y *= f; m1.y *= f; a0.y = (((float)(tspr->x+spriteext[tspr->owner].position_offset.x-globalposx))* (1.f/1024.f) + a0.y)*f; m0.x *=-f; m1.x *=-f; a0.x = ((k1 -fglobalposy) * -(1.f/1024.f) + a0.x)*-f; m0.z *= g; m1.z *= g; a0.z = ((k0 -fglobalposz) * -(1.f/16384.f) + a0.z)*g; @@ -1623,14 +1623,14 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) float f = 1.f/(fxdimen * fviewingrange) * (256.f/(65536.f*128.f)) * (m0.x+m1.x); Bmemset(&a0, 0, sizeof(a0)); - if (sext->offset.x) - a0.x = (float) sext->offset.x * f; + if (sext->pivot_offset.x) + a0.x = (float) sext->pivot_offset.x * f; - if (sext->offset.y) // Compare with SCREEN_FACTORS above - a0.y = (float) sext->offset.y * f; + if (sext->pivot_offset.y) // Compare with SCREEN_FACTORS above + a0.y = (float) sext->pivot_offset.y * f; - if ((sext->offset.z) && !(tspr->clipdist & TSPR_FLAGS_MDHACK)) // Compare with SCREEN_FACTORS above - a0.z = (float)sext->offset.z / (gxyaspect * fxdimen * (65536.f/128.f) * (m0.z+m1.z)); + if ((sext->pivot_offset.z) && !(tspr->clipdist & TSPR_FLAGS_MDHACK)) // Compare with SCREEN_FACTORS above + a0.z = (float)sext->pivot_offset.z / (gxyaspect * fxdimen * (65536.f/128.f) * (m0.z+m1.z)); k0 = (float)sintable[(sext->pitch+512)&2047] * (1.f/16384.f); k1 = (float)sintable[sext->pitch&2047] * (1.f/16384.f); diff --git a/source/build/src/mhk.cpp b/source/build/src/mhk.cpp index 0ac922632..7d8224aae 100644 --- a/source/build/src/mhk.cpp +++ b/source/build/src/mhk.cpp @@ -46,9 +46,12 @@ int32_t engineLoadMHK(const char *filename) T_NOANIM, T_PITCH, T_ROLL, - T_MDXOFF, - T_MDYOFF, - T_MDZOFF, + T_PIVOTXOFF, + T_PIVOTYOFF, + T_PIVOTZOFF, + T_POSITIONXOFF, + T_POSITIONYOFF, + T_POSITIONZOFF, T_AWAY1, T_AWAY2, T_LIGHT, @@ -67,9 +70,21 @@ int32_t engineLoadMHK(const char *filename) { "nomdanim", T_NOANIM }, { "pitch", T_PITCH }, { "roll", T_ROLL }, - { "mdxoff", T_MDXOFF }, - { "mdyoff", T_MDYOFF }, - { "mdzoff", T_MDZOFF }, + { "mdxoff", T_PIVOTXOFF }, + { "mdyoff", T_PIVOTYOFF }, + { "mdzoff", T_PIVOTZOFF }, + { "pivxoff", T_PIVOTXOFF }, + { "pivyoff", T_PIVOTYOFF }, + { "pivzoff", T_PIVOTZOFF }, + { "pivotxoff", T_PIVOTXOFF }, + { "pivotyoff", T_PIVOTYOFF }, + { "pivotzoff", T_PIVOTZOFF }, + { "posxoff", T_POSITIONXOFF }, + { "posyoff", T_POSITIONYOFF }, + { "poszoff", T_POSITIONZOFF }, + { "positionxoff", T_POSITIONXOFF }, + { "positionyoff", T_POSITIONYOFF }, + { "positionzoff", T_POSITIONZOFF }, { "away1", T_AWAY1 }, { "away2", T_AWAY2 }, { "light", T_LIGHT }, @@ -197,7 +212,7 @@ int32_t engineLoadMHK(const char *filename) spriteext[whichsprite].roll = (int16_t) roll; } break; - case T_MDXOFF: // mdxoff + case T_PIVOTXOFF: // pivxoff { int32_t i; if (scriptfile_getnumber(script, &i)) break; @@ -205,14 +220,14 @@ int32_t engineLoadMHK(const char *filename) if (whichsprite < 0) { // no sprite directive preceeding - initprintf("Ignoring mdxoff directive because of absent/invalid sprite number on line %s:%d\n", + initprintf("Ignoring mdxoff/pivxoff directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script, cmdtokptr)); break; } - spriteext[whichsprite].offset.x = i; + spriteext[whichsprite].pivot_offset.x = i; } break; - case T_MDYOFF: // mdyoff + case T_PIVOTYOFF: // pivyoff { int32_t i; if (scriptfile_getnumber(script, &i)) break; @@ -220,14 +235,14 @@ int32_t engineLoadMHK(const char *filename) if (whichsprite < 0) { // no sprite directive preceeding - initprintf("Ignoring mdyoff directive because of absent/invalid sprite number on line %s:%d\n", + initprintf("Ignoring mdyoff/pivyoff directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script, cmdtokptr)); break; } - spriteext[whichsprite].offset.y = i; + spriteext[whichsprite].pivot_offset.y = i; } break; - case T_MDZOFF: // mdzoff + case T_PIVOTZOFF: // pivzoff { int32_t i; if (scriptfile_getnumber(script, &i)) break; @@ -235,11 +250,56 @@ int32_t engineLoadMHK(const char *filename) if (whichsprite < 0) { // no sprite directive preceeding - initprintf("Ignoring mdzoff directive because of absent/invalid sprite number on line %s:%d\n", + initprintf("Ignoring mdzoff/pivzoff directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script, cmdtokptr)); break; } - spriteext[whichsprite].offset.z = i; + spriteext[whichsprite].pivot_offset.z = i; + } + break; + case T_POSITIONXOFF: // posxoff + { + int32_t i; + if (scriptfile_getnumber(script, &i)) break; + + if (whichsprite < 0) + { + // no sprite directive preceeding + initprintf("Ignoring posxoff directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script, cmdtokptr)); + break; + } + spriteext[whichsprite].position_offset.x = i; + } + break; + case T_POSITIONYOFF: // posyoff + { + int32_t i; + if (scriptfile_getnumber(script, &i)) break; + + if (whichsprite < 0) + { + // no sprite directive preceeding + initprintf("Ignoring posyoff directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script, cmdtokptr)); + break; + } + spriteext[whichsprite].position_offset.y = i; + } + break; + case T_POSITIONZOFF: // poszoff + { + int32_t i; + if (scriptfile_getnumber(script, &i)) break; + + if (whichsprite < 0) + { + // no sprite directive preceeding + initprintf("Ignoring poszoff directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script, cmdtokptr)); + break; + } + spriteext[whichsprite].position_offset.z = i; } break; case T_AWAY1: // away1 diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index af5789e13..ffdc8c280 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -1035,7 +1035,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) f = (float) tspr->yrepeat * k0; m0.z *= f; a0.z *= f; - k0 = (float) tspr->z; + k0 = (float) (tspr->z+spriteext[tspr->owner].position_offset.z); f = ((globalorientation&8) && (sprite[tspr->owner].cstat&48)!=0) ? -4.f : 4.f; k0 -= (tspr->yoffset*tspr->yrepeat)*f*m->bscale; zoff = m->siz.z*.5f; @@ -1053,8 +1053,8 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) int const shadowHack = !!(tspr->clipdist & TSPR_FLAGS_MDHACK); - m0.y *= f; a0.y = (((float)(tspr->x-globalposx)) * (1.f/1024.f) + a0.y) * f; - m0.x *=-f; a0.x = (((float)(tspr->y-globalposy)) * -(1.f/1024.f) + a0.x) * -f; + m0.y *= f; a0.y = (((float)(tspr->x+spriteext[tspr->owner].position_offset.x-globalposx)) * (1.f/1024.f) + a0.y) * f; + m0.x *=-f; a0.x = (((float)(tspr->y+spriteext[tspr->owner].position_offset.y-globalposy)) * -(1.f/1024.f) + a0.x) * -f; m0.z *= g; a0.z = (((float)(k0 -globalposz - shadowHack)) * -(1.f/16384.f) + a0.z) * g; float mat[16]; diff --git a/source/duke3d/src/actors.h b/source/duke3d/src/actors.h index 94a2340bc..312aa01b5 100644 --- a/source/duke3d/src/actors.h +++ b/source/duke3d/src/actors.h @@ -315,9 +315,13 @@ typedef struct netactor_s ext_pitch, ext_roll, - ext_offset_x, - ext_offset_y, - ext_offset_z, + ext_pivot_offset_x, + ext_pivot_offset_y, + ext_pivot_offset_z, + + ext_position_offset_x, + ext_position_offset_y, + ext_position_offset_z, ext_flags, ext_xpanning, diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index f46bc8df0..912cbaafa 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -737,9 +737,12 @@ enum ActorLabel_t ACTOR_ANGOFF = ACTOR_SPRITEEXT_BEGIN, ACTOR_PITCH, ACTOR_ROLL, - ACTOR_MDXOFF, - ACTOR_MDYOFF, - ACTOR_MDZOFF, + ACTOR_PIVOTXOFF, + ACTOR_PIVOTYOFF, + ACTOR_PIVOTZOFF, + ACTOR_POSITIONXOFF, + ACTOR_POSITIONYOFF, + ACTOR_POSITIONZOFF, ACTOR_MDFLAGS, ACTOR_XPANNING, ACTOR_YPANNING, diff --git a/source/duke3d/src/gamestructures.cpp b/source/duke3d/src/gamestructures.cpp index 8a4713b98..41a267a33 100644 --- a/source/duke3d/src/gamestructures.cpp +++ b/source/duke3d/src/gamestructures.cpp @@ -305,9 +305,12 @@ const memberlabel_t ActorLabels[]= LABEL_SETUP(spriteext, pitch, ACTOR_PITCH), LABEL_SETUP(spriteext, roll, ACTOR_ROLL), - LABEL_SETUP_UNMATCHED(spriteext, offset.x, "mdxoff", ACTOR_MDXOFF), - LABEL_SETUP_UNMATCHED(spriteext, offset.y, "mdyoff", ACTOR_MDYOFF), - LABEL_SETUP_UNMATCHED(spriteext, offset.z, "mdzoff", ACTOR_MDZOFF), + LABEL_SETUP_UNMATCHED(spriteext, pivot_offset.x, "mdxoff", ACTOR_PIVOTXOFF), + LABEL_SETUP_UNMATCHED(spriteext, pivot_offset.y, "mdyoff", ACTOR_PIVOTYOFF), + LABEL_SETUP_UNMATCHED(spriteext, pivot_offset.z, "mdzoff", ACTOR_PIVOTZOFF), + LABEL_SETUP_UNMATCHED(spriteext, position_offset.x, "posxoff", ACTOR_POSITIONXOFF), + LABEL_SETUP_UNMATCHED(spriteext, position_offset.y, "posyoff", ACTOR_POSITIONYOFF), + LABEL_SETUP_UNMATCHED(spriteext, position_offset.z, "poszoff", ACTOR_POSITIONZOFF), LABEL_SETUP_UNMATCHED(spriteext, flags, "mdflags", ACTOR_MDFLAGS), LABEL_SETUP(spriteext, xpanning, ACTOR_XPANNING), diff --git a/source/duke3d/src/network.cpp b/source/duke3d/src/network.cpp index 69cd7c6fc..13b90b70d 100644 --- a/source/duke3d/src/network.cpp +++ b/source/duke3d/src/network.cpp @@ -402,9 +402,13 @@ static netField_t ActorFields[] = { ACTF(ext_pitch), 16 }, { ACTF(ext_roll), 16 }, - { ACTF(ext_offset_x), 32 }, - { ACTF(ext_offset_y), 32 }, - { ACTF(ext_offset_z), 32 }, + { ACTF(ext_pivot_offset_x), 32 }, + { ACTF(ext_pivot_offset_y), 32 }, + { ACTF(ext_pivot_offset_z), 32 }, + + { ACTF(ext_position_offset_x), 32 }, + { ACTF(ext_position_offset_y), 32 }, + { ACTF(ext_position_offset_z), 32 }, { ACTF(ext_flags), 8 }, { ACTF(ext_xpanning), 8 }, @@ -1020,9 +1024,13 @@ static void Net_CopySpriteExtFromNet(const netactor_t* netActor, spriteext_t* ga gameSprExt->pitch = netActor->ext_pitch; gameSprExt->roll = netActor->ext_roll; - gameSprExt->offset.x = netActor->ext_offset_x; - gameSprExt->offset.y = netActor->ext_offset_y; - gameSprExt->offset.z = netActor->ext_offset_z; + gameSprExt->pivot_offset.x = netActor->ext_pivot_offset_x; + gameSprExt->pivot_offset.y = netActor->ext_pivot_offset_y; + gameSprExt->pivot_offset.z = netActor->ext_pivot_offset_z; + + gameSprExt->position_offset.x = netActor->ext_position_offset_x; + gameSprExt->position_offset.y = netActor->ext_position_offset_y; + gameSprExt->position_offset.z = netActor->ext_position_offset_z; gameSprExt->flags = netActor->ext_flags; gameSprExt->xpanning = netActor->ext_xpanning; @@ -1375,9 +1383,13 @@ static void Net_CopySpriteExtToNet(const spriteext_t* gameSpriteExt, netactor_t* netActor->ext_pitch = gameSpriteExt->pitch; netActor->ext_roll = gameSpriteExt->roll; - netActor->ext_offset_x = gameSpriteExt->offset.x; - netActor->ext_offset_y = gameSpriteExt->offset.y; - netActor->ext_offset_z = gameSpriteExt->offset.z; + netActor->ext_pivot_offset_x = gameSpriteExt->pivot_offset.x; + netActor->ext_pivot_offset_y = gameSpriteExt->pivot_offset.y; + netActor->ext_pivot_offset_z = gameSpriteExt->pivot_offset.z; + + netActor->ext_position_offset_x = gameSpriteExt->position_offset.x; + netActor->ext_position_offset_y = gameSpriteExt->position_offset.y; + netActor->ext_position_offset_z = gameSpriteExt->position_offset.z; netActor->ext_flags = gameSpriteExt->flags; netActor->ext_xpanning = gameSpriteExt->xpanning; From 851a82c01f78039e9b5d14337c074b39dfc29028 Mon Sep 17 00:00:00 2001 From: CommonLoon102 Date: Sat, 11 Jan 2020 15:56:14 +0100 Subject: [PATCH 06/51] Blood: prefix the new maphack tokens with md # Conflicts: # source/duke3d/src/lunatic/con_lang.lua # source/rr/src/lunatic/con_lang.lua --- source/build/src/mhk.cpp | 66 ++++++++++++++-------------- source/duke3d/src/gamedef.h | 12 ++--- source/duke3d/src/gamestructures.cpp | 12 ++--- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/source/build/src/mhk.cpp b/source/build/src/mhk.cpp index 7d8224aae..bef1b573c 100644 --- a/source/build/src/mhk.cpp +++ b/source/build/src/mhk.cpp @@ -46,12 +46,12 @@ int32_t engineLoadMHK(const char *filename) T_NOANIM, T_PITCH, T_ROLL, - T_PIVOTXOFF, - T_PIVOTYOFF, - T_PIVOTZOFF, - T_POSITIONXOFF, - T_POSITIONYOFF, - T_POSITIONZOFF, + T_MDPIVOTXOFF, + T_MDPIVOTYOFF, + T_MDPIVOTZOFF, + T_MDPOSITIONXOFF, + T_MDPOSITIONYOFF, + T_MDPOSITIONZOFF, T_AWAY1, T_AWAY2, T_LIGHT, @@ -70,21 +70,21 @@ int32_t engineLoadMHK(const char *filename) { "nomdanim", T_NOANIM }, { "pitch", T_PITCH }, { "roll", T_ROLL }, - { "mdxoff", T_PIVOTXOFF }, - { "mdyoff", T_PIVOTYOFF }, - { "mdzoff", T_PIVOTZOFF }, - { "pivxoff", T_PIVOTXOFF }, - { "pivyoff", T_PIVOTYOFF }, - { "pivzoff", T_PIVOTZOFF }, - { "pivotxoff", T_PIVOTXOFF }, - { "pivotyoff", T_PIVOTYOFF }, - { "pivotzoff", T_PIVOTZOFF }, - { "posxoff", T_POSITIONXOFF }, - { "posyoff", T_POSITIONYOFF }, - { "poszoff", T_POSITIONZOFF }, - { "positionxoff", T_POSITIONXOFF }, - { "positionyoff", T_POSITIONYOFF }, - { "positionzoff", T_POSITIONZOFF }, + { "mdxoff", T_MDPIVOTXOFF }, + { "mdyoff", T_MDPIVOTYOFF }, + { "mdzoff", T_MDPIVOTZOFF }, + { "mdpivxoff", T_MDPIVOTXOFF }, + { "mdpivyoff", T_MDPIVOTYOFF }, + { "mdpivzoff", T_MDPIVOTZOFF }, + { "mdpivotxoff", T_MDPIVOTXOFF }, + { "mdpivotyoff", T_MDPIVOTYOFF }, + { "mdpivotzoff", T_MDPIVOTZOFF }, + { "mdposxoff", T_MDPOSITIONXOFF }, + { "mdposyoff", T_MDPOSITIONYOFF }, + { "mdposzoff", T_MDPOSITIONZOFF }, + { "mdpositionxoff", T_MDPOSITIONXOFF }, + { "mdpositionyoff", T_MDPOSITIONYOFF }, + { "mdpositionzoff", T_MDPOSITIONZOFF }, { "away1", T_AWAY1 }, { "away2", T_AWAY2 }, { "light", T_LIGHT }, @@ -212,7 +212,7 @@ int32_t engineLoadMHK(const char *filename) spriteext[whichsprite].roll = (int16_t) roll; } break; - case T_PIVOTXOFF: // pivxoff + case T_MDPIVOTXOFF: // mdpivxoff { int32_t i; if (scriptfile_getnumber(script, &i)) break; @@ -220,14 +220,14 @@ int32_t engineLoadMHK(const char *filename) if (whichsprite < 0) { // no sprite directive preceeding - initprintf("Ignoring mdxoff/pivxoff directive because of absent/invalid sprite number on line %s:%d\n", + initprintf("Ignoring mdxoff/mdpivxoff directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script, cmdtokptr)); break; } spriteext[whichsprite].pivot_offset.x = i; } break; - case T_PIVOTYOFF: // pivyoff + case T_MDPIVOTYOFF: // mdpivyoff { int32_t i; if (scriptfile_getnumber(script, &i)) break; @@ -235,14 +235,14 @@ int32_t engineLoadMHK(const char *filename) if (whichsprite < 0) { // no sprite directive preceeding - initprintf("Ignoring mdyoff/pivyoff directive because of absent/invalid sprite number on line %s:%d\n", + initprintf("Ignoring mdyoff/mdpivyoff directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script, cmdtokptr)); break; } spriteext[whichsprite].pivot_offset.y = i; } break; - case T_PIVOTZOFF: // pivzoff + case T_MDPIVOTZOFF: // mdpivzoff { int32_t i; if (scriptfile_getnumber(script, &i)) break; @@ -250,14 +250,14 @@ int32_t engineLoadMHK(const char *filename) if (whichsprite < 0) { // no sprite directive preceeding - initprintf("Ignoring mdzoff/pivzoff directive because of absent/invalid sprite number on line %s:%d\n", + initprintf("Ignoring mdzoff/mdpivzoff directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script, cmdtokptr)); break; } spriteext[whichsprite].pivot_offset.z = i; } break; - case T_POSITIONXOFF: // posxoff + case T_MDPOSITIONXOFF: // mdposxoff { int32_t i; if (scriptfile_getnumber(script, &i)) break; @@ -265,14 +265,14 @@ int32_t engineLoadMHK(const char *filename) if (whichsprite < 0) { // no sprite directive preceeding - initprintf("Ignoring posxoff directive because of absent/invalid sprite number on line %s:%d\n", + initprintf("Ignoring mdposxoff directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script, cmdtokptr)); break; } spriteext[whichsprite].position_offset.x = i; } break; - case T_POSITIONYOFF: // posyoff + case T_MDPOSITIONYOFF: // mdposyoff { int32_t i; if (scriptfile_getnumber(script, &i)) break; @@ -280,14 +280,14 @@ int32_t engineLoadMHK(const char *filename) if (whichsprite < 0) { // no sprite directive preceeding - initprintf("Ignoring posyoff directive because of absent/invalid sprite number on line %s:%d\n", + initprintf("Ignoring mdposyoff directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script, cmdtokptr)); break; } spriteext[whichsprite].position_offset.y = i; } break; - case T_POSITIONZOFF: // poszoff + case T_MDPOSITIONZOFF: // mdposzoff { int32_t i; if (scriptfile_getnumber(script, &i)) break; @@ -295,7 +295,7 @@ int32_t engineLoadMHK(const char *filename) if (whichsprite < 0) { // no sprite directive preceeding - initprintf("Ignoring poszoff directive because of absent/invalid sprite number on line %s:%d\n", + initprintf("Ignoring mdposzoff directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script, cmdtokptr)); break; } diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index 912cbaafa..e4d77bdff 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -737,12 +737,12 @@ enum ActorLabel_t ACTOR_ANGOFF = ACTOR_SPRITEEXT_BEGIN, ACTOR_PITCH, ACTOR_ROLL, - ACTOR_PIVOTXOFF, - ACTOR_PIVOTYOFF, - ACTOR_PIVOTZOFF, - ACTOR_POSITIONXOFF, - ACTOR_POSITIONYOFF, - ACTOR_POSITIONZOFF, + ACTOR_MDPIVOTXOFF, + ACTOR_MDPIVOTYOFF, + ACTOR_MDPIVOTZOFF, + ACTOR_MDPOSITIONXOFF, + ACTOR_MDPOSITIONYOFF, + ACTOR_MDPOSITIONZOFF, ACTOR_MDFLAGS, ACTOR_XPANNING, ACTOR_YPANNING, diff --git a/source/duke3d/src/gamestructures.cpp b/source/duke3d/src/gamestructures.cpp index 41a267a33..a721b0f89 100644 --- a/source/duke3d/src/gamestructures.cpp +++ b/source/duke3d/src/gamestructures.cpp @@ -305,12 +305,12 @@ const memberlabel_t ActorLabels[]= LABEL_SETUP(spriteext, pitch, ACTOR_PITCH), LABEL_SETUP(spriteext, roll, ACTOR_ROLL), - LABEL_SETUP_UNMATCHED(spriteext, pivot_offset.x, "mdxoff", ACTOR_PIVOTXOFF), - LABEL_SETUP_UNMATCHED(spriteext, pivot_offset.y, "mdyoff", ACTOR_PIVOTYOFF), - LABEL_SETUP_UNMATCHED(spriteext, pivot_offset.z, "mdzoff", ACTOR_PIVOTZOFF), - LABEL_SETUP_UNMATCHED(spriteext, position_offset.x, "posxoff", ACTOR_POSITIONXOFF), - LABEL_SETUP_UNMATCHED(spriteext, position_offset.y, "posyoff", ACTOR_POSITIONYOFF), - LABEL_SETUP_UNMATCHED(spriteext, position_offset.z, "poszoff", ACTOR_POSITIONZOFF), + LABEL_SETUP_UNMATCHED(spriteext, pivot_offset.x, "mdxoff", ACTOR_MDPIVOTXOFF), + LABEL_SETUP_UNMATCHED(spriteext, pivot_offset.y, "mdyoff", ACTOR_MDPIVOTYOFF), + LABEL_SETUP_UNMATCHED(spriteext, pivot_offset.z, "mdzoff", ACTOR_MDPIVOTZOFF), + LABEL_SETUP_UNMATCHED(spriteext, position_offset.x, "mdposxoff", ACTOR_MDPOSITIONXOFF), + LABEL_SETUP_UNMATCHED(spriteext, position_offset.y, "mdposyoff", ACTOR_MDPOSITIONYOFF), + LABEL_SETUP_UNMATCHED(spriteext, position_offset.z, "mdposzoff", ACTOR_MDPOSITIONZOFF), LABEL_SETUP_UNMATCHED(spriteext, flags, "mdflags", ACTOR_MDFLAGS), LABEL_SETUP(spriteext, xpanning, ACTOR_XPANNING), From 6e3772d50dfd4249d424d9dd1dca6aea3c4dd613 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 11 Jan 2020 22:39:53 +0100 Subject: [PATCH 07/51] - fixed voxel color setting. --- source/build/src/voxmodel.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index ffdc8c280..e844a7e40 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -1082,6 +1082,12 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * hw_shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades; + auto& h = hictinting[globalpal]; + if (h.f & (HICTINT_USEONART|HICTINT_ALWAYSUSEART)) + GLInterface.SetTinting(h.f, h.tint, h.tint); + else + GLInterface.SetTinting(-1, 0xffffff, 0xffffff); + if (!shadowHack) { pc[3] = (tspr->cstat & 2) ? glblend[tspr->blend].def[!!(tspr->cstat & 512)].alpha : 1.0f; From d4a2d776cfdc61ec080fc46d1259808bdfce792f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 11 Jan 2020 22:50:12 +0100 Subject: [PATCH 08/51] - added detection for another variant of SW's Wanton Destruction add-on. - corrected the main script name for WW2GI's Platoon Leader add-on. --- wadsrc/static/engine/grpinfo.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wadsrc/static/engine/grpinfo.txt b/wadsrc/static/engine/grpinfo.txt index 0759375dc..6dc8d4894 100644 --- a/wadsrc/static/engine/grpinfo.txt +++ b/wadsrc/static/engine/grpinfo.txt @@ -305,7 +305,7 @@ grpinfo grpinfo { name "Platoon Leader" - scriptname "PLATOONL.CON" + scriptname "PLATOONL.DEF" size 37852572 crc PLATOONL_CRC flags GAMEFLAG_WW2GI|GAMEFLAG_ADDON @@ -479,6 +479,17 @@ grpinfo gamefilter "ShadowWarrior.Wanton" } +grpinfo +{ + name "Shadow Warrior: Wanton Destruction" + flags GAMEFLAG_SW|GAMEFLAG_ADDON + crc 0x8B6E8011 + size 48698128 + defname "sw.def" + dependency SWREG12_CRC + gamefilter "ShadowWarrior.Wanton" +} + grpinfo { name "Shadow Warrior: Twin Dragon" From 238bbd26c1a37c4f254e2321a3bbd44fb3d90880 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 11 Jan 2020 23:05:37 +0100 Subject: [PATCH 09/51] - fixed: savegame insertion must not move the "New savegame" node at the top. --- source/common/menu/savegamemanager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/common/menu/savegamemanager.cpp b/source/common/menu/savegamemanager.cpp index fb2334d19..4a458a8ba 100644 --- a/source/common/menu/savegamemanager.cpp +++ b/source/common/menu/savegamemanager.cpp @@ -146,8 +146,9 @@ int FSavegameManager::InsertSaveNode(FSaveGameNode *node) } else { // Add node at top of list - unsigned int i; - for (i = 0; i < SaveGames.Size(); i++) + unsigned int i = 0; + if (SaveGames[0] == &NewSaveNode) i++; // To not insert above the "new savegame" dummy entry. + for (; i < SaveGames.Size(); i++) { if (SaveGames[i]->bOldVersion || node->SaveTitle.CompareNoCase(SaveGames[i]->SaveTitle) <= 0) { From b57d683938967aa5c359f0ff80e08d450611ecc6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 12 Jan 2020 08:53:11 +0100 Subject: [PATCH 10/51] - added default for nosubdir parameter. --- source/common/filesystem/file_directory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/filesystem/file_directory.cpp b/source/common/filesystem/file_directory.cpp index 20d8f4250..3e0023eed 100644 --- a/source/common/filesystem/file_directory.cpp +++ b/source/common/filesystem/file_directory.cpp @@ -78,7 +78,7 @@ class FDirectory : public FResourceFile void AddEntry(const char *fullpath, int size); public: - FDirectory(const char * dirname, bool nosubdirflag); + FDirectory(const char * dirname, bool nosubdirflag = false); bool Open(bool quiet); virtual FResourceLump *GetLump(int no) { return ((unsigned)no < NumLumps)? &Lumps[no] : NULL; } }; From 9ca2819ad1638bd9a4c48ffe2a36e478f18fd01f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 12 Jan 2020 09:32:30 +0100 Subject: [PATCH 11/51] - added missing validation to S_GetUserFlags functions. --- source/duke3d/src/sounds.cpp | 1 + source/rr/src/sounds.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/source/duke3d/src/sounds.cpp b/source/duke3d/src/sounds.cpp index f0740f0c4..a2b0e84e1 100644 --- a/source/duke3d/src/sounds.cpp +++ b/source/duke3d/src/sounds.cpp @@ -114,6 +114,7 @@ float S_ConvertPitch(int lpitch) int S_GetUserFlags(int num) { + if (!soundEngine->isValidSoundId(num+1)) return 0; auto const* snd = (sound_t*)soundEngine->GetUserData(num + 1); if (!snd) return 0; return snd->flags; diff --git a/source/rr/src/sounds.cpp b/source/rr/src/sounds.cpp index cf997333d..206e20995 100644 --- a/source/rr/src/sounds.cpp +++ b/source/rr/src/sounds.cpp @@ -113,6 +113,7 @@ float S_ConvertPitch(int lpitch) int S_GetUserFlags(int num) { + if (!soundEngine->isValidSoundId(num+1)) return 0; auto const* snd = (sound_t*)soundEngine->GetUserData(num + 1); if (!snd) return 0; return snd->flags; From 661431df873dda92c1e612ec35b1406b1d6019e0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 12 Jan 2020 14:54:43 +0100 Subject: [PATCH 12/51] - moved bits of my own code to properly copyrighted files. --- source/build/src/sdlayer.cpp | 102 +------------------------- source/common/gamecontrol.cpp | 55 ++++++++++++++ source/common/sound/s_soundinternal.h | 2 +- 3 files changed, 57 insertions(+), 102 deletions(-) diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index 7bd9f7376..8fa69d58a 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -1,45 +1,16 @@ // SDL interface layer for the Build Engine // Use SDL 1.2 or 2.0 from http://www.libsdl.org -#ifdef _WIN32 -#include -#include -#endif -#include -#include -#include -# include "gl_load.h" - #include "a.h" #include "build.h" #include "common.h" #include "compat.h" #include "engine_priv.h" -#include "osd.h" #include "palette.h" #include "baselayer.h" -#include "m_argv.h" #include "mmulti.h" -#include "scriptfile.h" -#include "zstring.h" -#include "gameconfigfile.h" -#include "gamecontrol.h" -#include "resourcefile.h" -#include "sc_man.h" -#include "i_specialpaths.h" -#include "inputstate.h" -#include "c_cvars.h" -#include "i_time.h" -#include "c_dispatch.h" -#include "d_gui.h" -#include "menu.h" -#include "utf8.h" -#include "imgui.h" -#include "imgui_impl_sdl.h" -#include "imgui_impl_opengl3.h" -# include "glsurface.h" - +#include "glsurface.h" double g_beforeSwapTime; @@ -66,47 +37,6 @@ int32_t lockcount=0; char modechange=1; char offscreenrendering=0; -#define MAX_ERRORTEXT 4096 - -//========================================================================== -// -// I_Error -// -// Throw an error that will send us to the console if we are far enough -// along in the startup process. -// -//========================================================================== - -void I_Error(const char *error, ...) -{ - va_list argptr; - char errortext[MAX_ERRORTEXT]; - - va_start(argptr, error); - vsnprintf(errortext, MAX_ERRORTEXT, error, argptr); - va_end(argptr); - #ifdef _WIN32 - OutputDebugStringA(errortext); - #endif - - throw std::runtime_error(errortext); -} - -void I_FatalError(const char* error, ...) -{ - va_list argptr; - char errortext[MAX_ERRORTEXT]; - - va_start(argptr, error); - vsnprintf(errortext, MAX_ERRORTEXT, error, argptr); - va_end(argptr); -#ifdef _WIN32 - OutputDebugStringA(errortext); -#endif - - throw std::runtime_error(errortext); -} - // Calculate ylookup[] and call setvlinebpl() void calc_ylookup(int32_t bpl, int32_t lastyidx) @@ -223,35 +153,5 @@ void videoEndDrawing(void) lockcount = 0; } -// -// -// --------------------------------------- -// -// Miscellany -// -// --------------------------------------- -// -// - auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries. -// -// debugprintf() -- sends a debug string to the debugger -// -void debugprintf(const char* f, ...) -{ - va_list va; - va_start(va, f); - -#ifdef _WIN32 - if (!IsDebuggerPresent()) return; - - char buf[1024]; - vsnprintf(buf, 1024, f, va); - va_end(va); - OutputDebugStringA(buf); -#else - vprintf(f, va); -#endif -} - diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index 842af461c..d34a982d2 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- +#include #include "gamecontrol.h" #include "tarray.h" #include "zstring.h" @@ -807,3 +808,57 @@ void S_SetSoundPaused(int state) } #endif } + +#define MAX_ERRORTEXT 4096 + +//========================================================================== +// +// I_Error +// +// Throw an error that will send us to the console if we are far enough +// along in the startup process. +// +//========================================================================== + +void I_Error(const char* error, ...) +{ + va_list argptr; + char errortext[MAX_ERRORTEXT]; + + va_start(argptr, error); + vsnprintf(errortext, MAX_ERRORTEXT, error, argptr); + va_end(argptr); +#ifdef _WIN32 + OutputDebugStringA(errortext); +#endif + + throw std::runtime_error(errortext); +} + +void I_FatalError(const char* error, ...) +{ + va_list argptr; + char errortext[MAX_ERRORTEXT]; + + va_start(argptr, error); + vsnprintf(errortext, MAX_ERRORTEXT, error, argptr); + va_end(argptr); +#ifdef _WIN32 + OutputDebugStringA(errortext); +#endif + + throw std::runtime_error(errortext); +} + +// +// debugprintf() -- sends a debug string to the debugger +// +void debugprintf(const char* f, ...) +{ + va_list va; + va_start(va, f); + FString out; + out.VFormat(f, va); + I_DebugPrint(out); +} + diff --git a/source/common/sound/s_soundinternal.h b/source/common/sound/s_soundinternal.h index 08cfff2c5..0fdc5d107 100644 --- a/source/common/sound/s_soundinternal.h +++ b/source/common/sound/s_soundinternal.h @@ -358,7 +358,7 @@ public: { return id == 0 ? "" : S_sfx[id].name.GetChars(); } - TArray &GetSounds() //Thio should only be used for constructing the sound list or for diagnostics code prinring information about the sound list. + TArray &GetSounds() //Thio should only be used for constructing the sound list or for diagnostics code printing information about the sound list. { return S_sfx; } From 95f917a40881ddc2988c85166f974f42f4baad9e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 12 Jan 2020 20:28:07 +0100 Subject: [PATCH 13/51] - added the main vertex buffer and some code to maintain it on systems where persistent mapping is not possible. All games combined there's 11(!!!) scene render blocks, not counting the sub-blocks for ROR and mirrors. Does it surprise anyone that most of these sub-blocks do not feature all engine capabilities? --- source/CMakeLists.txt | 1 + source/blood/src/view.cpp | 6 + .../rendering/gl/system/gl_framebuffer.cpp | 7 +- .../rendering/gl/system/gl_framebuffer.h | 2 - .../hwrenderer/data/flatvertices.cpp | 138 ++++++++++++++++++ .../rendering/hwrenderer/data/flatvertices.h | 98 +++++++++++++ source/common/rendering/v_framebuffer.cpp | 22 ++- source/common/rendering/v_video.h | 7 +- source/duke3d/src/game.cpp | 4 + source/duke3d/src/gameexec.cpp | 3 + source/duke3d/src/sector.cpp | 3 + source/exhumed/src/view.cpp | 3 + source/rr/src/game.cpp | 2 + source/rr/src/sector.cpp | 3 + source/sw/src/draw.cpp | 26 +--- source/sw/src/jsector.cpp | 3 + source/sw/src/save.cpp | 39 ----- 17 files changed, 299 insertions(+), 68 deletions(-) create mode 100644 source/common/rendering/hwrenderer/data/flatvertices.cpp create mode 100644 source/common/rendering/hwrenderer/data/flatvertices.h diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 25843c271..89aeae8e6 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -832,6 +832,7 @@ set (PCH_SOURCES common/rendering/gl/system/gl_debug.cpp common/rendering/gl/system/gl_framebuffer.cpp common/rendering/gl_load/gl_interface.cpp + common/rendering/hwrenderer/data/flatvertices.cpp common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp common/rendering/hwrenderer/utility/hw_shaderpatcher.cpp diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index dc3076ba5..da9b99db8 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -64,6 +64,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "menu/menu.h" #include "gstrings.h" #include "v_2ddrawer.h" +#include "v_video.h" CVARD(Bool, hud_powerupduration, true, CVAR_ARCHIVE|CVAR_FRONTEND_BLOOD, "enable/disable displaying the remaining seconds for power-ups") @@ -3226,6 +3227,7 @@ void viewDrawScreen(void) } else if (v4 && gNetPlayers > 1) { + int tmp = ((int)totalclock / 240) % (gNetPlayers - 1); int i = connecthead; while (1) @@ -3245,6 +3247,7 @@ void viewDrawScreen(void) } renderSetTarget(4079, 128, 128); renderSetAspect(65536, 78643); + screen->BeginScene(); int vd8 = pOther->pSprite->x; int vd4 = pOther->pSprite->y; int vd0 = pOther->zView; @@ -3307,6 +3310,7 @@ void viewDrawScreen(void) memcpy(gotpic + 510, bakMirrorGotpic, 2); viewProcessSprites(vd8, vd4, vd0, v50, gInterpolate); renderDrawMasks(); + screen->FinishScene(); renderRestoreTarget(); } else @@ -3347,6 +3351,7 @@ void viewDrawScreen(void) } nSprite = nextspritestat[nSprite]; } + screen->BeginScene(); g_visibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - unk, 0) * (numplayers > 1 ? 1.f : r_ambientlightrecip)); cA = (cA + interpolateangfix16(fix16_from_int(deliriumTurnO), fix16_from_int(deliriumTurn), gInterpolate)) & 0x7ffffff; int vfc, vf8; @@ -3400,6 +3405,7 @@ void viewDrawScreen(void) sub_557C4(cX, cY, gInterpolate); renderDrawMasks(); gView->pSprite->cstat = bakCstat; + screen->FinishScene(); if (v78 || bDelirium) { diff --git a/source/common/rendering/gl/system/gl_framebuffer.cpp b/source/common/rendering/gl/system/gl_framebuffer.cpp index 873edb0cb..dc6d86a34 100644 --- a/source/common/rendering/gl/system/gl_framebuffer.cpp +++ b/source/common/rendering/gl/system/gl_framebuffer.cpp @@ -45,6 +45,7 @@ #include "gl/system/gl_framebuffer.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderbuffers.h" +#include "hwrenderer/data/flatvertices.h" /* #include "gl/textures/gl_samplers.h" #include "hwrenderer/utility/hw_clock.h" @@ -105,8 +106,8 @@ OpenGLFrameBuffer::~OpenGLFrameBuffer() { PPResource::ResetAll(); -#ifdef IMPLEMENT_IT if (mVertexData != nullptr) delete mVertexData; +#ifdef IMPLEMENT_IT if (mSkyData != nullptr) delete mSkyData; if (mViewpoints != nullptr) delete mViewpoints; if (mLights != nullptr) delete mLights; @@ -171,8 +172,8 @@ void OpenGLFrameBuffer::InitializeState() SetViewportRects(nullptr); -#ifdef IMPLEMENT_IT mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight()); +#ifdef IMPLEMENT_IT mSkyData = new FSkyVertexBuffer; mViewpoints = new HWViewpointBuffer; mLights = new FLightBuffer(); @@ -305,6 +306,7 @@ FModelRenderer *OpenGLFrameBuffer::CreateModelRenderer(int mli) { return new FHWModelRenderer(nullptr, gl_RenderState, mli); } +#endif IVertexBuffer *OpenGLFrameBuffer::CreateVertexBuffer() { @@ -315,7 +317,6 @@ IIndexBuffer *OpenGLFrameBuffer::CreateIndexBuffer() { return new GLIndexBuffer; } -#endif IDataBuffer *OpenGLFrameBuffer::CreateDataBuffer(int bindingpoint, bool ssbo, bool needsresize) { diff --git a/source/common/rendering/gl/system/gl_framebuffer.h b/source/common/rendering/gl/system/gl_framebuffer.h index e0670a605..6b4a99db8 100644 --- a/source/common/rendering/gl/system/gl_framebuffer.h +++ b/source/common/rendering/gl/system/gl_framebuffer.h @@ -37,10 +37,8 @@ public: void BeginFrame() override; //void SetViewportRects(IntRect *bounds) override; void BlurScene(float amount) override; -#ifdef IMPLEMENT_IT IVertexBuffer *CreateVertexBuffer() override; IIndexBuffer *CreateIndexBuffer() override; -#endif IDataBuffer *CreateDataBuffer(int bindingpoint, bool ssbo, bool needsresize) override; // Retrieves a buffer containing image data for a screenshot. diff --git a/source/common/rendering/hwrenderer/data/flatvertices.cpp b/source/common/rendering/hwrenderer/data/flatvertices.cpp new file mode 100644 index 000000000..eae6a42e9 --- /dev/null +++ b/source/common/rendering/hwrenderer/data/flatvertices.cpp @@ -0,0 +1,138 @@ +/* +** hw_flatvertices.cpp +** Creates flat vertex data for hardware rendering. +** +**--------------------------------------------------------------------------- +** Copyright 2010-2020 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "c_cvars.h" +#include "flatvertices.h" +#include "v_video.h" +#include "cmdlib.h" +#include "hwrenderer/data/buffers.h" + +//========================================================================== +// +// +// +//========================================================================== + +FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) +{ + vbo_shadowdata.Resize(NUM_RESERVED); + + // the first quad is reserved for handling coordinates through uniforms. + vbo_shadowdata[0].Set(0, 0, 0, 0, 0); + vbo_shadowdata[1].Set(1, 0, 0, 0, 0); + vbo_shadowdata[2].Set(2, 0, 0, 0, 0); + vbo_shadowdata[3].Set(3, 0, 0, 0, 0); + + // and the second one for the fullscreen quad used for blend overlays. + vbo_shadowdata[4].Set(0, 0, 0, 0, 0); + vbo_shadowdata[5].Set(0, (float)height, 0, 0, 1); + vbo_shadowdata[6].Set((float)width, 0, 0, 1, 0); + vbo_shadowdata[7].Set((float)width, (float)height, 0, 1, 1); + + // and this is for the postprocessing copy operation + vbo_shadowdata[8].Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); + vbo_shadowdata[9].Set(-1.0f, 1.0f, 0, 0.0f, 1.f); + vbo_shadowdata[10].Set(1.0f, -1.0f, 0, 1.f, 0.0f); + vbo_shadowdata[11].Set(1.0f, 1.0f, 0, 1.f, 1.f); + + // The next two are the stencil caps. + vbo_shadowdata[12].Set(-32767.0f, 32767.0f, -32767.0f, 0, 0); + vbo_shadowdata[13].Set(-32767.0f, 32767.0f, 32767.0f, 0, 0); + vbo_shadowdata[14].Set(32767.0f, 32767.0f, 32767.0f, 0, 0); + vbo_shadowdata[15].Set(32767.0f, 32767.0f, -32767.0f, 0, 0); + + vbo_shadowdata[16].Set(-32767.0f, -32767.0f, -32767.0f, 0, 0); + vbo_shadowdata[17].Set(-32767.0f, -32767.0f, 32767.0f, 0, 0); + vbo_shadowdata[18].Set(32767.0f, -32767.0f, 32767.0f, 0, 0); + vbo_shadowdata[19].Set(32767.0f, -32767.0f, -32767.0f, 0, 0); + + mVertexBuffer = screen->CreateVertexBuffer(); + mIndexBuffer = screen->CreateIndexBuffer(); + + unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); + mVertexBuffer->SetData(bytesize, nullptr, false); + + static const FVertexBufferAttribute format[] = { + { 0, VATTR_VERTEX, VFmt_Float3, (int)myoffsetof(FFlatVertex, x) }, + { 0, VATTR_TEXCOORD, VFmt_Float2, (int)myoffsetof(FFlatVertex, u) } + }; + mVertexBuffer->SetFormat(1, 2, sizeof(FFlatVertex), format); + + mIndex = mCurIndex = 0; + mNumReserved = NUM_RESERVED; + Copy(0, NUM_RESERVED); +} + +//========================================================================== +// +// +// +//========================================================================== + +FFlatVertexBuffer::~FFlatVertexBuffer() +{ + delete mIndexBuffer; + delete mVertexBuffer; + mIndexBuffer = nullptr; + mVertexBuffer = nullptr; +} + +//========================================================================== +// +// +// +//========================================================================== + +void FFlatVertexBuffer::OutputResized(int width, int height) +{ + vbo_shadowdata[4].Set(0, 0, 0, 0, 0); + vbo_shadowdata[5].Set(0, (float)height, 0, 0, 1); + vbo_shadowdata[6].Set((float)width, 0, 0, 1, 0); + vbo_shadowdata[7].Set((float)width, (float)height, 0, 1, 1); + Copy(4, 4); +} + +//========================================================================== +// +// +// +//========================================================================== + +void FFlatVertexBuffer::Copy(int start, int count) +{ + Map(); + memcpy(GetBuffer(start), &vbo_shadowdata[0], count * sizeof(FFlatVertex)); + Unmap(); +} + diff --git a/source/common/rendering/hwrenderer/data/flatvertices.h b/source/common/rendering/hwrenderer/data/flatvertices.h new file mode 100644 index 000000000..58c383013 --- /dev/null +++ b/source/common/rendering/hwrenderer/data/flatvertices.h @@ -0,0 +1,98 @@ + +#ifndef _HW__VERTEXBUFFER_H +#define _HW__VERTEXBUFFER_H + +#include "tarray.h" +#include "hwrenderer/data/buffers.h" +#include +#include + +class FRenderState; +struct secplane_t; +struct subsector_t; + +struct FFlatVertex +{ + float x, z, y; // world position + float u, v; // texture coordinates + + void Set(float xx, float zz, float yy, float uu, float vv) + { + x = xx; + z = zz; + y = yy; + u = uu; + v = vv; + } +}; + +class FFlatVertexBuffer +{ + TArray vbo_shadowdata; + TArray ibo_data; + + IVertexBuffer *mVertexBuffer; + IIndexBuffer *mIndexBuffer; + + unsigned int mIndex; + std::atomic mCurIndex; + unsigned int mNumReserved; + + + static const unsigned int BUFFER_SIZE = 2000000; + static const unsigned int BUFFER_SIZE_TO_USE = 1999500; + +public: + enum + { + QUAD_INDEX = 0, + FULLSCREEN_INDEX = 4, + PRESENT_INDEX = 8, + STENCILTOP_INDEX = 12, + STENCILBOTTOM_INDEX = 16, + + NUM_RESERVED = 20 + }; + + FFlatVertexBuffer(int width, int height); + ~FFlatVertexBuffer(); + + void OutputResized(int width, int height); + std::pair GetBufferObjects() const + { + return std::make_pair(mVertexBuffer, mIndexBuffer); + } + + void Copy(int start, int count); + + FFlatVertex *GetBuffer(int index) const + { + FFlatVertex *ff = (FFlatVertex*)mVertexBuffer->Memory(); + return &ff[index]; + } + + FFlatVertex *GetBuffer() const + { + return GetBuffer(mCurIndex); + } + + std::pair AllocVertices(unsigned int count); + + void Reset() + { + mCurIndex = mIndex; + } + + void Map() + { + mVertexBuffer->Map(); + } + + void Unmap() + { + mVertexBuffer->Unmap(); + } + +}; + +#endif diff --git a/source/common/rendering/v_framebuffer.cpp b/source/common/rendering/v_framebuffer.cpp index 0782ae49e..854feb9c3 100644 --- a/source/common/rendering/v_framebuffer.cpp +++ b/source/common/rendering/v_framebuffer.cpp @@ -49,8 +49,8 @@ /* #include "hwrenderer/scene/hw_portal.h" #include "hwrenderer/utility/hw_clock.h" -#include "hwrenderer/data/flatvertices.h" */ +#include "hwrenderer/data/flatvertices.h" #include #include @@ -189,7 +189,7 @@ void DFrameBuffer::Update() { SetVirtualSize(clientWidth, clientHeight); V_OutputResized(clientWidth, clientHeight); - //mVertexData->OutputResized(clientWidth, clientHeight); + mVertexData->OutputResized(clientWidth, clientHeight); } } @@ -364,3 +364,21 @@ void DFrameBuffer::FPSLimit() } #endif } + +void DFrameBuffer::BeginScene() +{ + if (videoGetRenderMode() < REND_POLYMOST) return; + assert(BufferLock >= 0); + if (BufferLock++ == 0) + { + mVertexData->Map(); + } +} + +void DFrameBuffer::FinishScene() +{ + if (videoGetRenderMode() < REND_POLYMOST) return; + assert(BufferLock > 0); + if (--BufferLock == 0) + mVertexData->Unmap(); +} diff --git a/source/common/rendering/v_video.h b/source/common/rendering/v_video.h index 5904470c1..292b0b259 100644 --- a/source/common/rendering/v_video.h +++ b/source/common/rendering/v_video.h @@ -178,6 +178,7 @@ class FFont; struct FRemapTable; class player_t; typedef uint32_t angle_t; +struct RenderScene; // @@ -219,6 +220,7 @@ protected: private: int Width = 0; int Height = 0; + int BufferLock = 0; protected: int clipleft = 0, cliptop = 0, clipwidth = -1, clipheight = -1; @@ -233,7 +235,7 @@ public: const char *vendorstring; // We have to account for some issues with particular vendors. //FPortalSceneState *mPortalState; // global portal state. //FSkyVertexBuffer *mSkyData = nullptr; // the sky vertex buffer - //FFlatVertexBuffer *mVertexData = nullptr; // Global vertex data + FFlatVertexBuffer *mVertexData = nullptr; // Global vertex data //HWViewpointBuffer *mViewpoints = nullptr; // Viewpoint render data. //FLightBuffer *mLights = nullptr; // Dynamic lights //IShadowMap mShadowMap; @@ -313,6 +315,9 @@ public: void Begin2D() { isIn2D = true; } void End2D() { isIn2D = false; } + void BeginScene(); + void FinishScene(); + void End2DAndUpdate() { DrawRateStuff(); diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index e6a275ca4..450229c98 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -725,6 +725,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) "other values are reserved.\n"); #endif + screen->BeginScene(); #ifdef LEGACY_ROR G_SE40(smoothRatio); #endif @@ -737,6 +738,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) yax_drawrooms(G_DoSpriteAnimations, pSprite->sectnum, 0, smoothRatio); G_DoSpriteAnimations(pSprite->x, pSprite->y, pSprite->z - ZOFFSET6, fix16_to_int(CAMERA(q16ang)), smoothRatio); renderDrawMasks(); + screen->FinishScene(); } } else @@ -981,6 +983,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) OSD_Printf(OSD_ERROR "ERROR: EVENT_DISPLAYROOMS return value must be 0 or 1, " "other values are reserved.\n"); #endif + screen->BeginScene(); G_HandleMirror(CAMERA(pos.x), CAMERA(pos.y), CAMERA(pos.z), CAMERA(q16ang), CAMERA(q16horiz), smoothRatio); G_ClearGotMirror(); @@ -1010,6 +1013,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) #endif renderDrawMasks(); #endif + screen->FinishScene(); } if (g_screenCapture) diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 1ae2cb404..22273e3d9 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -42,6 +42,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "quotemgr.h" #include "mapinfo.h" #include "version.h" +#include "v_video.h" #include "debugbreak.h" @@ -1214,6 +1215,7 @@ LUNATIC_EXTERN void G_ShowView(vec3_t vec, fix16_t a, fix16_t horiz, int sect, i renderSetAspect(viewingRange, yxAspect); int const smoothratio = calc_smoothratio(totalclock, ototalclock); G_DoInterpolations(smoothratio); + screen->BeginScene(); if (!display_mirror) G_HandleMirror(vec.x, vec.y, vec.z, a, horiz, smoothratio); #ifdef POLYMER @@ -1228,6 +1230,7 @@ LUNATIC_EXTERN void G_ShowView(vec3_t vec, fix16_t a, fix16_t horiz, int sect, i G_DoSpriteAnimations(vec.x, vec.y, vec.z, fix16_to_int(a), smoothratio); display_mirror = 0; renderDrawMasks(); + screen->FinishScene(); G_RestoreInterpolations(); G_UpdateScreenArea(); renderSetAspect(viewingRange, yxAspect); diff --git a/source/duke3d/src/sector.cpp b/source/duke3d/src/sector.cpp index da4559472..376944cce 100644 --- a/source/duke3d/src/sector.cpp +++ b/source/duke3d/src/sector.cpp @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "printf.h" #include "secrets.h" +#include "v_video.h" BEGIN_DUKE_NS @@ -399,6 +400,7 @@ static void G_SetupCamTile(int spriteNum, int tileNum, int smoothRatio) OSD_Printf(OSD_ERROR "ERROR: EVENT_DISPLAYROOMSCAMERATILE return value must be 0 or 1, " "other values are reserved.\n"); #endif + screen->BeginScene(); yax_preparedrawrooms(); drawrooms(camera.x, camera.y, camera.z, SA(spriteNum), 100 + sprite[spriteNum].shade, SECT(spriteNum)); @@ -408,6 +410,7 @@ static void G_SetupCamTile(int spriteNum, int tileNum, int smoothRatio) G_DoSpriteAnimations(camera.x, camera.y, camera.z, SA(spriteNum), smoothRatio); display_mirror = saveMirror; renderDrawMasks(); + screen->FinishScene(); finishTileSetup: renderRestoreTarget(); diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index 583b73079..df8c9891c 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "engine.h" #include "trigdat.h" #include "runlist.h" +#include "v_video.h" #include BEGIN_PS_NS @@ -530,9 +531,11 @@ void DrawView(int smoothRatio) } } + screen->BeginScene(); renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa, nCamerapan, nSector); analyzesprites(); renderDrawMasks(); + screen->FinishScene(); if (HavePLURemap()) { diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 26c17862e..ccaf44f5e 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -1280,6 +1280,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) CAMERA(q16horiz) = fix16_clamp(CAMERA(q16horiz), F16(HORIZ_MIN), F16(HORIZ_MAX)); + screen->BeginScene(); G_HandleMirror(CAMERA(pos.x), CAMERA(pos.y), CAMERA(pos.z), CAMERA(q16ang), CAMERA(q16horiz), smoothRatio); #ifdef LEGACY_ROR if (!RR) @@ -1409,6 +1410,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) #endif renderDrawMasks(); #endif + screen->FinishScene(); if (g_screenCapture) { diff --git a/source/rr/src/sector.cpp b/source/rr/src/sector.cpp index 1333b1a88..7d39a13fa 100644 --- a/source/rr/src/sector.cpp +++ b/source/rr/src/sector.cpp @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "duke3d.h" #include "secrets.h" +#include "v_video.h" BEGIN_RR_NS @@ -505,6 +506,7 @@ static void G_SetupCamTile(int spriteNum, int tileNum, int smoothRatio) int const saveMirror = display_mirror; renderSetTarget(tileNum, tilesiz[tileNum].y, tilesiz[tileNum].x); + screen->BeginScene(); yax_preparedrawrooms(); drawrooms(camera.x, camera.y, camera.z, SA(spriteNum), 100 + sprite[spriteNum].shade, SECT(spriteNum)); @@ -514,6 +516,7 @@ static void G_SetupCamTile(int spriteNum, int tileNum, int smoothRatio) G_DoSpriteAnimations(camera.x, camera.y, camera.z, SA(spriteNum), smoothRatio); display_mirror = saveMirror; renderDrawMasks(); + screen->FinishScene(); renderRestoreTarget(); squarerotatetile(tileNum); diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index ce2b38c7b..f3ccadacf 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -58,6 +58,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "menu/menu.h" #include "swcvar.h" #include "v_2ddrawer.h" +#include "v_video.h" BEGIN_SW_NS @@ -2183,6 +2184,7 @@ drawscreen(PLAYERp pp) if (FAF_DebugView) videoClearViewableArea(255L); + screen->BeginScene(); OverlapDraw = TRUE; DrawOverlapRoom(tx, ty, tz, tang, thoriz, tsectnum); OverlapDraw = FALSE; @@ -2203,6 +2205,7 @@ drawscreen(PLAYERp pp) analyzesprites(tx, ty, tz, FALSE); post_analyzesprites(); renderDrawMasks(); + screen->FinishScene(); if (r_usenewaspect) { @@ -2439,29 +2442,9 @@ DrawCompass(PLAYERp pp) } -void ScreenTileLock(void) -{ -} -void ScreenTileUnLock(void) -{ -} - -int -ScreenLoadSaveSetup(PLAYERp pp) -{ - int tx, ty, tz,thoriz,pp_siz; - short tang,tsectnum; - short i; - - // lock and allocate memory - - ScreenTileLock(); - - TileFiles.tileCreate(SAVE_SCREEN_TILE, SAVE_SCREEN_XSIZE, SAVE_SCREEN_YSIZE); - return SAVE_SCREEN_TILE; -} +#if 0 int ScreenSaveSetup(PLAYERp pp) { @@ -2479,6 +2462,7 @@ ScreenSaveSetup(PLAYERp pp) return SAVE_SCREEN_TILE; } +#endif diff --git a/source/sw/src/jsector.cpp b/source/sw/src/jsector.cpp index 420df85bd..58a2a57ce 100644 --- a/source/sw/src/jsector.cpp +++ b/source/sw/src/jsector.cpp @@ -45,6 +45,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "lists.h" #include "pal.h" #include "parent.h" +#include "v_video.h" BEGIN_SW_NS @@ -472,10 +473,12 @@ void drawroomstotile(int daposx, int daposy, int daposz, TileFiles.tileCreate(tilenume, tilesiz[tilenume].x, tilesiz[tilenume].y); renderSetTarget(tilenume, tilesiz[tilenume].x, tilesiz[tilenume].y); + screen->BeginScene(); drawrooms(daposx, daposy, daposz, daang, dahoriz, dacursectnum); analyzesprites(daposx, daposy, daposz, FALSE); renderDrawMasks(); + screen->FinishScene(); renderRestoreTarget(); diff --git a/source/sw/src/save.cpp b/source/sw/src/save.cpp index 22447e94a..33b96a025 100644 --- a/source/sw/src/save.cpp +++ b/source/sw/src/save.cpp @@ -90,15 +90,6 @@ extern SWBOOL sumowasseen; extern SWBOOL zillawasseen; extern short BossSpriteNum[3]; -void ScreenTileLock(void); -void ScreenTileUnLock(void); - -int ScreenSaveSetup(PLAYERp pp); -void ScreenSave(MFILE_WRITE fout); - -int ScreenLoadSaveSetup(PLAYERp pp); -void ScreenLoad(MFILE_READ fin); - #define PANEL_SAVE 1 #define ANIM_SAVE 1 @@ -255,12 +246,6 @@ bool GameInterface::SaveGame(FSaveGameNode *sv) MWRITE(&Level,sizeof(Level),1,fil); MWRITE(&Skill,sizeof(Skill),1,fil); - ScreenSaveSetup(&Player[myconnectindex]); - - ScreenSave(fil); - - ScreenTileUnLock(); - MWRITE(&numplayers,sizeof(numplayers),1,fil); MWRITE(&myconnectindex,sizeof(myconnectindex),1,fil); MWRITE(&connecthead,sizeof(connecthead),1,fil); @@ -794,10 +779,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) MREAD(&Level,sizeof(Level),1,fil); MREAD(&Skill,sizeof(Skill),1,fil); - ScreenLoadSaveSetup(Player + myconnectindex); - ScreenLoad(fil); - ScreenTileUnLock(); - MREAD(&numplayers, sizeof(numplayers),1,fil); MREAD(&myconnectindex,sizeof(myconnectindex),1,fil); MREAD(&connecthead,sizeof(connecthead),1,fil); @@ -1287,24 +1268,4 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) return true; } -void -ScreenSave(MFILE_WRITE fout) -{ - // int num; - MWRITE((void *)tileData(SAVE_SCREEN_TILE), SAVE_SCREEN_XSIZE * SAVE_SCREEN_YSIZE, 1, fout); - // ASSERT(num == 1); -} - -void -ScreenLoad(MFILE_READ fin) -{ - int num; - - renderSetTarget(SAVE_SCREEN_TILE, SAVE_SCREEN_YSIZE, SAVE_SCREEN_XSIZE); - - num = MREAD(tileData(SAVE_SCREEN_TILE), SAVE_SCREEN_XSIZE * SAVE_SCREEN_YSIZE, 1, fin); - - renderRestoreTarget(); -} - END_SW_NS From dc5b8d27f8493aaae2c6d1e59b09be631e991b57 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 12 Jan 2020 23:16:21 +0100 Subject: [PATCH 14/51] - infrastructure for savegame pics. Savepic generation implemented for Duke 3D, but results in a black image. --- source/blood/src/loadsave.cpp | 2 - source/build/include/baselayer.h | 1 + source/build/src/engine.cpp | 2 - source/common/compositesavegame.cpp | 2 + source/common/menu/savegamemanager.cpp | 12 ++-- .../rendering/gl/renderer/gl_renderer.cpp | 64 ++++++++++++------- .../rendering/gl/renderer/gl_renderer.h | 4 +- .../rendering/gl/system/gl_framebuffer.cpp | 12 +++- .../rendering/gl/system/gl_framebuffer.h | 1 + source/common/rendering/v_framebuffer.cpp | 10 +++ source/common/rendering/v_video.h | 1 + source/common/savegamehelp.cpp | 29 +++++---- source/common/savegamehelp.h | 3 +- source/duke3d/src/demo.cpp | 2 +- source/duke3d/src/duke3d.h | 1 + source/duke3d/src/game.cpp | 44 ++++--------- source/duke3d/src/global.h | 1 - source/duke3d/src/savegame.cpp | 14 +--- source/duke3d/src/savegame.h | 2 +- source/exhumed/src/save.cpp | 4 -- source/rr/src/demo.cpp | 2 +- source/rr/src/savegame.cpp | 6 +- source/rr/src/savegame.h | 2 +- source/sw/src/save.cpp | 2 - 24 files changed, 113 insertions(+), 110 deletions(-) diff --git a/source/blood/src/loadsave.cpp b/source/blood/src/loadsave.cpp index 5ba194d5c..47f70287e 100644 --- a/source/blood/src/loadsave.cpp +++ b/source/blood/src/loadsave.cpp @@ -210,7 +210,6 @@ bool GameInterface::LoadGame(FSaveGameNode* node) bool GameInterface::SaveGame(FSaveGameNode* node) { - OpenSaveGameForWrite(node->Filename); LoadSave::hSFile = WriteSavegameChunk("snapshot.bld"); try @@ -231,7 +230,6 @@ bool GameInterface::SaveGame(FSaveGameNode* node) Printf(TEXTCOLOR_RED "%s\n", err.what()); return false; } - G_WriteSaveHeader(node->SaveTitle); LoadSave::hSFile = NULL; return FinishSavegameWrite(); diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index ff7713345..0eea5be5f 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -99,6 +99,7 @@ enum EMenuSounds : int; struct GameInterface { virtual ~GameInterface() {} + virtual bool GenerateSavePic() { return false; } virtual void faketimerhandler() {} // This is a remnant of older versions, but Blood backend has not updated yet. virtual int app_main() = 0; virtual void UpdateScreenSize() {} diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 567128913..7740d4f76 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -10787,5 +10787,3 @@ void renderSetRollAngle(int32_t rolla) gtang = (float)rolla * (fPI * (1.f/1024.f)); } #endif - - diff --git a/source/common/compositesavegame.cpp b/source/common/compositesavegame.cpp index 89814ed94..418565ad4 100644 --- a/source/common/compositesavegame.cpp +++ b/source/common/compositesavegame.cpp @@ -37,6 +37,8 @@ #include "compositesaveame.h" #include "file_zip.h" #include "resourcefile.h" +#include "m_png.h" +#include "gamecontrol.h" bool WriteZip(const char *filename, TArray &filenames, TArray &content); diff --git a/source/common/menu/savegamemanager.cpp b/source/common/menu/savegamemanager.cpp index 4a458a8ba..45bf519f1 100644 --- a/source/common/menu/savegamemanager.cpp +++ b/source/common/menu/savegamemanager.cpp @@ -64,13 +64,15 @@ void FSavegameManager::LoadGame(FSaveGameNode* node) void FSavegameManager::SaveGame(FSaveGameNode* node, bool ok4q, bool forceq) { - if (gi->SaveGame(node)) + if (OpenSaveGameForWrite(node->Filename, node->SaveTitle)) { - FString fn = node->Filename; - FString desc = node->SaveTitle; - NotifyNewSave(fn, desc, ok4q, forceq); + if (gi->SaveGame(node)) + { + FString fn = node->Filename; + FString desc = node->SaveTitle; + NotifyNewSave(fn, desc, ok4q, forceq); + } } - } //============================================================================= diff --git a/source/common/rendering/gl/renderer/gl_renderer.cpp b/source/common/rendering/gl/renderer/gl_renderer.cpp index 6b106a900..79402cbec 100644 --- a/source/common/rendering/gl/renderer/gl_renderer.cpp +++ b/source/common/rendering/gl/renderer/gl_renderer.cpp @@ -39,6 +39,7 @@ #include "filesystem.h" #include "i_time.h" #include "cmdlib.h" +#include "m_png.h" //#include "swrenderer/r_swscene.h" //#include "hwrenderer/utility/hw_clock.h" @@ -58,14 +59,13 @@ //#include "r_data/models/models.h" #include "gl/renderer/gl_postprocessstate.h" #include "gl/system/gl_buffers.h" +#include "build.h" EXTERN_CVAR(Int, screenblocks) EXTERN_CVAR(Bool, cl_capfps) extern bool NoInterpolateView; -void DoWriteSavePic(FileWriter *file, ESSType ssformat, uint8_t *scr, int width, int height, sector_t *viewsector, bool upsidedown); - namespace OpenGLRenderer { @@ -190,8 +190,7 @@ void FGLRenderer::BindToFrameBuffer(FMaterial *mat) // //=========================================================================== -#if 0 -void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, int height) +void FGLRenderer::WriteSavePic ( FileWriter *file, int width, int height) { IntRect bounds; bounds.left = 0; @@ -204,35 +203,52 @@ void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, i // Switch to render buffers dimensioned for the savepic mBuffers = mSaveBuffers; - - hw_ClearFakeFlat(); - gl_RenderState.SetVertexBuffer(screen->mVertexData); - screen->mVertexData->Reset(); - screen->mLights->Clear(); - screen->mViewpoints->Clear(); + mBuffers->BindSceneFB(false); + screen->SetViewportRects(&bounds); - // This shouldn't overwrite the global viewpoint even for a short time. - FRenderViewpoint savevp; - sector_t *viewsector = RenderViewpoint(savevp, players[consoleplayer].camera, &bounds, r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false); - glDisable(GL_STENCIL_TEST); - gl_RenderState.SetNoSoftLightLevel(); - CopyToBackbuffer(&bounds, false); + + int oldx = xdim; + int oldy = ydim; + auto oldwindowxy1 = windowxy1; + auto oldwindowxy2 = windowxy2; + + xdim = width; + ydim = height; + videoSetViewableArea(0, 0, width - 1, height - 1); + renderSetAspect(65536, 65536); + calc_ylookup(width, height); + bool didit = gi->GenerateSavePic(); + + xdim = oldx; + ydim = oldy; + videoSetViewableArea(oldwindowxy1.x, oldwindowxy1.y, oldwindowxy2.x, oldwindowxy2.y); + calc_ylookup(bytesperline, ydim); + modechange = 1; + + // The 2D drawers can contain some garbage from the dirty render setup. Get rid of that first. + twodgen.Clear(); + twodpsp.Clear(); + CopyToBackbuffer(&bounds, false); // strictly speaking not needed as the glReadPixels should block until the scene is rendered, but this is to safeguard against shitty drivers glFinish(); - int numpixels = width * height; - uint8_t * scr = (uint8_t *)M_Malloc(numpixels * 3); - glReadPixels(0,0,width, height,GL_RGB,GL_UNSIGNED_BYTE,scr); - - DoWriteSavePic(file, SS_RGB, scr, width, height, viewsector, true); - M_Free(scr); + if (didit) + { + int numpixels = width * height; + uint8_t* scr = (uint8_t*)Xmalloc(numpixels * 3); + glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, scr); + M_CreatePNG(file, scr + ((height - 1) * width), nullptr, SS_RGB, width, height, -width, vid_gamma); + Xfree(scr); + } // Switch back the screen render buffers screen->SetViewportRects(nullptr); mBuffers = mScreenBuffers; + bool useSSAO = (gl_ssao != 0); + mBuffers->BindSceneFB(useSSAO); } -#endif + //=========================================================================== // @@ -243,7 +259,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, i void FGLRenderer::BeginFrame() { mScreenBuffers->Setup(screen->mScreenViewport.width, screen->mScreenViewport.height, screen->mSceneViewport.width, screen->mSceneViewport.height); - //mSaveBuffers->Setup(SAVEPICWIDTH, SAVEPICHEIGHT, SAVEPICWIDTH, SAVEPICHEIGHT); + mSaveBuffers->Setup(240, 180, 240, 180); } } diff --git a/source/common/rendering/gl/renderer/gl_renderer.h b/source/common/rendering/gl/renderer/gl_renderer.h index 353ed3a44..f588440db 100644 --- a/source/common/rendering/gl/renderer/gl_renderer.h +++ b/source/common/rendering/gl/renderer/gl_renderer.h @@ -81,9 +81,7 @@ public: void DrawPresentTexture(const IntRect &box, bool applyGamma); void Flush(); //void Draw2D(F2DDrawer *data); -#if 0 - void WriteSavePic(player_t *player, FileWriter *file, int width, int height); -#endif + void WriteSavePic(FileWriter *file, int width, int height); void BeginFrame(); diff --git a/source/common/rendering/gl/system/gl_framebuffer.cpp b/source/common/rendering/gl/system/gl_framebuffer.cpp index dc6d86a34..b76b7bb35 100644 --- a/source/common/rendering/gl/system/gl_framebuffer.cpp +++ b/source/common/rendering/gl/system/gl_framebuffer.cpp @@ -209,6 +209,17 @@ void OpenGLFrameBuffer::Update() Super::Update(); } +//=========================================================================== +// +// Render the view to a savegame picture +// +//=========================================================================== + +void OpenGLFrameBuffer::WriteSavePic(FileWriter *file, int width, int height) +{ + GLRenderer->WriteSavePic(file, width, height); +} + const char* OpenGLFrameBuffer::DeviceName() const { @@ -468,4 +479,3 @@ void videoShowFrame(int32_t w) twodgen.Clear(); GLInterface.ResetFrame(); } - diff --git a/source/common/rendering/gl/system/gl_framebuffer.h b/source/common/rendering/gl/system/gl_framebuffer.h index 6b4a99db8..6f9b0e7c9 100644 --- a/source/common/rendering/gl/system/gl_framebuffer.h +++ b/source/common/rendering/gl/system/gl_framebuffer.h @@ -27,6 +27,7 @@ public: void CleanForRestart() override; const char* DeviceName() const override; + void WriteSavePic(FileWriter* file, int width, int height); #ifdef IMPLEMENT_IT void SetTextureFilterMode() override; IHardwareTexture *CreateHardwareTexture() override; diff --git a/source/common/rendering/v_framebuffer.cpp b/source/common/rendering/v_framebuffer.cpp index 854feb9c3..3ccb89de2 100644 --- a/source/common/rendering/v_framebuffer.cpp +++ b/source/common/rendering/v_framebuffer.cpp @@ -234,6 +234,16 @@ FTexture *DFrameBuffer::WipeEndScreen() return nullptr; } +//========================================================================== +// +// +// +//========================================================================== +void DFrameBuffer::WriteSavePic(FileWriter *file, int width, int height) +{ +} + + //========================================================================== // // Calculates the viewport values needed for 2D and 3D operations diff --git a/source/common/rendering/v_video.h b/source/common/rendering/v_video.h index 292b0b259..1351e2661 100644 --- a/source/common/rendering/v_video.h +++ b/source/common/rendering/v_video.h @@ -339,6 +339,7 @@ public: virtual int Backend() { return 0; } virtual const char* DeviceName() const { return "Unknown"; } virtual void Draw2D() {} + virtual void WriteSavePic(FileWriter *file, int width, int height); // Screen wiping virtual FTexture *WipeStartScreen(); diff --git a/source/common/savegamehelp.cpp b/source/common/savegamehelp.cpp index 84f681e2e..475173948 100644 --- a/source/common/savegamehelp.cpp +++ b/source/common/savegamehelp.cpp @@ -46,6 +46,7 @@ #include "s_music.h" #include "quotemgr.h" #include "mapinfo.h" +#include "v_video.h" static CompositeSavegameWriter savewriter; static FResourceFile *savereader; @@ -64,12 +65,6 @@ static FResourceFile *savereader; //============================================================================= -void OpenSaveGameForWrite(const char *name) -{ - savewriter.Clear(); - savewriter.SetFileName(name); -} - bool OpenSaveGameForRead(const char *name) { if (savereader) delete savereader; @@ -126,16 +121,20 @@ void FinishSavegameRead() //============================================================================= // -// Writes the header which is used to display the savegame in the menu. +// Creates the savegame and writes all cross-game content. // //============================================================================= -void G_WriteSaveHeader(const char *name) +bool OpenSaveGameForWrite(const char* filename, const char *name) { + savewriter.Clear(); + savewriter.SetFileName(filename); + sjson_context* ctx = sjson_create_context(0, 0, NULL); if (!ctx) { - return; + savewriter.Clear(); + return false; } sjson_node* root = sjson_mkobject(ctx); auto savesig = gi->GetSaveSig(); @@ -158,7 +157,11 @@ void G_WriteSaveHeader(const char *name) auto mapfile = fileSystem.GetFileContainer(fileno); auto mapcname = fileSystem.GetResourceFileName(mapfile); if (mapcname) sjson_put_string(ctx, root, "Map Resource", mapcname); - else return; // this should never happen. Saving on a map that isn't present is impossible. + else + { + savewriter.Clear(); + return false; // this should never happen. Saving on a map that isn't present is impossible. + } } char* encoded = sjson_stringify(ctx, root, " "); @@ -167,7 +170,8 @@ void G_WriteSaveHeader(const char *name) if (!fil) { sjson_destroy_context(ctx); - return; + savewriter.Clear(); + return false; } fil->Write(encoded, strlen(encoded)); @@ -180,6 +184,9 @@ void G_WriteSaveHeader(const char *name) SECRET_Save(); MUS_Save(); quoteMgr.WriteToSavegame(); + auto picfile = WriteSavegameChunk("savepic.png"); + screen->WriteSavePic(picfile, 240, 180); + return true; } //============================================================================= diff --git a/source/common/savegamehelp.h b/source/common/savegamehelp.h index a7e0f839d..a829a8443 100644 --- a/source/common/savegamehelp.h +++ b/source/common/savegamehelp.h @@ -2,7 +2,7 @@ #include "filesystem/resourcefile.h" -void OpenSaveGameForWrite(const char *name); +bool OpenSaveGameForWrite(const char *fname, const char *name); bool OpenSaveGameForRead(const char *name); FileWriter *WriteSavegameChunk(const char *name); @@ -16,7 +16,6 @@ class FileReader; FString G_BuildSaveName (const char *prefix); int G_ValidateSavegame(FileReader &fr, FString *savetitle, bool formenu); -void G_WriteSaveHeader(const char* name); #define SAVEGAME_EXT ".dsave" diff --git a/source/duke3d/src/demo.cpp b/source/duke3d/src/demo.cpp index 2f018cb6d..f9aa415d5 100644 --- a/source/duke3d/src/demo.cpp +++ b/source/duke3d/src/demo.cpp @@ -172,7 +172,7 @@ void G_OpenDemoWrite(void) if (g_demo_filePtr == NULL) return; - i=sv_saveandmakesnapshot(*g_demo_filePtr, nullptr, -1); + i=sv_saveandmakesnapshot(*g_demo_filePtr, -1); if (i) { delete g_demo_filePtr; diff --git a/source/duke3d/src/duke3d.h b/source/duke3d/src/duke3d.h index 18e49b7bd..3f257a104 100644 --- a/source/duke3d/src/duke3d.h +++ b/source/duke3d/src/duke3d.h @@ -145,6 +145,7 @@ struct GameInterface : ::GameInterface int app_main() override; void UpdateScreenSize() override; void FreeGameData() override; + bool GenerateSavePic() override; bool validate_hud(int) override; void set_hud_layout(int size) override; void set_hud_scale(int size) override; diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 450229c98..e3fe74915 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -762,14 +762,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) else renderSetAspect(mulscale16(vr, viewingrange), yxaspect); - if (g_screenCapture) - { - TileFiles.tileCreate(TILE_SAVESHOT, 200, 320); - - //if (videoGetRenderMode() == REND_CLASSIC) - renderSetTarget(TILE_SAVESHOT, 200, 320); - } - else if (screenTilting) + if (screenTilting) { int32_t oviewingrange = viewingrange; // save it from renderSetAspect() const int16_t tang = (ud.screen_tilting) ? pPlayer->rotscrnang : 0; @@ -850,23 +843,15 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) } else if (videoGetRenderMode() >= REND_POLYMOST) { - if (ud.screen_tilting -#ifdef SPLITSCREEN_MOD_HACKS - && !g_fakeMultiMode -#endif - ) + if (ud.screen_tilting) { -#ifdef USE_OPENGL renderSetRollAngle(pPlayer->orotscrnang + mulscale16(((pPlayer->rotscrnang - pPlayer->orotscrnang + 1024)&2047)-1024, smoothRatio)); -#endif pPlayer->orotscrnang = pPlayer->rotscrnang; } -#ifdef USE_OPENGL else { renderSetRollAngle(0); } -#endif } if (pPlayer->newowner < 0) @@ -1016,22 +1001,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) screen->FinishScene(); } - if (g_screenCapture) - { - g_screenCapture = 0; - - tileInvalidate(TILE_SAVESHOT, 0, 255); - - //if (videoGetRenderMode() == REND_CLASSIC) - { - renderRestoreTarget(); - } -#ifdef USE_OPENGL - //else - // G_ReadGLFrame(); -#endif - } - else if (screenTilting) + if (screenTilting) { const int16_t tang = (ud.screen_tilting) ? pPlayer->rotscrnang : 0; @@ -1115,6 +1085,14 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) VM_OnEvent(EVENT_DISPLAYROOMSEND, g_player[screenpeek].ps->i, screenpeek); } + +bool GameInterface::GenerateSavePic() +{ + G_DrawRooms(myconnectindex, 65536); + return true; +} + + void G_DumpDebugInfo(void) { static char const s_WEAPON[] = "WEAPON"; diff --git a/source/duke3d/src/global.h b/source/duke3d/src/global.h index 49e1a1e14..7be73c3b3 100644 --- a/source/duke3d/src/global.h +++ b/source/duke3d/src/global.h @@ -147,7 +147,6 @@ G_EXTERN input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS]; G_EXTERN int32_t g_noEnemies; G_EXTERN int32_t g_restorePalette; -G_EXTERN int32_t g_screenCapture; G_EXTERN projectile_t SpriteProjectile[MAXSPRITES]; G_EXTERN uint32_t everyothertime; G_EXTERN uint32_t g_moveThingsCount; diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp index 9910f4713..af50e2543 100644 --- a/source/duke3d/src/savegame.cpp +++ b/source/duke3d/src/savegame.cpp @@ -536,10 +536,6 @@ static void G_RestoreTimers(void) bool G_SavePlayer(FSaveGameNode *sv) { -#ifdef __ANDROID__ - G_SavePalette(); -#endif - G_SaveTimers(); Net_WaitForServer(); @@ -550,7 +546,6 @@ bool G_SavePlayer(FSaveGameNode *sv) errno = 0; FileWriter *fil; - OpenSaveGameForWrite(sv->Filename); fil = WriteSavegameChunk("snapshot.dat"); // The above call cannot fail. { @@ -564,7 +559,7 @@ bool G_SavePlayer(FSaveGameNode *sv) portableBackupSave(sv->Filename, sv->SaveTitle, ud.last_stateless_volume, ud.last_stateless_level); // SAVE! - sv_saveandmakesnapshot(fw, sv->SaveTitle, 0); + sv_saveandmakesnapshot(fw, 0); fw.Close(); @@ -620,9 +615,6 @@ bool GameInterface::SaveGame(FSaveGameNode* sv) else { videoNextPage(); // no idea if this is needed here. - g_screenCapture = 1; - //G_DrawRooms(myconnectindex, 65536); - g_screenCapture = 0; return G_SavePlayer(sv); } @@ -1361,7 +1353,7 @@ static void SV_AllocSnap(int32_t allocinit) } // make snapshot only if spot < 0 (demo) -int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot) +int32_t sv_saveandmakesnapshot(FileWriter &fil, int8_t spot) { savehead_t h; @@ -1400,8 +1392,6 @@ int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot) // savegame auto fw = WriteSavegameChunk("header.dat"); fw->Write(&h, sizeof(savehead_t)); - - G_WriteSaveHeader(name); } else { diff --git a/source/duke3d/src/savegame.h b/source/duke3d/src/savegame.h index 08f8d7213..9f4047b59 100644 --- a/source/duke3d/src/savegame.h +++ b/source/duke3d/src/savegame.h @@ -68,7 +68,7 @@ int32_t sv_readdiff(FileReader& fil); uint32_t sv_writediff(FileWriter *fil); int32_t sv_loadheader(FileReader &fil, int32_t spot, savehead_t *h); int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h); -int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot); +int32_t sv_saveandmakesnapshot(FileWriter &fil, int8_t spot); void sv_freemem(); int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh); void ReadSaveGameHeaders(void); diff --git a/source/exhumed/src/save.cpp b/source/exhumed/src/save.cpp index 9bb95088d..395e09dc9 100644 --- a/source/exhumed/src/save.cpp +++ b/source/exhumed/src/save.cpp @@ -40,10 +40,6 @@ static TArray sghelpers(TArray::NoInit); bool GameInterface::SaveGame(FSaveGameNode* sv) { - OpenSaveGameForWrite(sv->Filename); - // workaround until the level info here has been transitioned. - G_WriteSaveHeader(sv->SaveTitle); - auto fw = WriteSavegameChunk("engine"); fw->Write(&numsectors, sizeof(numsectors)); fw->Write(sector, sizeof(sectortype) * numsectors); diff --git a/source/rr/src/demo.cpp b/source/rr/src/demo.cpp index 048a681de..1d7c98801 100644 --- a/source/rr/src/demo.cpp +++ b/source/rr/src/demo.cpp @@ -172,7 +172,7 @@ void G_OpenDemoWrite(void) if (g_demo_filePtr == NULL) return; - i=sv_saveandmakesnapshot(*g_demo_filePtr, nullptr, -1, (demorec_seeds_cvar<<1)); + i=sv_saveandmakesnapshot(*g_demo_filePtr, -1, (demorec_seeds_cvar<<1)); if (i) { delete g_demo_filePtr; diff --git a/source/rr/src/savegame.cpp b/source/rr/src/savegame.cpp index 13a6c7bbc..58cfb724e 100644 --- a/source/rr/src/savegame.cpp +++ b/source/rr/src/savegame.cpp @@ -300,7 +300,6 @@ bool G_SavePlayer(FSaveGameNode *sv) errno = 0; FileWriter *fil; - OpenSaveGameForWrite(sv->Filename); fil = WriteSavegameChunk("snapshot.dat"); // The above call cannot fail. { @@ -311,7 +310,7 @@ bool G_SavePlayer(FSaveGameNode *sv) // SAVE! - sv_saveandmakesnapshot(fw, sv->SaveTitle, 0, 0); + sv_saveandmakesnapshot(fw, 0, 0); fw.Close(); @@ -1068,7 +1067,7 @@ static void SV_AllocSnap(int32_t allocinit) } // make snapshot only if spot < 0 (demo) -int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, bool isAutoSave) +int32_t sv_saveandmakesnapshot(FileWriter &fil, int8_t spot, bool isAutoSave) { savehead_t h; @@ -1105,7 +1104,6 @@ int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, b // savegame auto fw = WriteSavegameChunk("header.dat"); fw->Write(&h, sizeof(savehead_t)); - G_WriteSaveHeader(name); } else { diff --git a/source/rr/src/savegame.h b/source/rr/src/savegame.h index 9feb8950e..ea636988a 100644 --- a/source/rr/src/savegame.h +++ b/source/rr/src/savegame.h @@ -59,7 +59,7 @@ int32_t sv_readdiff(FileReader& fil); uint32_t sv_writediff(FileWriter *fil); int32_t sv_loadheader(FileReader &fil, int32_t spot, savehead_t *h); int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h); -int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, bool isAutoSave = false); +int32_t sv_saveandmakesnapshot(FileWriter &fil, int8_t spot, bool isAutoSave = false); void sv_freemem(); int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh); void ReadSaveGameHeaders(void); diff --git a/source/sw/src/save.cpp b/source/sw/src/save.cpp index 33b96a025..553c94f65 100644 --- a/source/sw/src/save.cpp +++ b/source/sw/src/save.cpp @@ -236,9 +236,7 @@ bool GameInterface::SaveGame(FSaveGameNode *sv) Saveable_Init(); - OpenSaveGameForWrite(sv->Filename); // workaround until the level info here has been transitioned. - G_WriteSaveHeader(sv->SaveTitle); fil = WriteSavegameChunk("snapshot.sw"); MWRITE(&GameVersion,sizeof(GameVersion),1,fil); From 6f3ccdc65111b60fc91032aef8a685950b84f986 Mon Sep 17 00:00:00 2001 From: NoOneBlood Date: Sat, 4 Jan 2020 03:20:41 +0300 Subject: [PATCH 15/51] - Combination switches fix (and basically all event commands) - No sound of jumping when player's jump velocity is too low --- source/blood/src/eventq.cpp | 8 +++++++- source/blood/src/player.cpp | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/blood/src/eventq.cpp b/source/blood/src/eventq.cpp index ef70f5305..26b16125e 100644 --- a/source/blood/src/eventq.cpp +++ b/source/blood/src/eventq.cpp @@ -353,7 +353,7 @@ char evGetSourceState(int nType, int nIndex) void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy) { - EVENT event; event.index = nIndex; event.type = nType; event.cmd = command; event.causedBy = causedBy; + switch (command) { case kCmdState: @@ -365,6 +365,12 @@ void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy) default: break; } + + EVENT event; + event.index = nIndex; + event.type = nType; + event.cmd = command; + event.causedBy = causedBy; switch (rxId) { case kChannelTextOver: diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index bc4c326d5..0a29544a5 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -1578,7 +1578,9 @@ void ProcessInput(PLAYER *pPlayer) break; default: if (!pPlayer->cantJump && pInput->buttonFlags.jump && pXSprite->height == 0) { - sfxPlay3DSound(pSprite, 700, 0, 0); + if ((packItemActive(pPlayer, 4) && pPosture->pwupJumpZ > 1000) || pPosture->normalJumpZ > 1000) + sfxPlay3DSound(pSprite, 700, 0, 0); + if (packItemActive(pPlayer, 4)) zvel[nSprite] = pPosture->pwupJumpZ; //-0x175555; else zvel[nSprite] = pPosture->normalJumpZ; //-0xbaaaa; pPlayer->cantJump = 1; From 4123a9e14ef092472468f24957719234143a596d Mon Sep 17 00:00:00 2001 From: NoOneBlood Date: Sun, 5 Jan 2020 16:48:22 +0300 Subject: [PATCH 16/51] - gModernMap guard instead of VanillaMode in dudeSpawn - No sound for player when jumping fix --- source/blood/src/player.cpp | 2 +- source/blood/src/triggers.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index 0a29544a5..07d1eaac7 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -1578,7 +1578,7 @@ void ProcessInput(PLAYER *pPlayer) break; default: if (!pPlayer->cantJump && pInput->buttonFlags.jump && pXSprite->height == 0) { - if ((packItemActive(pPlayer, 4) && pPosture->pwupJumpZ > 1000) || pPosture->normalJumpZ > 1000) + if ((packItemActive(pPlayer, 4) && pPosture->pwupJumpZ != 0) || pPosture->normalJumpZ != 0) sfxPlay3DSound(pSprite, 700, 0, 0); if (packItemActive(pPlayer, 4)) zvel[nSprite] = pPosture->pwupJumpZ; //-0x175555; diff --git a/source/blood/src/triggers.cpp b/source/blood/src/triggers.cpp index 1c7080a7f..61061de88 100644 --- a/source/blood/src/triggers.cpp +++ b/source/blood/src/triggers.cpp @@ -1275,7 +1275,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) spritetype* pSpawn = NULL; // By NoOne: add spawn random dude feature - works only if at least 2 data fields are not empty. - if (!VanillaMode()) { + if (gModernMap) { if ((pSpawn = spawnRandomDude(pSprite)) == NULL) pSpawn = actSpawnDude(pSprite, pXSprite->data1, -1, 0); } else { From 2b36e537066a16c2a47bbc4478652b9cdf1170ff Mon Sep 17 00:00:00 2001 From: NoOneBlood Date: Sun, 12 Jan 2020 00:07:05 +0300 Subject: [PATCH 17/51] - Removed event.causedBy for demo playback compatibility - Fixed kThingArmedRemote in triggers.cpp (OperateSprite()) - Fixed kTrapFlame in triggers.cpp (OperateSprite()) # Conflicts: # source/blood/src/actor.cpp # source/blood/src/player.h --- source/blood/src/actor.cpp | 50 ++-- source/blood/src/aicult.cpp | 4 +- source/blood/src/aiunicult.cpp | 2 +- source/blood/src/callback.cpp | 6 +- source/blood/src/eventq.cpp | 12 +- source/blood/src/eventq.h | 7 +- source/blood/src/player.cpp | 36 +-- source/blood/src/player.h | 16 +- source/blood/src/triggers.cpp | 448 ++++++++++++++++----------------- source/blood/src/triggers.h | 10 +- source/blood/src/weapon.cpp | 22 +- 11 files changed, 297 insertions(+), 316 deletions(-) diff --git a/source/blood/src/actor.cpp b/source/blood/src/actor.cpp index db14951ee..2c26951b4 100644 --- a/source/blood/src/actor.cpp +++ b/source/blood/src/actor.cpp @@ -3235,7 +3235,7 @@ void actKillDude(int nKillerSprite, spritetype *pSprite, DAMAGE_TYPE damageType, gPlayer[p].fraggerId = -1; } if (pSprite->type != kDudeCultistBeast) - trTriggerSprite(pSprite->index, pXSprite, kCmdOff, nKillerSprite); + trTriggerSprite(pSprite->index, pXSprite, kCmdOff); pSprite->flags |= 7; if (VanillaMode()) { @@ -3747,7 +3747,7 @@ int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, in break; } - trTriggerSprite(pSprite->index, pXSprite, kCmdOff, nSource); + trTriggerSprite(pSprite->index, pXSprite, kCmdOff); switch (pSprite->type) { case kThingObjectGib: @@ -4501,7 +4501,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite) if (spriRangeIsFine(nHSprite) && xspriRangeIsFine(sprite[nHSprite].extra)) { XSPRITE* pXHSprite = &xsprite[sprite[nHSprite].extra]; if (pXHSprite->Touch && !pXHSprite->isTriggered && (!pXHSprite->DudeLockout || IsPlayerSprite(pSprite))) - trTriggerSprite(nHSprite, pXHSprite, kCmdSpriteTouch, nSprite); + trTriggerSprite(nHSprite, pXHSprite, kCmdSpriteTouch); } // Touch walls @@ -4511,7 +4511,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite) if (wallRangeIsFine(nHWall) && xwallRangeIsFine(wall[nHWall].extra)) { XWALL* pXHWall = &xwall[wall[nHWall].extra]; if (pXHWall->triggerTouch && !pXHWall->isTriggered && (!pXHWall->dudeLockout || IsPlayerSprite(pSprite))) - trTriggerWall(nHWall, pXHWall, kCmdWallTouch, nSprite); + trTriggerWall(nHWall, pXHWall, kCmdWallTouch); } } @@ -4798,10 +4798,10 @@ void MoveDude(spritetype *pSprite) } if (!gModernMap && pHitXSprite && pHitXSprite->Touch && !pHitXSprite->state && !pHitXSprite->isTriggered) - trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpriteTouch, nSprite); + trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpriteTouch); if (pDudeInfo->lockOut && pHitXSprite && pHitXSprite->Push && !pHitXSprite->key && !pHitXSprite->DudeLockout && !pHitXSprite->state && !pHitXSprite->busy && !pPlayer) - trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpritePush, nSprite); + trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpritePush); break; } @@ -4813,7 +4813,7 @@ void MoveDude(spritetype *pSprite) if (pHitWall->extra > 0) pHitXWall = &xwall[pHitWall->extra]; if (pDudeInfo->lockOut && pHitXWall && pHitXWall->triggerPush && !pHitXWall->key && !pHitXWall->dudeLockout && !pHitXWall->state && !pHitXWall->busy && !pPlayer) - trTriggerWall(nHitWall, pHitXWall, kCmdWallPush, nSprite); + trTriggerWall(nHitWall, pHitXWall, kCmdWallPush); if (pHitWall->nextsector != -1) { sectortype *pHitSector = §or[pHitWall->nextsector]; @@ -4821,7 +4821,7 @@ void MoveDude(spritetype *pSprite) if (pHitSector->extra > 0) pHitXSector = &xsector[pHitSector->extra]; if (pDudeInfo->lockOut && pHitXSector && pHitXSector->Wallpush && !pHitXSector->Key && !pHitXSector->dudeLockout && !pHitXSector->state && !pHitXSector->busy && !pPlayer) - trTriggerSector(pHitWall->nextsector, pHitXSector, kCmdSectorPush, nSprite); + trTriggerSector(pHitWall->nextsector, pHitXSector, kCmdSectorPush); if (top < pHitSector->ceilingz || bottom > pHitSector->floorz) { // ??? @@ -4847,7 +4847,7 @@ void MoveDude(spritetype *pSprite) else pXSector = NULL; if (pXSector && pXSector->Exit && (pPlayer || !pXSector->dudeLockout)) - trTriggerSector(pSprite->sectnum, pXSector, kCmdSectorExit, nSprite); + trTriggerSector(pSprite->sectnum, pXSector, kCmdSectorExit); ChangeSpriteSect(nSprite, nSector); nXSector = sector[nSector].extra; @@ -4856,7 +4856,7 @@ void MoveDude(spritetype *pSprite) if (sector[nSector].type == kSectorTeleport) pXSector->data = pPlayer ? nSprite : -1; - trTriggerSector(nSector, pXSector, kCmdSectorEnter, nSprite); + trTriggerSector(nSector, pXSector, kCmdSectorEnter); } nSector = pSprite->sectnum; @@ -5359,7 +5359,7 @@ int MoveMissile(spritetype *pSprite) XWALL *pXWall = &xwall[pWall->extra]; if (pXWall->triggerVector) { - trTriggerWall(gHitInfo.hitwall, pXWall, kCmdWallImpact, nSprite); + trTriggerWall(gHitInfo.hitwall, pXWall, kCmdWallImpact); if (!(pWall->cstat&64)) { vdi = -1; @@ -5428,7 +5428,7 @@ void actExplodeSprite(spritetype *pSprite) return; sfxKill3DSound(pSprite, -1, -1); evKill(pSprite->index, 3); - int nType = kExplosionStandard; + int nType; switch (pSprite->type) { case kMissileFireballNapam: @@ -5623,7 +5623,7 @@ void actProcessSprites(void) if ((sprite[nAffected].flags & 32) || xsprite[sprite[nAffected].extra].health <= 0) continue; else if (CheckProximity(&sprite[nAffected], x, y, z, sectnum, 96)) { - trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity, nAffected); + trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity); break; } } @@ -5632,7 +5632,7 @@ void actProcessSprites(void) for (int a = connecthead; a >= 0; a = connectpoint2[a]) { if (gPlayer[a].pXSprite->health > 0 && CheckProximity(gPlayer[a].pSprite, x, y, z, sectnum, 96)) { - trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity, gPlayer[a].pSprite->index); + trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity); break; } } @@ -5657,7 +5657,7 @@ void actProcessSprites(void) for (int a = connecthead; a >= 0; a = connectpoint2[a]) { spritetype* pPlaySprite = gPlayer[a].pSprite; if (gPlayer[a].pXSprite->health > 0 && cansee(x, y, z, sectnum, pPlaySprite->x, pPlaySprite->y, pPlaySprite->z, pPlaySprite->sectnum)) { - trTriggerSprite(index, pXSightSpr, kCmdSpriteSight, pPlaySprite->index); + trTriggerSprite(index, pXSightSpr, kCmdSpriteSight); break; } } @@ -5803,7 +5803,7 @@ void actProcessSprites(void) break; } if (pSprite->owner == -1) actPropagateSpriteOwner(pSprite, pSprite2); - trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity, pSprite2->index); + trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity); } } } @@ -5879,7 +5879,7 @@ void actProcessSprites(void) { XSPRITE *pXSprite = &xsprite[nXSprite]; if (pXSprite->Impact) - trTriggerSprite(nSprite, pXSprite, kCmdOff, -1); + trTriggerSprite(nSprite, pXSprite, kCmdOff); switch (pSprite->type) { case kThingDripWater: case kThingDripBlood: @@ -5986,7 +5986,7 @@ void actProcessSprites(void) if (nWall == -1) break; XWALL *pXWall = &xwall[wall[nWall].extra]; - trTriggerWall(nWall, pXWall, kCmdWallImpact, nSprite); + trTriggerWall(nWall, pXWall, kCmdWallImpact); } for (int nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) @@ -6169,7 +6169,7 @@ void actProcessSprites(void) pXIncarnation->triggerOff = false; // trigger dude death before transform - trTriggerSprite(nSprite, pXSprite, kCmdOff, pSprite->owner); + trTriggerSprite(nSprite, pXSprite, kCmdOff); pSprite->type = pIncarnation->type; pSprite->flags = pIncarnation->flags; @@ -6257,7 +6257,7 @@ void actProcessSprites(void) } else { if (pXSprite->sysData1 == kGenDudeTransformStatus) pXSprite->sysData1 = 0; // just trigger dude death - trTriggerSprite(nSprite, pXSprite, kCmdOff, pSprite->owner); + trTriggerSprite(nSprite, pXSprite, kCmdOff); } } } @@ -6285,7 +6285,7 @@ void actProcessSprites(void) XSPRITE *pXSprite2 = &xsprite[pSprite2->extra]; if ((unsigned int)pXSprite2->health > 0 && IsPlayerSprite(pSprite2)) { if (CheckProximity(pSprite2, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 128)) - trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity, pSprite2->index); + trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity); } } } @@ -6961,7 +6961,7 @@ void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6, { XWALL *pXWall = &xwall[nXWall]; if (pXWall->triggerVector) - trTriggerWall(nWall, pXWall, kCmdWallImpact, nShooter); + trTriggerWall(nWall, pXWall, kCmdWallImpact); } break; } @@ -6983,7 +6983,7 @@ void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6, { XSPRITE *pXSprite = &xsprite[nXSprite]; if (pXSprite->Vector) - trTriggerSprite(nSprite, pXSprite, kCmdSpriteImpact, nShooter); + trTriggerSprite(nSprite, pXSprite, kCmdSpriteImpact); } if (pSprite->statnum == kStatThing) { @@ -7857,8 +7857,8 @@ void debrisMove(int listIndex) { changespritestat(nSprite, kStatThing); - if (pXDebris->state == 1) trTriggerSprite(pSprite->xvel, pXDebris, kCmdOff, -1); - else trTriggerSprite(pSprite->xvel, pXDebris, kCmdOn, -1); + if (pXDebris->state == 1) trTriggerSprite(pSprite->xvel, pXDebris, kCmdOff); + else trTriggerSprite(pSprite->xvel, pXDebris, kCmdOn); } } diff --git a/source/blood/src/aicult.cpp b/source/blood/src/aicult.cpp index 086bc27f4..317bfae86 100644 --- a/source/blood/src/aicult.cpp +++ b/source/blood/src/aicult.cpp @@ -181,7 +181,7 @@ static void ThrowSeqCallback(int, int nXSprite) if (v4) xsprite[pMissile->extra].Impact = 1; else - evPost(pMissile->index, 3, 120*(1+Random(2)), kCmdOn, nSprite); + evPost(pMissile->index, 3, 120*(1+Random(2)), kCmdOn); } static void sub_68170(int, int nXSprite) @@ -194,7 +194,7 @@ static void sub_68170(int, int nXSprite) nMissile = kThingArmedTNTBundle; sfxPlay3DSound(pSprite, 455, -1, 0); spritetype *pMissile = actFireThing(pSprite, 0, 0, gDudeSlope[nXSprite]-9460, nMissile, 0x133333); - evPost(pMissile->index, 3, 120*(2+Random(2)), kCmdOn, nSprite); + evPost(pMissile->index, 3, 120*(2+Random(2)), kCmdOn); } static void sub_68230(int, int nXSprite) diff --git a/source/blood/src/aiunicult.cpp b/source/blood/src/aiunicult.cpp index 388bf9799..6940349d8 100644 --- a/source/blood/src/aiunicult.cpp +++ b/source/blood/src/aiunicult.cpp @@ -400,7 +400,7 @@ static void ThrowThing(int nXIndex, bool impact) { if (impact == true && dist <= 7680) xsprite[pThing->extra].Impact = true; else { xsprite[pThing->extra].Impact = false; - evPost(pThing->xvel, 3, 120 * Random(2) + 120, kCmdOn, pXSprite->reference); + evPost(pThing->xvel, 3, 120 * Random(2) + 120, kCmdOn); } } diff --git a/source/blood/src/callback.cpp b/source/blood/src/callback.cpp index 4dc66fb51..6ed39027d 100644 --- a/source/blood/src/callback.cpp +++ b/source/blood/src/callback.cpp @@ -361,7 +361,7 @@ void CounterCheck(int nSector) // 12 return; } else { //pXSector->waitTimeA = 0; //do not reset necessary objects counter to zero - trTriggerSector(nSector, pXSector, kCmdOn, -1); + trTriggerSector(nSector, pXSector, kCmdOn); pXSector->locked = 1; //lock sector, so it can be opened again later } } @@ -489,13 +489,13 @@ void returnFlagToBase(int nSprite) // 17 XSPRITE* pXOwner = &xsprite[pOwner->extra]; switch (pSprite->type) { case kItemFlagA: - trTriggerSprite(pOwner->index, pXOwner, kCmdOn, pOwner->index); + trTriggerSprite(pOwner->index, pXOwner, kCmdOn); sndStartSample(8003, 255, 2, 0); gBlueFlagDropped = false; viewSetMessage("Blue Flag returned to base."); break; case kItemFlagB: - trTriggerSprite(pOwner->index, pXOwner, kCmdOn, pOwner->index); + trTriggerSprite(pOwner->index, pXOwner, kCmdOn); sndStartSample(8002, 255, 2, 0); gRedFlagDropped = false; viewSetMessage("Red Flag returned to base."); diff --git a/source/blood/src/eventq.cpp b/source/blood/src/eventq.cpp index 26b16125e..f66c17eb8 100644 --- a/source/blood/src/eventq.cpp +++ b/source/blood/src/eventq.cpp @@ -351,7 +351,7 @@ char evGetSourceState(int nType, int nIndex) return 0; } -void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy) +void evSend(int nIndex, int nType, int rxId, COMMAND_ID command) { @@ -370,7 +370,6 @@ void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy) event.index = nIndex; event.type = nType; event.cmd = command; - event.causedBy = causedBy; switch (rxId) { case kChannelTextOver: @@ -452,9 +451,6 @@ void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy) if ((pPlayer = getPlayerById(i)) != NULL) trMessageSprite(pPlayer->nSprite, event); } - // send command on sprite which create the event sequence - } else if (rxId == kChannelEventCauser && spriRangeIsFine(event.causedBy)) { - trMessageSprite(event.causedBy, event); } } @@ -488,7 +484,7 @@ void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy) } } -void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command, short causedBy) { +void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command) { dassert(command != kCmdCallback); if (command == kCmdState) command = evGetSourceState(nType, nIndex) ? kCmdOn : kCmdOff; else if (command == kCmdNotState) command = evGetSourceState(nType, nIndex) ? kCmdOff : kCmdOn; @@ -496,17 +492,15 @@ void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command, shor evn.index = nIndex; evn.type = nType; evn.cmd = command; - evn.causedBy = causedBy; eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn); } -void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID callback, short causedBy) { +void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID callback) { EVENT evn = {}; evn.index = nIndex; evn.type = nType; evn.cmd = kCmdCallback; evn.funcID = callback; - evn.causedBy = causedBy; eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn); } diff --git a/source/blood/src/eventq.h b/source/blood/src/eventq.h index 057cbcf70..1c576194c 100644 --- a/source/blood/src/eventq.h +++ b/source/blood/src/eventq.h @@ -129,14 +129,13 @@ struct EVENT { unsigned int type: 3; // type unsigned int cmd: 8; // cmd unsigned int funcID: 8; // callback - signed int causedBy: 14; // by NoOne: spritenum of object which initiated this event (-1 == initiated by the game) }; void evInit(void); char evGetSourceState(int nType, int nIndex); -void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy); -void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command, short causedBy); -void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID callback, short causedBy = -1); +void evSend(int nIndex, int nType, int rxId, COMMAND_ID command); +void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command); +void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID callback); void evProcess(unsigned int nTime); void evKill(int a1, int a2); void evKill(int a1, int a2, CALLBACK_ID a3); diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index 07d1eaac7..1749230ad 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -991,7 +991,7 @@ void playerResetPosture(PLAYER* pPlayer) { void playerResetQavScene(PLAYER* pPlayer) { QAVSCENE* pQavScene = &gPlayerCtrl[pPlayer->nPlayer].qavScene; - pQavScene->index = pQavScene->causedBy = pPlayer->sceneQav = -1; + pQavScene->index = pQavScene->dummy = pPlayer->sceneQav = -1; pQavScene->qavResrc = NULL; } @@ -1062,7 +1062,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) { if ((pPlayer->hasFlag & 1) == 0 && pXItem->state) { pPlayer->hasFlag |= 1; pPlayer->used2[0] = pItem->index; - trTriggerSprite(pItem->index, pXItem, kCmdOff, pPlayer->nSprite); + trTriggerSprite(pItem->index, pXItem, kCmdOff); sprintf(buffer, "%s stole Blue Flag", gProfile[pPlayer->nPlayer].name); sndStartSample(8007, 255, 2, 0); viewSetMessage(buffer); @@ -1074,7 +1074,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) { if ((pPlayer->hasFlag & 1) != 0 && !pXItem->state) { pPlayer->hasFlag &= ~1; pPlayer->used2[0] = -1; - trTriggerSprite(pItem->index, pXItem, kCmdOn, pPlayer->nSprite); + trTriggerSprite(pItem->index, pXItem, kCmdOn); sprintf(buffer, "%s returned Blue Flag", gProfile[pPlayer->nPlayer].name); sndStartSample(8003, 255, 2, 0); viewSetMessage(buffer); @@ -1085,7 +1085,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) { pPlayer->used2[1] = -1; dword_21EFB0[pPlayer->teamId] += 10; dword_21EFD0[pPlayer->teamId] += 240; - evSend(0, 0, 81, kCmdOn, pPlayer->nSprite); + evSend(0, 0, 81, kCmdOn); sprintf(buffer, "%s captured Red Flag!", gProfile[pPlayer->nPlayer].name); sndStartSample(8001, 255, 2, 0); viewSetMessage(buffer); @@ -1106,7 +1106,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) { if ((pPlayer->hasFlag & 2) == 0 && pXItem->state) { pPlayer->hasFlag |= 2; pPlayer->used2[1] = pItem->index; - trTriggerSprite(pItem->index, pXItem, kCmdOff, pPlayer->nSprite); + trTriggerSprite(pItem->index, pXItem, kCmdOff); sprintf(buffer, "%s stole Red Flag", gProfile[pPlayer->nPlayer].name); sndStartSample(8006, 255, 2, 0); viewSetMessage(buffer); @@ -1118,7 +1118,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) { { pPlayer->hasFlag &= ~2; pPlayer->used2[1] = -1; - trTriggerSprite(pItem->index, pXItem, kCmdOn, pPlayer->nSprite); + trTriggerSprite(pItem->index, pXItem, kCmdOn); sprintf(buffer, "%s returned Red Flag", gProfile[pPlayer->nPlayer].name); sndStartSample(8002, 255, 2, 0); viewSetMessage(buffer); @@ -1129,7 +1129,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) { pPlayer->used2[0] = -1; dword_21EFB0[pPlayer->teamId] += 10; dword_21EFD0[pPlayer->teamId] += 240; - evSend(0, 0, 80, kCmdOn, pPlayer->nSprite); + evSend(0, 0, 80, kCmdOn); sprintf(buffer, "%s captured Blue Flag!", gProfile[pPlayer->nPlayer].name); sndStartSample(8000, 255, 2, 0); viewSetMessage(buffer); @@ -1305,7 +1305,7 @@ void PickUp(PLAYER *pPlayer, spritetype *pSprite) else if (pSprite->extra > 0) { XSPRITE *pXSprite = &xsprite[pSprite->extra]; if (pXSprite->Pickup) - trTriggerSprite(pSprite->index, pXSprite, kCmdSpritePickup, pPlayer->nSprite); + trTriggerSprite(pSprite->index, pXSprite, kCmdSpritePickup); } if (!actCheckRespawn(pSprite)) @@ -1400,7 +1400,7 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3) zvel[*a2] += mulscale16(z, t2); } if (pXSprite->Push && !pXSprite->state && !pXSprite->isTriggered) - trTriggerSprite(*a2, pXSprite, kCmdSpritePush, pPlayer->nSprite); + trTriggerSprite(*a2, pXSprite, kCmdSpritePush); } break; case 0: @@ -1607,7 +1607,7 @@ void ProcessInput(PLAYER *pPlayer) sndStartSample(3062, 255, 2, 0); } if (!key || pPlayer->hasKey[key]) - trTriggerSector(a2, pXSector, kCmdSpritePush, nSprite); + trTriggerSector(a2, pXSector, kCmdSpritePush); else if (pPlayer == gMe) { viewSetMessage(GStrings("TXTB_KEY")); @@ -1625,7 +1625,7 @@ void ProcessInput(PLAYER *pPlayer) sndStartSample(3062, 255, 2, 0); } if (!key || pPlayer->hasKey[key]) - trTriggerWall(a2, pXWall, kCmdWallPush, pPlayer->nSprite); + trTriggerWall(a2, pXWall, kCmdWallPush); else if (pPlayer == gMe) { viewSetMessage(GStrings("TXTB_KEY")); @@ -1640,7 +1640,7 @@ void ProcessInput(PLAYER *pPlayer) if (pXSprite->locked && pPlayer == gMe && pXSprite->lockMsg) trTextOver(pXSprite->lockMsg); if (!key || pPlayer->hasKey[key]) - trTriggerSprite(a2, pXSprite, kCmdSpritePush, pPlayer->nSprite); + trTriggerSprite(a2, pXSprite, kCmdSpritePush); else if (pPlayer == gMe) { viewSetMessage(GStrings("TXTB_KEY")); @@ -2012,16 +2012,16 @@ void FragPlayer(PLAYER *pPlayer, int nSprite) if (nTeam1 == 0) { if (nTeam1 != nTeam2) - evSend(0, 0, 15, kCmdToggle, pKiller->nSprite); + evSend(0, 0, 15, kCmdToggle); else - evSend(0, 0, 16, kCmdToggle, pKiller->nSprite); + evSend(0, 0, 16, kCmdToggle); } else { if (nTeam1 == nTeam2) - evSend(0, 0, 16, kCmdToggle, pKiller->nSprite); + evSend(0, 0, 16, kCmdToggle); else - evSend(0, 0, 15, kCmdToggle, pKiller->nSprite); + evSend(0, 0, 15, kCmdToggle); } } } @@ -2203,7 +2203,7 @@ int playerDamageSprite(int nSource, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, in { powerupClear(pPlayer); if (nXSector > 0 && xsector[nXSector].Exit) - trTriggerSector(pSprite->sectnum, &xsector[nXSector], kCmdSectorExit, nSprite); + trTriggerSector(pSprite->sectnum, &xsector[nXSector], kCmdSectorExit); pSprite->flags |= 7; for (int p = connecthead; p >= 0; p = connectpoint2[p]) { @@ -2211,7 +2211,7 @@ int playerDamageSprite(int nSource, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, in gPlayer[p].fraggerId = -1; } FragPlayer(pPlayer, nSource); - trTriggerSprite(nSprite, pXSprite, kCmdOff, nSource); + trTriggerSprite(nSprite, pXSprite, kCmdOff); } dassert(gSysRes.Lookup(pDudeInfo->seqStartID + nDeathSeqID, "SEQ") != NULL); seqSpawn(pDudeInfo->seqStartID+nDeathSeqID, 3, nXSprite, nKneelingPlayer); diff --git a/source/blood/src/player.h b/source/blood/src/player.h index 4a9c29732..a964294ee 100644 --- a/source/blood/src/player.h +++ b/source/blood/src/player.h @@ -202,8 +202,6 @@ struct PLAYER POSTURE pPosture[kModeMax][kPostureMax]; }; - - struct PROFILE { int nAutoAim; @@ -226,21 +224,15 @@ struct POWERUPINFO int maxTime; }; - -#define kQavSceneStackSize 16 // by NoOne: this one stores qavs anims that can be played by trigger -struct QAVSCENE -{ - short index = -1; // index of sprite which triggered qav scene +struct QAVSCENE { + short index = -1; // index of sprite which triggered qav scene QAV * qavResrc = NULL; - short causedBy = -1; - - // TO-DO: Stack of animations which allows to pop and push (restoring previous animation instead of weapon once current animation is played) + short dummy = -1; }; // by NoOne: this one for controlling the player using triggers (movement speed, jumps and other stuff) -struct TRPLAYERCTRL -{ +struct TRPLAYERCTRL { QAVSCENE qavScene; }; diff --git a/source/blood/src/triggers.cpp b/source/blood/src/triggers.cpp index 61061de88..1b3b2a2e7 100644 --- a/source/blood/src/triggers.cpp +++ b/source/blood/src/triggers.cpp @@ -87,7 +87,7 @@ unsigned int GetWaveValue(unsigned int nPhase, int nType) return nPhase; } -char SetSpriteState(int nSprite, XSPRITE* pXSprite, int nState, short causedBy) +char SetSpriteState(int nSprite, XSPRITE* pXSprite, int nState) { if ((pXSprite->busy & 0xffff) == 0 && pXSprite->state == nState) return 0; @@ -101,18 +101,18 @@ char SetSpriteState(int nSprite, XSPRITE* pXSprite, int nState, short causedBy) return 1; } if (pXSprite->restState != nState && pXSprite->waitTime > 0) - evPost(nSprite, 3, (pXSprite->waitTime * 120) / 10, pXSprite->restState ? kCmdOn : kCmdOff, causedBy); + evPost(nSprite, 3, (pXSprite->waitTime * 120) / 10, pXSprite->restState ? kCmdOn : kCmdOff); if (pXSprite->txID) { if (pXSprite->command != kCmdLink && pXSprite->triggerOn && pXSprite->state) - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, causedBy); + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); if (pXSprite->command != kCmdLink && pXSprite->triggerOff && !pXSprite->state) - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, causedBy); + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); } return 1; } -char modernTypeSetSpriteState(int nSprite, XSPRITE *pXSprite, int nState, short causedBy) +char modernTypeSetSpriteState(int nSprite, XSPRITE *pXSprite, int nState) { if ((pXSprite->busy&0xffff) == 0 && pXSprite->state == nState) return 0; pXSprite->busy = nState<<16; @@ -120,12 +120,12 @@ char modernTypeSetSpriteState(int nSprite, XSPRITE *pXSprite, int nState, short evKill(nSprite, 3); if ((sprite[nSprite].flags & kHitagRespawn) != 0 && sprite[nSprite].inittype >= kDudeBase && sprite[nSprite].inittype < kDudeMax) { pXSprite->respawnPending = 3; - evPost(nSprite, 3, gGameOptions.nMonsterRespawnTime, kCallbackRespawn, causedBy); + evPost(nSprite, 3, gGameOptions.nMonsterRespawnTime, kCallbackRespawn); return 1; } if (pXSprite->restState != nState && pXSprite->waitTime > 0) - evPost(nSprite, 3, (pXSprite->waitTime*120) / 10, pXSprite->restState ? kCmdOn : kCmdOff, causedBy); + evPost(nSprite, 3, (pXSprite->waitTime*120) / 10, pXSprite->restState ? kCmdOn : kCmdOff); if (pXSprite->txID != 0 && ((pXSprite->triggerOn && pXSprite->state) || (pXSprite->triggerOff && !pXSprite->state))) { @@ -134,15 +134,15 @@ char modernTypeSetSpriteState(int nSprite, XSPRITE *pXSprite, int nState, short switch (pXSprite->command) { case kCmdLink: case kCmdModernUse: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, causedBy); // just send command to change properties + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // just send command to change properties return 1; case kCmdUnlock: - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, causedBy); // send normal command first - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, causedBy); // then send command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // send normal command first + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // then send command to change properties return 1; default: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, causedBy); // send first command to change properties - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, causedBy); // then send normal command + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // send first command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // then send normal command return 1; } @@ -150,7 +150,7 @@ char modernTypeSetSpriteState(int nSprite, XSPRITE *pXSprite, int nState, short return 1; } -char SetWallState(int nWall, XWALL *pXWall, int nState, short causedBy) +char SetWallState(int nWall, XWALL *pXWall, int nState) { if ((pXWall->busy&0xffff) == 0 && pXWall->state == nState) return 0; @@ -158,18 +158,18 @@ char SetWallState(int nWall, XWALL *pXWall, int nState, short causedBy) pXWall->state = nState; evKill(nWall, 0); if (pXWall->restState != nState && pXWall->waitTime > 0) - evPost(nWall, 0, (pXWall->waitTime*120) / 10, pXWall->restState ? kCmdOn : kCmdOff, causedBy); + evPost(nWall, 0, (pXWall->waitTime*120) / 10, pXWall->restState ? kCmdOn : kCmdOff); if (pXWall->txID) { if (pXWall->command != kCmdLink && pXWall->triggerOn && pXWall->state) - evSend(nWall, 0, pXWall->txID, (COMMAND_ID)pXWall->command, causedBy); + evSend(nWall, 0, pXWall->txID, (COMMAND_ID)pXWall->command); if (pXWall->command != kCmdLink && pXWall->triggerOff && !pXWall->state) - evSend(nWall, 0, pXWall->txID, (COMMAND_ID)pXWall->command, causedBy); + evSend(nWall, 0, pXWall->txID, (COMMAND_ID)pXWall->command); } return 1; } -char SetSectorState(int nSector, XSECTOR *pXSector, int nState, short causedBy) +char SetSectorState(int nSector, XSECTOR *pXSector, int nState) { if ((pXSector->busy&0xffff) == 0 && pXSector->state == nState) return 0; @@ -179,26 +179,26 @@ char SetSectorState(int nSector, XSECTOR *pXSector, int nState, short causedBy) if (nState == 1) { if (pXSector->command != kCmdLink && pXSector->triggerOn && pXSector->txID) - evSend(nSector, 6, pXSector->txID, (COMMAND_ID)pXSector->command, causedBy); + evSend(nSector, 6, pXSector->txID, (COMMAND_ID)pXSector->command); if (pXSector->stopOn) { pXSector->stopOn = 0; pXSector->stopOff = 0; } else if (pXSector->reTriggerA) - evPost(nSector, 6, (pXSector->waitTimeA * 120) / 10, kCmdOff, causedBy); + evPost(nSector, 6, (pXSector->waitTimeA * 120) / 10, kCmdOff); } else { if (pXSector->command != kCmdLink && pXSector->triggerOff && pXSector->txID) - evSend(nSector, 6, pXSector->txID, (COMMAND_ID)pXSector->command, causedBy); + evSend(nSector, 6, pXSector->txID, (COMMAND_ID)pXSector->command); if (pXSector->stopOff) { pXSector->stopOn = 0; pXSector->stopOff = 0; } else if (pXSector->reTriggerB) - evPost(nSector, 6, (pXSector->waitTimeB * 120) / 10, kCmdOn, causedBy); + evPost(nSector, 6, (pXSector->waitTimeB * 120) / 10, kCmdOn); } return 1; } @@ -410,13 +410,13 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kDudePlayer8: switch (event.cmd) { case kCmdOff: - SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + SetSpriteState(nSprite, pXSprite, 0); break; case kCmdOn: - SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + SetSpriteState(nSprite, pXSprite, 1); break; default: - SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); + SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); break; } return; @@ -433,7 +433,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (pXSprite->command) { case kCmdLink: if (pXSprite->txID <= 0) return; - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); return; } break; // go normal operate switch @@ -470,7 +470,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) } pXSprite->txID = (tx > 0 && tx < kChannelUserMax) ? tx : 0; - SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); + SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); } return; // Sequential Switch takes values from data fields starting from data1 and uses it as TX ID @@ -490,7 +490,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) if (pSprite->flags & kModernTypeFlag1) { for (pXSprite->txID = pXSprite->data1; pXSprite->txID <= pXSprite->data4; pXSprite->txID++) { if (pXSprite->txID > 0) - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); } pXSprite->txID = pXSprite->sysData1 = 0; @@ -509,7 +509,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) if (pSprite->flags & kModernTypeFlag1) { for (int i = 0; i <= 3; i++) { if ((pXSprite->txID = GetDataVal(pSprite, i)) > 0) - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); } pXSprite->txID = pXSprite->sysData1 = 0; @@ -563,15 +563,14 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) } pXSprite->txID = (tx > 0 && tx < kChannelUserMax) ? tx : 0; - SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); + SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); } return; case kMarkerWarpDest: if (pXSprite->txID <= 0) { - if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy) == 1) { - if (pXSprite->data1 == 0 && spriRangeIsFine(event.causedBy)) useTeleportTarget(pXSprite, &sprite[event.causedBy]); - else if (pXSprite->data1 > 0) { + if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1) == 1) { + if (pXSprite->data1 > 0) { PLAYER* pPlayer = getPlayerById(pXSprite->data1); if (pPlayer != NULL) useTeleportTarget(pXSprite, pPlayer->pSprite); @@ -579,14 +578,13 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) } return; } - modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); + modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); return; case kModernSpriteDamager: if (pXSprite->txID <= 0) { - if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy) == 1) { - if (pXSprite->data1 == 0 && spriRangeIsFine(event.causedBy)) useSpriteDamager(pXSprite, &sprite[event.causedBy]); - else if (pXSprite->data1 > 0) { + if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1) == 1) { + if (pXSprite->data1 > 0) { PLAYER* pPlayer = getPlayerById(pXSprite->data1); if (pPlayer != NULL) useSpriteDamager(pXSprite, pPlayer->pSprite); @@ -594,30 +592,25 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) } return; } - modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); + modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); return; case kModernObjPropertiesChanger: if (pXSprite->txID <= 0) { - if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy) == 1) + if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1) == 1) usePropertiesChanger(pXSprite, -1, -1); return; } - modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); + modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); return; case kModernObjSizeChanger: - if (pXSprite->txID <= 0 && spriRangeIsFine(event.causedBy)) { - if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy) == 1) - useObjResizer(pXSprite, 3, event.causedBy); - return; - } - modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); + modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); return; case kModernObjPicnumChanger: case kModernSectorFXChanger: case kModernObjDataChanger: - modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); + modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); return; case kModernCustomDudeSpawn: @@ -629,11 +622,11 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kModernEffectSpawner: switch (event.cmd) { case kCmdOff: - if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0); break; case kCmdOn: evKill(nSprite, 3); // queue overflow protect - if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1); fallthrough__; case kCmdRepeat: if (pXSprite->txID <= 0) @@ -642,26 +635,26 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (pXSprite->command) { case kCmdLink: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // just send command to change properties + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // just send command to change properties break; case kCmdUnlock: - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // send normal command first - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // then send command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // send normal command first + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // then send command to change properties break; default: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // send first command to change properties - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // then send normal command + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // send first command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // then send normal command break; } } if (pXSprite->busyTime > 0) - evPost(nSprite, 3, ClipLow((int(pXSprite->busyTime) + Random2(pXSprite->data1)) * 120 / 10, 0), kCmdRepeat, event.causedBy); + evPost(nSprite, 3, ClipLow((int(pXSprite->busyTime) + Random2(pXSprite->data1)) * 120 / 10, 0), kCmdRepeat); break; default: - if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); - else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); + if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn); + else evPost(nSprite, 3, 0, kCmdOff); break; } return; @@ -670,11 +663,11 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (event.cmd) { case kCmdOff: stopWindOnSectors(pXSprite); - if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0); break; case kCmdOn: evKill(nSprite, 3); // queue overflow protect - if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1); fallthrough__; case kCmdRepeat: if (pXSprite->txID <= 0) useSectorWindGen(pXSprite, NULL); @@ -682,25 +675,25 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (pXSprite->command) { case kCmdLink: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // just send command to change properties + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // just send command to change properties break; case kCmdUnlock: - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // send normal command first - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // then send command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // send normal command first + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // then send command to change properties break; default: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // send first command to change properties - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // then send normal command + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // send first command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // then send normal command break; } } - if (pXSprite->busyTime > 0) evPost(nSprite, 3, pXSprite->busyTime, kCmdRepeat, event.causedBy); + if (pXSprite->busyTime > 0) evPost(nSprite, 3, pXSprite->busyTime, kCmdRepeat); break; default: - if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); - else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); + if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn); + else evPost(nSprite, 3, 0, kCmdOff); break; } return; @@ -719,41 +712,41 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (event.cmd) { case kCmdOff: if (pXSprite->data4 == 3 && activated == false) activateDudes(pXSprite->txID); - if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0); break; case kCmdOn: evKill(nSprite, 3); // queue overflow protect - if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1); fallthrough__; case kCmdRepeat: if (pXSprite->txID <= 0 || !getDudesForTargetChg(pXSprite)) { freeAllTargets(pXSprite); - evPost(nSprite, 3, 0, kCmdOff, event.causedBy); + evPost(nSprite, 3, 0, kCmdOff); break; } else { switch (pXSprite->command) { case kCmdLink: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // just send command to change properties + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // just send command to change properties break; case kCmdUnlock: - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // send normal command first - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // then send command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // send normal command first + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // then send command to change properties break; default: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // send first command to change properties - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // then send normal command + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // send first command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // then send normal command break; } } - if (pXSprite->busyTime > 0) evPost(nSprite, 3, pXSprite->busyTime, kCmdRepeat, event.causedBy); + if (pXSprite->busyTime > 0) evPost(nSprite, 3, pXSprite->busyTime, kCmdRepeat); break; default: - if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); - else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); + if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn); + else evPost(nSprite, 3, 0, kCmdOff); break; } @@ -764,17 +757,17 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kModernObjDataAccumulator: switch (event.cmd) { case kCmdOff: - if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0); break; case kCmdOn: evKill(nSprite, 3); // queue overflow protect - if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1); fallthrough__; case kCmdRepeat: // force OFF after *all* TX objects reach the goal value if (pSprite->flags == 0 && goalValueIsReached(pXSprite)) { - evPost(nSprite, 3, 0, kCmdOff, event.causedBy); + evPost(nSprite, 3, 0, kCmdOff); break; } @@ -782,24 +775,24 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (pXSprite->command) { case kCmdLink: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // just send command to change properties + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // just send command to change properties break; case kCmdUnlock: - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // send normal command first - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // then send command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // send normal command first + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // then send command to change properties break; default: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // send first command to change properties - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // then send normal command + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // send first command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // then send normal command break; } - if (pXSprite->busyTime > 0) evPost(nSprite, 3, pXSprite->busyTime, kCmdRepeat, event.causedBy); + if (pXSprite->busyTime > 0) evPost(nSprite, 3, pXSprite->busyTime, kCmdRepeat); } break; default: - if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); - else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); + if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn); + else evPost(nSprite, 3, 0, kCmdOff); break; } return; @@ -808,20 +801,20 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kModernRandom2: switch (event.cmd) { case kCmdOff: - if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0); break; case kCmdOn: evKill(nSprite, 3); // queue overflow protect - if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1); fallthrough__; case kCmdRepeat: ActivateGenerator(nSprite); if (pXSprite->busyTime > 0) - evPost(nSprite, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat, event.causedBy); + evPost(nSprite, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat); break; default: - if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); - else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); + if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn); + else evPost(nSprite, 3, 0, kCmdOff); break; } return; @@ -833,38 +826,35 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kGenModernMissileUniversal: switch (event.cmd) { case kCmdOff: - if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0); break; case kCmdOn: evKill(nSprite, 3); // queue overflow protect - if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1); fallthrough__; case kCmdRepeat: ActivateGenerator(nSprite); - if (pXSprite->txID) evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); - if (pXSprite->busyTime > 0) evPost(nSprite, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat, event.causedBy); + if (pXSprite->txID) evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); + if (pXSprite->busyTime > 0) evPost(nSprite, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat); break; default: - if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); - else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); + if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn); + else evPost(nSprite, 3, 0, kCmdOff); break; } return; case kModernPlayerControl: // WIP PLAYER* pPlayer = NULL; int nPlayer = pXSprite->data1; int oldCmd = -1; - if (pXSprite->data1 == 0 && spriRangeIsFine(event.causedBy)) - nPlayer = sprite[event.causedBy].type; - if ((pPlayer = getPlayerById(nPlayer)) == NULL || pPlayer->pXSprite->health <= 0) return; else if (pXSprite->command < kCmdNumberic + 3 && pXSprite->command > kCmdNumberic + 4 - && !modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy)) return; + && !modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1)) return; TRPLAYERCTRL* pCtrl = &gPlayerCtrl[pPlayer->nPlayer]; if (event.cmd >= kCmdNumberic) { switch (event.cmd) { case kCmdNumberic + 3: // start playing qav scene if (pCtrl->qavScene.index != nSprite || pXSprite->Interrutable) - trPlayerCtrlStartScene(pXSprite, pPlayer, event.causedBy); + trPlayerCtrlStartScene(pXSprite, pPlayer); return; case kCmdNumberic + 4: { // stop playing qav scene int scnIndex = pCtrl->qavScene.index; @@ -975,7 +965,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kCmdNumberic + 3: // 67 // start playing qav scene if (pCtrl->qavScene.index != nSprite || pXSprite->Interrutable) - trPlayerCtrlStartScene(pXSprite, pPlayer, event.causedBy); + trPlayerCtrlStartScene(pXSprite, pPlayer); break; case kCmdNumberic + 4: // 68 @@ -1118,7 +1108,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (event.cmd) { case kCmdOff: - SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + SetSpriteState(nSprite, pXSprite, 0); break; case kCmdSpriteProximity: if (pXSprite->state) break; @@ -1126,7 +1116,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kCmdOn: case kCmdSpritePush: case kCmdSpriteTouch: - if (!pXSprite->state) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + if (!pXSprite->state) SetSpriteState(nSprite, pXSprite, 1); aiActivateDude(pSprite, pXSprite); break; } @@ -1140,11 +1130,11 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) if (pXSprite->health <= 0) break; switch (event.cmd) { case kCmdOff: - if (!SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, 0)) break; seqSpawn(40, 3, pSprite->extra, -1); break; case kCmdOn: - if (!SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, 1)) break; seqSpawn(38, 3, pSprite->extra, nMGunOpenClient); if (pXSprite->data1 > 0) pXSprite->data2 = pXSprite->data1; @@ -1152,15 +1142,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) } break; case kThingFallingRock: - if (SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) + if (SetSpriteState(nSprite, pXSprite, 1)) pSprite->flags |= 7; break; case kThingWallCrack: - if (SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) + if (SetSpriteState(nSprite, pXSprite, 0)) actPostSprite(nSprite, kStatFree); break; case kThingCrateFace: - if (SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) + if (SetSpriteState(nSprite, pXSprite, 0)) actPostSprite(nSprite, kStatFree); break; case kTrapZapSwitchable: @@ -1185,12 +1175,12 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kTrapFlame: switch (event.cmd) { case kCmdOff: - if (!SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, 0)) break; seqSpawn(40, 3, pSprite->extra, -1); sfxKill3DSound(pSprite, 0, -1); break; case kCmdOn: - if (SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, 1)) break; seqSpawn(38, 3, pSprite->extra, -1); sfxPlay3DSound(pSprite, 441, 0, 0); break; @@ -1199,14 +1189,14 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kSwitchPadlock: switch (event.cmd) { case kCmdOff: - SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + SetSpriteState(nSprite, pXSprite, 0); break; case kCmdOn: - if (!SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, 1)) break; seqSpawn(37, 3, pSprite->extra, -1); break; default: - SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); + SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); if (pXSprite->state) seqSpawn(37, 3, pSprite->extra, -1); break; } @@ -1214,15 +1204,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kSwitchToggle: switch (event.cmd) { case kCmdOff: - if (!SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, 0)) break; sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); break; case kCmdOn: - if (!SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, 1)) break; sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); break; default: - if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1)) break; if (pXSprite->state) sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); else sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); break; @@ -1231,15 +1221,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kSwitchOneWay: switch (event.cmd) { case kCmdOff: - if (!SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, 0)) break; sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); break; case kCmdOn: - if (!SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, 1)) break; sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); break; default: - if (!SetSpriteState(nSprite, pXSprite, pXSprite->restState ^ 1, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, pXSprite->restState ^ 1)) break; if (pXSprite->state) sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); else sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); break; @@ -1262,12 +1252,12 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) sfxPlay3DSound(pSprite, pXSprite->data4, -1, 0); if (pXSprite->command == kCmdLink && pXSprite->txID > 0) - evSend(nSprite, 3, pXSprite->txID, kCmdLink, event.causedBy); + evSend(nSprite, 3, pXSprite->txID, kCmdLink); if (pXSprite->data1 == pXSprite->data2) - SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + SetSpriteState(nSprite, pXSprite, 1); else - SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + SetSpriteState(nSprite, pXSprite, 0); break; case kMarkerDudeSpawn: @@ -1308,7 +1298,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kMarkerEarthQuake: pXSprite->triggerOn = 0; pXSprite->isTriggered = 1; - SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + SetSpriteState(nSprite, pXSprite, 1); for (int p = connecthead; p >= 0; p = connectpoint2[p]) { spritetype *pPlayerSprite = gPlayer[p].pSprite; int dx = (pSprite->x - pPlayerSprite->x)>>4; @@ -1329,7 +1319,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kTrapExploder: switch (event.cmd) { case kCmdOn: - SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + SetSpriteState(nSprite, pXSprite, 1); break; default: pSprite->cstat &= (unsigned short)~CSTAT_SPRITE_INVISIBLE; @@ -1339,16 +1329,25 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) break; case kThingArmedRemoteBomb: if (pSprite->statnum != kStatRespawn) { + if (event.cmd != kCmdOn) actExplodeSprite(pSprite); + else { + sfxPlay3DSound(pSprite, 454, 0, 0); + evPost(nSprite, 3, 18, kCmdOff); + } + } + break; + + /*if (pSprite->statnum != kStatRespawn) { switch (event.cmd) { case kCmdOn: actExplodeSprite(pSprite); break; default: sfxPlay3DSound(pSprite, 454, 0, 0); - evPost(nSprite, 3, 18, kCmdOff, event.causedBy); + evPost(nSprite, 3, 18, kCmdOff); break; } - } + }*/ break; case kThingArmedProxBomb: @@ -1358,7 +1357,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kCmdSpriteProximity: if (pXSprite->state) break; sfxPlay3DSound(pSprite, 452, 0, 0); - evPost(nSprite, 3, 30, kCmdOff, event.causedBy); + evPost(nSprite, 3, 30, kCmdOff); pXSprite->state = 1; fallthrough__; case kCmdOn: @@ -1385,20 +1384,20 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kGenSound: switch (event.cmd) { case kCmdOff: - SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + SetSpriteState(nSprite, pXSprite, 0); break; case kCmdRepeat: if (pSprite->type != kGenTrigger) ActivateGenerator(nSprite); - if (pXSprite->txID) evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); + if (pXSprite->txID) evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); if (pXSprite->busyTime > 0) { int nRand = Random2(pXSprite->data1); - evPost(nSprite, 3, 120*(nRand+pXSprite->busyTime) / 10, kCmdRepeat, event.causedBy); + evPost(nSprite, 3, 120*(nRand+pXSprite->busyTime) / 10, kCmdRepeat); } break; default: if (!pXSprite->state) { - SetSpriteState(nSprite, pXSprite, 1, event.causedBy); - evPost(nSprite, 3, 0, kCmdRepeat, event.causedBy); + SetSpriteState(nSprite, pXSprite, 1); + evPost(nSprite, 3, 0, kCmdRepeat); } break; } @@ -1414,15 +1413,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kThingZombieHead: switch (event.cmd) { case kCmdOff: - if (!SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, 0)) break; actActivateGibObject(pSprite, pXSprite); break; case kCmdOn: - if (!SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, 1)) break; actActivateGibObject(pSprite, pXSprite); break; default: - if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy)) break; + if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1)) break; actActivateGibObject(pSprite, pXSprite); break; } @@ -1430,13 +1429,13 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) default: switch (event.cmd) { case kCmdOff: - SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + SetSpriteState(nSprite, pXSprite, 0); break; case kCmdOn: - SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + SetSpriteState(nSprite, pXSprite, 1); break; default: - SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); + SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); break; } break; @@ -1463,7 +1462,7 @@ void stopWindOnSectors(XSPRITE* pXSource) { } } -void trPlayerCtrlStartScene(XSPRITE* pXSource, PLAYER* pPlayer, int causedBy) { +void trPlayerCtrlStartScene(XSPRITE* pXSource, PLAYER* pPlayer) { int nSource = sprite[pXSource->reference].index; TRPLAYERCTRL* pCtrl = &gPlayerCtrl[pPlayer->nPlayer]; QAV* pQav = qavSceneLoad(pXSource->data2); @@ -1483,7 +1482,7 @@ void trPlayerCtrlStartScene(XSPRITE* pXSource, PLAYER* pPlayer, int causedBy) { pCtrl->qavScene.index = nSource; pCtrl->qavScene.qavResrc = pQav; - pCtrl->qavScene.causedBy = causedBy; + pCtrl->qavScene.dummy = -1; pCtrl->qavScene.qavResrc->Preload(); @@ -1581,7 +1580,7 @@ void useObjResizer(XSPRITE* pXSource, short objType, int objIndex) { gGenDudeExtra[objIndex].updReq[kGenDudePropertyAttack] = true; gGenDudeExtra[objIndex].updReq[kGenDudePropertyMass] = true; gGenDudeExtra[objIndex].updReq[kGenDudePropertyDmgScale] = true; - evPost(objIndex, 3, kGenDudeUpdTimeRate, kCallbackGenDudeUpdate, -1); + evPost(objIndex, 3, kGenDudeUpdTimeRate, kCallbackGenDudeUpdate); break; } } @@ -2176,13 +2175,13 @@ void OperateWall(int nWall, XWALL *pXWall, EVENT event) { case kSwitchOneWay: switch (event.cmd) { case kCmdOff: - SetWallState(nWall, pXWall, 0, event.causedBy); + SetWallState(nWall, pXWall, 0); break; case kCmdOn: - SetWallState(nWall, pXWall, 1, event.causedBy); + SetWallState(nWall, pXWall, 1); break; default: - SetWallState(nWall, pXWall, pXWall->restState ^ 1, event.causedBy); + SetWallState(nWall, pXWall, pXWall->restState ^ 1); break; } return; @@ -2199,13 +2198,13 @@ void OperateWall(int nWall, XWALL *pXWall, EVENT event) { switch (event.cmd) { case kCmdOn: case kCmdWallImpact: - bStatus = SetWallState(nWall, pXWall, 1, event.causedBy); + bStatus = SetWallState(nWall, pXWall, 1); break; case kCmdOff: - bStatus = SetWallState(nWall, pXWall, 0, event.causedBy); + bStatus = SetWallState(nWall, pXWall, 0); break; default: - bStatus = SetWallState(nWall, pXWall, pXWall->state ^ 1, event.causedBy); + bStatus = SetWallState(nWall, pXWall, pXWall->state ^ 1); break; } @@ -2222,13 +2221,13 @@ void OperateWall(int nWall, XWALL *pXWall, EVENT event) { default: switch (event.cmd) { case kCmdOff: - SetWallState(nWall, pXWall, 0, event.causedBy); + SetWallState(nWall, pXWall, 0); break; case kCmdOn: - SetWallState(nWall, pXWall, 1, event.causedBy); + SetWallState(nWall, pXWall, 1); break; default: - SetWallState(nWall, pXWall, pXWall->state ^ 1, event.causedBy); + SetWallState(nWall, pXWall, pXWall->state ^ 1); break; } return; @@ -2546,7 +2545,7 @@ int GetCrushedSpriteExtents(unsigned int nSector, int *pzTop, int *pzBot) return vc; } -int VCrushBusy(unsigned int nSector, unsigned int a2, short causedBy) +int VCrushBusy(unsigned int nSector, unsigned int a2) { dassert(nSector < (unsigned int)numsectors); int nXSector = sector[nSector].extra; @@ -2575,17 +2574,17 @@ int VCrushBusy(unsigned int nSector, unsigned int a2, short causedBy) sector[nSector].floorz = v10; pXSector->busy = a2; if (pXSector->command == kCmdLink && pXSector->txID) - evSend(nSector, 6, pXSector->txID, kCmdLink, causedBy); + evSend(nSector, 6, pXSector->txID, kCmdLink); if ((a2&0xffff) == 0) { - SetSectorState(nSector, pXSector, a2>>16, causedBy); + SetSectorState(nSector, pXSector, a2>>16); SectorEndSound(nSector, a2>>16); return 3; } return 0; } -int VSpriteBusy(unsigned int nSector, unsigned int a2, short causedBy) +int VSpriteBusy(unsigned int nSector, unsigned int a2) { dassert(nSector < (unsigned int)numsectors); int nXSector = sector[nSector].extra; @@ -2624,17 +2623,17 @@ int VSpriteBusy(unsigned int nSector, unsigned int a2, short causedBy) } pXSector->busy = a2; if (pXSector->command == kCmdLink && pXSector->txID) - evSend(nSector, 6, pXSector->txID, kCmdLink, causedBy); + evSend(nSector, 6, pXSector->txID, kCmdLink); if ((a2&0xffff) == 0) { - SetSectorState(nSector, pXSector, a2>>16, causedBy); + SetSectorState(nSector, pXSector, a2>>16); SectorEndSound(nSector, a2>>16); return 3; } return 0; } -int VDoorBusy(unsigned int nSector, unsigned int a2, short causedBy) +int VDoorBusy(unsigned int nSector, unsigned int a2) { dassert(nSector < (unsigned int)numsectors); int nXSector = sector[nSector].extra; @@ -2723,17 +2722,17 @@ int VDoorBusy(unsigned int nSector, unsigned int a2, short causedBy) ZTranslateSector(nSector, pXSector, a2, nWave); pXSector->busy = a2; if (pXSector->command == kCmdLink && pXSector->txID) - evSend(nSector, 6, pXSector->txID, kCmdLink, causedBy); + evSend(nSector, 6, pXSector->txID, kCmdLink); if ((a2&0xffff) == 0) { - SetSectorState(nSector, pXSector, a2>>16, causedBy); + SetSectorState(nSector, pXSector, a2>>16); SectorEndSound(nSector, a2>>16); return 3; } return 0; } -int HDoorBusy(unsigned int nSector, unsigned int a2, short causedBy) +int HDoorBusy(unsigned int nSector, unsigned int a2) { dassert(nSector < (unsigned int)numsectors); sectortype *pSector = §or[nSector]; @@ -2751,17 +2750,17 @@ int HDoorBusy(unsigned int nSector, unsigned int a2, short causedBy) ZTranslateSector(nSector, pXSector, a2, nWave); pXSector->busy = a2; if (pXSector->command == kCmdLink && pXSector->txID) - evSend(nSector, 6, pXSector->txID, kCmdLink, causedBy); + evSend(nSector, 6, pXSector->txID, kCmdLink); if ((a2&0xffff) == 0) { - SetSectorState(nSector, pXSector, a2>>16, causedBy); + SetSectorState(nSector, pXSector, a2>>16); SectorEndSound(nSector, a2>>16); return 3; } return 0; } -int RDoorBusy(unsigned int nSector, unsigned int a2, short causedBy) +int RDoorBusy(unsigned int nSector, unsigned int a2) { dassert(nSector < (unsigned int)numsectors); sectortype *pSector = §or[nSector]; @@ -2778,17 +2777,17 @@ int RDoorBusy(unsigned int nSector, unsigned int a2, short causedBy) ZTranslateSector(nSector, pXSector, a2, nWave); pXSector->busy = a2; if (pXSector->command == kCmdLink && pXSector->txID) - evSend(nSector, 6, pXSector->txID, kCmdLink, causedBy); + evSend(nSector, 6, pXSector->txID, kCmdLink); if ((a2&0xffff) == 0) { - SetSectorState(nSector, pXSector, a2>>16, causedBy); + SetSectorState(nSector, pXSector, a2>>16); SectorEndSound(nSector, a2>>16); return 3; } return 0; } -int StepRotateBusy(unsigned int nSector, unsigned int a2, short causedBy) +int StepRotateBusy(unsigned int nSector, unsigned int a2) { dassert(nSector < (unsigned int)numsectors); sectortype *pSector = §or[nSector]; @@ -2811,10 +2810,10 @@ int StepRotateBusy(unsigned int nSector, unsigned int a2, short causedBy) } pXSector->busy = a2; if (pXSector->command == kCmdLink && pXSector->txID) - evSend(nSector, 6, pXSector->txID, kCmdLink, causedBy); + evSend(nSector, 6, pXSector->txID, kCmdLink); if ((a2&0xffff) == 0) { - SetSectorState(nSector, pXSector, a2>>16, causedBy); + SetSectorState(nSector, pXSector, a2>>16); SectorEndSound(nSector, a2>>16); pXSector->data = vbp&2047; return 3; @@ -2822,7 +2821,7 @@ int StepRotateBusy(unsigned int nSector, unsigned int a2, short causedBy) return 0; } -int GenSectorBusy(unsigned int nSector, unsigned int a2, short causedBy) +int GenSectorBusy(unsigned int nSector, unsigned int a2) { dassert(nSector < (unsigned int)numsectors); sectortype *pSector = §or[nSector]; @@ -2831,17 +2830,17 @@ int GenSectorBusy(unsigned int nSector, unsigned int a2, short causedBy) XSECTOR *pXSector = &xsector[nXSector]; pXSector->busy = a2; if (pXSector->command == kCmdLink && pXSector->txID) - evSend(nSector, 6, pXSector->txID, kCmdLink, causedBy); + evSend(nSector, 6, pXSector->txID, kCmdLink); if ((a2&0xffff) == 0) { - SetSectorState(nSector, pXSector, a2>>16, causedBy); + SetSectorState(nSector, pXSector, a2>>16); SectorEndSound(nSector, a2>>16); return 3; } return 0; } -int PathBusy(unsigned int nSector, unsigned int a2, short causedBy) +int PathBusy(unsigned int nSector, unsigned int a2) { dassert(nSector < (unsigned int)numsectors); sectortype *pSector = §or[nSector]; @@ -2859,7 +2858,7 @@ int PathBusy(unsigned int nSector, unsigned int a2, short causedBy) pXSector->busy = a2; if ((a2&0xffff) == 0) { - evPost(nSector, 6, (120*pXSprite2->waitTime)/10, kCmdOn, causedBy); + evPost(nSector, 6, (120*pXSprite2->waitTime)/10, kCmdOn); pXSector->state = 0; pXSector->busy = 0; if (pXSprite1->data4) @@ -2990,7 +2989,7 @@ void OperatePath(unsigned int nSector, XSECTOR *pXSector, EVENT event) // by NoOne: trigger marker after it gets reached if (gModernMap && pXSprite2->state != 1) - trTriggerSprite(pSprite2->xvel, pXSprite2, kCmdOn, -1); + trTriggerSprite(pSprite2->xvel, pXSprite2, kCmdOn); if (nSprite < 0) { viewSetSystemMessage("Unable to find path marker with id #%d for path sector #%d", nId, nSector); @@ -3098,13 +3097,13 @@ void OperateSector(unsigned int nSector, XSECTOR *pXSector, EVENT event) switch (event.cmd) { case kCmdOff: - SetSectorState(nSector, pXSector, 0, event.causedBy); + SetSectorState(nSector, pXSector, 0); break; case kCmdOn: - SetSectorState(nSector, pXSector, 1, event.causedBy); + SetSectorState(nSector, pXSector, 1); break; default: - SetSectorState(nSector, pXSector, pXSector->state ^ 1, event.causedBy); + SetSectorState(nSector, pXSector, pXSector->state ^ 1); break; } @@ -3148,7 +3147,7 @@ void InitPath(unsigned int nSector, XSECTOR *pXSector) pXSector->marker0 = nSprite; basePath[nSector] = nSprite; if (pXSector->state) - evPost(nSector, 6, 0, kCmdOn, -1); + evPost(nSector, 6, 0, kCmdOn); } void LinkSector(int nSector, XSECTOR *pXSector, EVENT event) @@ -3157,18 +3156,18 @@ void LinkSector(int nSector, XSECTOR *pXSector, EVENT event) int nBusy = GetSourceBusy(event); switch (pSector->type) { case kSectorZMotionSprite: - VSpriteBusy(nSector, nBusy, event.causedBy); + VSpriteBusy(nSector, nBusy); break; case kSectorZMotion: - VDoorBusy(nSector, nBusy, event.causedBy); + VDoorBusy(nSector, nBusy); break; case kSectorSlideMarked: case kSectorSlide: - HDoorBusy(nSector, nBusy, event.causedBy); + HDoorBusy(nSector, nBusy); break; case kSectorRotateMarked: case kSectorRotate: - RDoorBusy(nSector, nBusy, event.causedBy); + RDoorBusy(nSector, nBusy); break; /* By NoOne: add link support for counter sectors so they can change necessary type and count of types*/ case kSectorCounter: @@ -3178,7 +3177,7 @@ void LinkSector(int nSector, XSECTOR *pXSector, EVENT event) default: pXSector->busy = nBusy; if ((pXSector->busy&0xffff) == 0) - SetSectorState(nSector, pXSector, nBusy>>16, event.causedBy); + SetSectorState(nSector, pXSector, nBusy>>16); break; } } @@ -3310,9 +3309,9 @@ void LinkSprite(int nSprite, XSPRITE *pXSprite, EVENT event) { dassert(nXSprite2 > 0 && nXSprite2 < kMaxXSprites); pXSprite->data1 = xsprite[nXSprite2].data1; if (pXSprite->data1 == pXSprite->data2) - SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + SetSpriteState(nSprite, pXSprite, 1); else - SetSpriteState(nSprite, pXSprite, 0, event.causedBy); + SetSpriteState(nSprite, pXSprite, 0); } } break; @@ -3320,7 +3319,7 @@ void LinkSprite(int nSprite, XSPRITE *pXSprite, EVENT event) { { pXSprite->busy = nBusy; if ((pXSprite->busy & 0xffff) == 0) - SetSpriteState(nSprite, pXSprite, nBusy >> 16, event.causedBy); + SetSpriteState(nSprite, pXSprite, nBusy >> 16); } break; } @@ -3331,10 +3330,10 @@ void LinkWall(int nWall, XWALL *pXWall, EVENT event) int nBusy = GetSourceBusy(event); pXWall->busy = nBusy; if ((pXWall->busy & 0xffff) == 0) - SetWallState(nWall, pXWall, nBusy>>16, event.causedBy); + SetWallState(nWall, pXWall, nBusy>>16); } -void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command, short causedBy) { +void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command) { dassert(nSector < (unsigned int)numsectors); if (!pXSector->locked && !pXSector->isTriggered) { @@ -3342,12 +3341,11 @@ void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command, short pXSector->isTriggered = 1; if (pXSector->decoupled && pXSector->txID > 0) - evSend(nSector, 6, pXSector->txID, (COMMAND_ID)pXSector->command, causedBy); + evSend(nSector, 6, pXSector->txID, (COMMAND_ID)pXSector->command); else { EVENT event; event.cmd = command; - event.causedBy = causedBy; OperateSector(nSector, pXSector, event); } @@ -3373,7 +3371,7 @@ void trMessageSector(unsigned int nSector, EVENT event) { } } -void trTriggerWall(unsigned int nWall, XWALL *pXWall, int command, short causedBy) { +void trTriggerWall(unsigned int nWall, XWALL *pXWall, int command) { dassert(nWall < (unsigned int)numwalls); if (!pXWall->locked && !pXWall->isTriggered) { @@ -3381,12 +3379,11 @@ void trTriggerWall(unsigned int nWall, XWALL *pXWall, int command, short causedB pXWall->isTriggered = 1; if (pXWall->decoupled && pXWall->txID > 0) - evSend(nWall, 0, pXWall->txID, (COMMAND_ID)pXWall->command, causedBy); + evSend(nWall, 0, pXWall->txID, (COMMAND_ID)pXWall->command); else { EVENT event; event.cmd = command; - event.causedBy = causedBy; OperateWall(nWall, pXWall, event); } @@ -3413,19 +3410,18 @@ void trMessageWall(unsigned int nWall, EVENT event) { } } -void trTriggerSprite(unsigned int nSprite, XSPRITE *pXSprite, int command, short causedBy) { +void trTriggerSprite(unsigned int nSprite, XSPRITE *pXSprite, int command) { if (!pXSprite->locked && !pXSprite->isTriggered) { if (pXSprite->triggerOnce) pXSprite->isTriggered = 1; if (pXSprite->Decoupled && pXSprite->txID > 0) - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, causedBy); + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); else { EVENT event; event.cmd = command; - event.causedBy = causedBy; OperateSprite(nSprite, pXSprite, event); } @@ -3600,7 +3596,7 @@ void pastePropertiesInObj(int type, int nDest, EVENT event) { } } - setDataValueOfObject(type, nDest, pXSource->data1, data, event.causedBy); + setDataValueOfObject(type, nDest, pXSource->data1, data); return; @@ -3617,26 +3613,26 @@ void pastePropertiesInObj(int type, int nDest, EVENT event) { switch (type) { case 6: if ((pSource->flags & kModernTypeFlag1) || (pXSource->data1 != -1 && pXSource->data1 != 32767)) - setDataValueOfObject(type, nDest, 1, pXSource->data1, event.causedBy); + setDataValueOfObject(type, nDest, 1, pXSource->data1); break; case 3: if ((pSource->flags & kModernTypeFlag1) || (pXSource->data1 != -1 && pXSource->data1 != 32767)) - setDataValueOfObject(type, nDest, 1, pXSource->data1, event.causedBy); + setDataValueOfObject(type, nDest, 1, pXSource->data1); if ((pSource->flags & kModernTypeFlag1) || (pXSource->data2 != -1 && pXSource->data2 != 32767)) - setDataValueOfObject(type, nDest, 2, pXSource->data2, event.causedBy); + setDataValueOfObject(type, nDest, 2, pXSource->data2); if ((pSource->flags & kModernTypeFlag1) || (pXSource->data3 != -1 && pXSource->data3 != 32767)) - setDataValueOfObject(type, nDest, 3, pXSource->data3, event.causedBy); + setDataValueOfObject(type, nDest, 3, pXSource->data3); if ((pSource->flags & kModernTypeFlag1) || pXSource->data4 != 65535) - setDataValueOfObject(type, nDest, 4, pXSource->data4, event.causedBy); + setDataValueOfObject(type, nDest, 4, pXSource->data4); break; case 0: if ((pSource->flags & kModernTypeFlag1) || (pXSource->data1 != -1 && pXSource->data1 != 32767)) - setDataValueOfObject(type, nDest, 1, pXSource->data1, event.causedBy); + setDataValueOfObject(type, nDest, 1, pXSource->data1); break; } @@ -4223,7 +4219,7 @@ int getDataFieldOfObject(int objType, int objIndex, int dataIndex) { } } -bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value, int causedBy) { +bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value) { switch (objType) { case 3: { @@ -4246,14 +4242,14 @@ bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value, i xsprite[sprite[objIndex].extra].data1 = value; switch (sprite[objIndex].type) { case kSwitchCombo: - if (value == xsprite[sprite[objIndex].extra].data2) SetSpriteState(objIndex, &xsprite[sprite[objIndex].extra], 1, causedBy); - else SetSpriteState(objIndex, &xsprite[sprite[objIndex].extra], 0, causedBy); + if (value == xsprite[sprite[objIndex].extra].data2) SetSpriteState(objIndex, &xsprite[sprite[objIndex].extra], 1); + else SetSpriteState(objIndex, &xsprite[sprite[objIndex].extra], 0); break; case kDudeModernCustom: case kDudeModernCustomBurning: gGenDudeExtra[objIndex].updReq[kGenDudePropertyWeapon] = true; gGenDudeExtra[objIndex].updReq[kGenDudePropertyDmgScale] = true; - evPost(objIndex, 3, kGenDudeUpdTimeRate, kCallbackGenDudeUpdate, causedBy); + evPost(objIndex, 3, kGenDudeUpdTimeRate, kCallbackGenDudeUpdate); break; } return true; @@ -4267,7 +4263,7 @@ bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value, i gGenDudeExtra[objIndex].updReq[kGenDudePropertyDmgScale] = true; gGenDudeExtra[objIndex].updReq[kGenDudePropertyStates] = true; gGenDudeExtra[objIndex].updReq[kGenDudePropertyAttack] = true; - evPost(objIndex, 3, kGenDudeUpdTimeRate, kCallbackGenDudeUpdate, causedBy); + evPost(objIndex, 3, kGenDudeUpdTimeRate, kCallbackGenDudeUpdate); break; } return true; @@ -4552,7 +4548,7 @@ void AlignSlopes(void) } } -int(*gBusyProc[])(unsigned int, unsigned int, short) = +int(*gBusyProc[])(unsigned int, unsigned int) = { VCrushBusy, VSpriteBusy, @@ -4572,7 +4568,7 @@ void trProcessBusy(void) { int oldBusy = gBusy[i].at8; gBusy[i].at8 = ClipRange(oldBusy+gBusy[i].at4*4, 0, 65536); - int nStatus = gBusyProc[gBusy[i].atc](gBusy[i].at0, gBusy[i].at8, -1); + int nStatus = gBusyProc[gBusy[i].atc](gBusy[i].at0, gBusy[i].at8); switch (nStatus) { case 1: gBusy[i].at8 = oldBusy; @@ -4741,17 +4737,17 @@ void trInit(void) } } - evSend(0, 0, kChannelLevelStart, kCmdOn, -1); + evSend(0, 0, kChannelLevelStart, kCmdOn); switch (gGameOptions.nGameType) { case 1: - evSend(0, 0, kChannelLevelStartCoop, kCmdOn, -1); + evSend(0, 0, kChannelLevelStartCoop, kCmdOn); break; case 2: - evSend(0, 0, kChannelLevelStartMatch, kCmdOn, -1); + evSend(0, 0, kChannelLevelStartMatch, kCmdOn); break; case 3: - evSend(0, 0, kChannelLevelStartMatch, kCmdOn, -1); - evSend(0, 0, kChannelLevelStartTeamsOnly, kCmdOn, -1); + evSend(0, 0, kChannelLevelStartMatch, kCmdOn); + evSend(0, 0, kChannelLevelStartTeamsOnly, kCmdOn); break; } } @@ -4778,30 +4774,30 @@ void InitGenerator(int nSprite) pSprite->cstat &= ~CSTAT_SPRITE_BLOCK; pSprite->cstat |= CSTAT_SPRITE_INVISIBLE; if (pXSprite->state != pXSprite->restState) - evPost(nSprite, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat, -1); + evPost(nSprite, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat); return; case kModernDudeTargetChanger: pSprite->cstat &= ~CSTAT_SPRITE_BLOCK; pSprite->cstat |= CSTAT_SPRITE_INVISIBLE; if (pXSprite->busyTime <= 0) pXSprite->busyTime = 5; if (pXSprite->state != pXSprite->restState) - evPost(nSprite, 3, 0, kCmdRepeat, -1); + evPost(nSprite, 3, 0, kCmdRepeat); return; case kModernEffectSpawner: case kModernSeqSpawner: if (pXSprite->state != pXSprite->restState) - evPost(nSprite, 3, 0, kCmdRepeat, -1); + evPost(nSprite, 3, 0, kCmdRepeat); return; case kModernObjDataAccumulator: pSprite->cstat &= ~CSTAT_SPRITE_BLOCK; pSprite->cstat |= CSTAT_SPRITE_INVISIBLE; if (pXSprite->state != pXSprite->restState) - evPost(nSprite, 3, 0, kCmdRepeat, -1); + evPost(nSprite, 3, 0, kCmdRepeat); return; case kModernWindGenerator: pSprite->cstat &= ~CSTAT_SPRITE_BLOCK; if (pXSprite->state != pXSprite->restState) - evPost(nSprite, 3, 0, kCmdRepeat, -1); + evPost(nSprite, 3, 0, kCmdRepeat); return; case kGenTrigger: pSprite->cstat &= ~CSTAT_SPRITE_BLOCK; @@ -4809,7 +4805,7 @@ void InitGenerator(int nSprite) break; } if (pXSprite->state != pXSprite->restState && pXSprite->busyTime > 0) - evPost(nSprite, 3, (120*(pXSprite->busyTime+Random2(pXSprite->data1)))/10, kCmdRepeat, -1); + evPost(nSprite, 3, (120*(pXSprite->busyTime+Random2(pXSprite->data1)))/10, kCmdRepeat); } void ActivateGenerator(int nSprite) @@ -4971,7 +4967,7 @@ void MGunFireSeqCallback(int, int nXSprite) { pXSprite->data2--; if (pXSprite->data2 == 0) - evPost(nSprite, 3, 1, kCmdOff, nSprite); + evPost(nSprite, 3, 1, kCmdOff); } int dx = (Cos(pSprite->ang)>>16)+Random2(1000); int dy = (Sin(pSprite->ang)>>16)+Random2(1000); diff --git a/source/blood/src/triggers.h b/source/blood/src/triggers.h index a82f1ad55..9a759e8d8 100644 --- a/source/blood/src/triggers.h +++ b/source/blood/src/triggers.h @@ -35,11 +35,11 @@ BEGIN_BLD_NS #define kPlayerCtrlSigStart "<<<>>>" // save game TRPLAYERCTRL block end -void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command, short causedBy); +void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command); void trMessageSector(unsigned int nSector, EVENT event); -void trTriggerWall(unsigned int nWall, XWALL *pXWall, int command, short causedBy); +void trTriggerWall(unsigned int nWall, XWALL *pXWall, int command); void trMessageWall(unsigned int nWall, EVENT event); -void trTriggerSprite(unsigned int nSprite, XSPRITE *pXSprite, int command, short causedBy); +void trTriggerSprite(unsigned int nSprite, XSPRITE *pXSprite, int command); void trMessageSprite(unsigned int nSprite, EVENT event); void trProcessBusy(void); void trInit(void); @@ -69,7 +69,7 @@ void freeTargets(int nSprite); void freeAllTargets(XSPRITE* pXSource); bool affectedByTargetChg(XSPRITE* pXDude); int getDataFieldOfObject(int objType, int objIndex, int dataIndex); -bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value, int causedBy); +bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value); bool goalValueIsReached(XSPRITE* pXSprite); bool getDudesForTargetChg(XSPRITE* pXSprite); void stopWindOnSectors(XSPRITE* pXSource); @@ -84,7 +84,7 @@ void TeleFrag(int nKiller, int nSector); bool valueIsBetween(int val, int min, int max); void trPlayerCtrlLink(XSPRITE* pXSource, PLAYER* pPlayer); -void trPlayerCtrlStartScene(XSPRITE* pXSource, PLAYER* pPlayer, int causedBy); +void trPlayerCtrlStartScene(XSPRITE* pXSource, PLAYER* pPlayer); void trPlayerCtrlStopScene(XSPRITE* pXSource, PLAYER* pPlayer); // ------------------------------------------------------- diff --git a/source/blood/src/weapon.cpp b/source/blood/src/weapon.cpp index 45ebce1d8..0400b24ea 100644 --- a/source/blood/src/weapon.cpp +++ b/source/blood/src/weapon.cpp @@ -1005,7 +1005,7 @@ void ThrowCan(int, PLAYER *pPlayer) if (pSprite) { sfxPlay3DSound(pSprite, 441, 0, 0); - evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn, pPlayer->nSprite); + evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn); int nXSprite = pSprite->extra; XSPRITE *pXSprite = &xsprite[nXSprite]; pXSprite->Impact = 1; @@ -1020,7 +1020,7 @@ void DropCan(int, PLAYER *pPlayer) spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedSpray, 0); if (pSprite) { - evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn, pPlayer->nSprite); + evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn); UseAmmo(pPlayer, 6, gAmmoItemData[0].count); } } @@ -1029,7 +1029,7 @@ void ExplodeCan(int, PLAYER *pPlayer) { sfxKill3DSound(pPlayer->pSprite, -1, 441); spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedSpray, 0); - evPost(pSprite->index, 3, 0, kCmdOn, pPlayer->nSprite); + evPost(pSprite->index, 3, 0, kCmdOn); UseAmmo(pPlayer, 6, gAmmoItemData[0].count); StartQAV(pPlayer, 15, -1); pPlayer->curWeapon = 0; @@ -1047,7 +1047,7 @@ void ThrowBundle(int, PLAYER *pPlayer) if (pPlayer->fuseTime < 0) pXSprite->Impact = 1; else - evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn, pPlayer->nSprite); + evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn); UseAmmo(pPlayer, 5, 1); pPlayer->throwPower = 0; } @@ -1056,7 +1056,7 @@ void DropBundle(int, PLAYER *pPlayer) { sfxKill3DSound(pPlayer->pSprite, 16, -1); spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedTNTBundle, 0); - evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn, pPlayer->nSprite); + evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn); UseAmmo(pPlayer, 5, 1); } @@ -1064,7 +1064,7 @@ void ExplodeBundle(int, PLAYER *pPlayer) { sfxKill3DSound(pPlayer->pSprite, 16, -1); spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedTNTBundle, 0); - evPost(pSprite->index, 3, 0, kCmdOn, pPlayer->nSprite); + evPost(pSprite->index, 3, 0, kCmdOn); UseAmmo(pPlayer, 5, 1); StartQAV(pPlayer, 24, -1, 0); pPlayer->curWeapon = 0; @@ -1076,7 +1076,7 @@ void ThrowProx(int, PLAYER *pPlayer) int nSpeed = mulscale16(pPlayer->throwPower, 0x177777)+0x66666; sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0); spritetype *pSprite = playerFireThing(pPlayer, 0, -9460, kThingArmedProxBomb, nSpeed); - evPost(pSprite->index, 3, 240, kCmdOn, pPlayer->nSprite); + evPost(pSprite->index, 3, 240, kCmdOn); UseAmmo(pPlayer, 10, 1); pPlayer->throwPower = 0; } @@ -1084,7 +1084,7 @@ void ThrowProx(int, PLAYER *pPlayer) void DropProx(int, PLAYER *pPlayer) { spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedProxBomb, 0); - evPost(pSprite->index, 3, 240, kCmdOn, pPlayer->nSprite); + evPost(pSprite->index, 3, 240, kCmdOn); UseAmmo(pPlayer, 10, 1); } @@ -1111,7 +1111,7 @@ void DropRemote(int, PLAYER *pPlayer) void FireRemote(int, PLAYER *pPlayer) { - evSend(0, 0, 90+(pPlayer->pSprite->type-kDudePlayer1), kCmdOn, pPlayer->nSprite); + evSend(0, 0, 90+(pPlayer->pSprite->type-kDudePlayer1), kCmdOn); } #define kMaxShotgunBarrels 4 @@ -1946,9 +1946,9 @@ void WeaponProcess(PLAYER *pPlayer) { XSPRITE* pXSprite = &xsprite[sprite[nIndex].extra]; if (pXSprite->waitTime > 0 && --pXSprite->sysData1 <= 0) { if (pXSprite->txID > 0) - evSend(nIndex, 3, pXSprite->txID, (COMMAND_ID) pXSprite->command, pQavScene->causedBy); + evSend(nIndex, 3, pXSprite->txID, (COMMAND_ID) pXSprite->command); if (pXSprite->locked) trPlayerCtrlStopScene(pXSprite, pPlayer); - else evPost(nIndex, 3, 0, (COMMAND_ID) (kCmdNumberic + 4), pQavScene->causedBy); + else evPost(nIndex, 3, 0, (COMMAND_ID) (kCmdNumberic + 4)); } else { qavScenePlay(pPlayer); pPlayer->weaponTimer = ClipLow(pPlayer->weaponTimer -= 4, 0); From 3e3477c414443eb1ad8ee982d636947358be9ba4 Mon Sep 17 00:00:00 2001 From: Evan Ramos Date: Sun, 12 Jan 2020 15:00:32 -0600 Subject: [PATCH 18/51] Fix errors in PR # Conflicts: # source/blood/src/osdcmd.cpp # source/blood/src/view.cpp # source/build/src/mutex.cpp --- source/blood/src/eventq.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/blood/src/eventq.cpp b/source/blood/src/eventq.cpp index f66c17eb8..d9c8c50bf 100644 --- a/source/blood/src/eventq.cpp +++ b/source/blood/src/eventq.cpp @@ -353,8 +353,6 @@ char evGetSourceState(int nType, int nIndex) void evSend(int nIndex, int nType, int rxId, COMMAND_ID command) { - - switch (command) { case kCmdState: command = evGetSourceState(nType, nIndex) ? kCmdOn : kCmdOff; From 45a93fc57ee0b9f5212605a6e92bc270771c151a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 13 Jan 2020 18:05:43 +0100 Subject: [PATCH 19/51] - fixed a few bad or missing string labels. --- source/rr/src/screens.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/rr/src/screens.cpp b/source/rr/src/screens.cpp index ab47de266..f5e4bc01e 100644 --- a/source/rr/src/screens.cpp +++ b/source/rr/src/screens.cpp @@ -2712,14 +2712,14 @@ void G_BonusScreenRRRA(int32_t bonusonly) if (lastmapname) menutext(80, 16, lastmapname); - menutext(15, 192, GStrings("TXT_PRESSKEY")); + menutext(15, 192, GStrings("PRESSKEY")); const int yystep = 16; if (totalclock > (60*3)) { yy = zz = 48; - menutext(30, yy, "Yer Time:"); + menutext(30, yy, GStrings("TXT_YERTIME")); yy+= yystep; if (!(ud.volume_number == 0 && ud.last_level-1 == 7 && boardfilename[0])) @@ -2762,7 +2762,7 @@ void G_BonusScreenRRRA(int32_t bonusonly) // menutext(191 + 30 + (clockpad*24), yy, "New record!"); } else - menutext(191, yy, "Cheated!"); + menutext(191, yy, GStrings("TXT_Cheated")); yy+=yystep; if (!(ud.volume_number == 0 && ud.last_level-1 == 7 && boardfilename[0])) From a0d02f2bea522ecd2411643ddfa15def0257d256 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 13 Jan 2020 18:07:34 +0100 Subject: [PATCH 20/51] - text fixes. --- wadsrc/static/engine/language.csv | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/wadsrc/static/engine/language.csv b/wadsrc/static/engine/language.csv index eb696b0a9..724423de4 100644 --- a/wadsrc/static/engine/language.csv +++ b/wadsrc/static/engine/language.csv @@ -1581,7 +1581,7 @@ fans for giving,fans for giving,,,,,unsere Fans für,,,,,,,,,,,,,,,,, us big heads.,us big heads.,,,,,ihre Unterstützung.,,,,,,,,,,,,,,,,, Look for a Duke Nukem 3D,Look for a Duke Nukem 3D,,,,,Haltet bald Ausschau nach,,,,,,,,,,,,,,,,, sequel soon.,sequel soon.,,,,,dem Duke Nukem 3D Sequel,,,,,,,,,,,,,,,,, -Press any key to continue,Presskey,,,,,Drüclke eine Taste um fortzufahren.,,,,,,,,,,,,,,,,, +Press any key to continue,Presskey,,,,,Drücke eine Taste um fortzufahren.,,,,,,,,,,,,,,,,, Kills,Kills,,,,Zabití,,,Mortigoj,Asesinatos,,Tapot,Victimes,Ölések,Uccisioni,キル,킬수,Doodt,Zabójstwa,Vítimas,,,Убийства,Убиства Completed,Completed,,,,Dokončen,Abgeschlossen,,Finita,Completado,,Suoritettu,terminé,Teljesítve,Finito,攻略,완료,Klaar,Ukończono,Finalizado,,,Уровень завершён,Ниво завршен Your Time:,TXT_YOURTIME,,,,,Deine Zeit:,,,,,,,,,,,,,,,,, @@ -1589,11 +1589,9 @@ Yer Time:,TXT_YERTIME,,,,,Deine Zeit:,,,,,,,,,,,,,,,,, Par Time:,TXT_PARTIME,,,,,Par Zeit:,,,,,,,,,,,,,,,,, 3D Realms' Time:,TXT_3DRTIME,,,,,3D Realms Zeit:,,,,,,,,,,,,,,,,, Green Beret's Time:,TXT_3DRTIME,,"Nam, WW2GI",,,Green Berets Zeit:,,,,,,,,,,,,,,,,, -Xatrix Time:,"TXT_XTRTIME -",,,,,Xatrix Zeit:,,,,,,,,,,,,,,,,, +Xatrix Time:,TXT_XTRTIME,,,,,Xatrix Zeit:,,,,,,,,,,,,,,,,, Prev Best Time:,TXT_PREVBEST,,,,,Vorh. Bestzeit:,,,,,,,,,,,,,,,,, -Your Best Time:,"TXT_YOURBEST -",,,,,Deine Bestzeit:,,,,,,,,,,,,,,,,, +Your Best Time:,TXT_YOURBEST,,,,,Deine Bestzeit:,,,,,,,,,,,,,,,,, New record!,TXT_NEWRECORD,,,,,"Neuer Rekord! ",,,,,,,,,,,,,,,,, Cheated!,TXT_CHEATED,,,,,Geschummelt!,,,,,,,,,,,,,,,,, From a8614c89ddb5999e895a9ecdcbbf8af0ef96a000 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 13 Jan 2020 19:50:25 +0100 Subject: [PATCH 21/51] Fix incorrect pitch size when creating savepic --- source/common/rendering/gl/renderer/gl_renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/rendering/gl/renderer/gl_renderer.cpp b/source/common/rendering/gl/renderer/gl_renderer.cpp index 79402cbec..9dc164d50 100644 --- a/source/common/rendering/gl/renderer/gl_renderer.cpp +++ b/source/common/rendering/gl/renderer/gl_renderer.cpp @@ -238,7 +238,7 @@ void FGLRenderer::WriteSavePic ( FileWriter *file, int width, int height) int numpixels = width * height; uint8_t* scr = (uint8_t*)Xmalloc(numpixels * 3); glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, scr); - M_CreatePNG(file, scr + ((height - 1) * width), nullptr, SS_RGB, width, height, -width, vid_gamma); + M_CreatePNG(file, scr + ((height - 1) * width * 3), nullptr, SS_RGB, width, height, -width * 3, vid_gamma); Xfree(scr); } From e923ef5d3acbb0a1596094afdf836f02ae554480 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 14 Jan 2020 14:22:03 +0100 Subject: [PATCH 22/51] Add missing M_FinishPNG call --- source/common/rendering/gl/renderer/gl_renderer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/common/rendering/gl/renderer/gl_renderer.cpp b/source/common/rendering/gl/renderer/gl_renderer.cpp index 9dc164d50..560f8cbe4 100644 --- a/source/common/rendering/gl/renderer/gl_renderer.cpp +++ b/source/common/rendering/gl/renderer/gl_renderer.cpp @@ -239,6 +239,7 @@ void FGLRenderer::WriteSavePic ( FileWriter *file, int width, int height) uint8_t* scr = (uint8_t*)Xmalloc(numpixels * 3); glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, scr); M_CreatePNG(file, scr + ((height - 1) * width * 3), nullptr, SS_RGB, width, height, -width * 3, vid_gamma); + M_FinishPNG(file); Xfree(scr); } From 7b6bd34a5853f4c615f444a27385b65eae7d33da Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Jan 2020 19:50:47 +0100 Subject: [PATCH 23/51] - create the savepic framebuffer without multisampling. It didn't work and doesn't need it so let's save that piece of video memory. --- source/common/rendering/gl/renderer/gl_renderbuffers.cpp | 3 ++- source/common/rendering/gl/renderer/gl_renderbuffers.h | 3 ++- source/common/rendering/gl/renderer/gl_renderer.cpp | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/common/rendering/gl/renderer/gl_renderbuffers.cpp b/source/common/rendering/gl/renderer/gl_renderbuffers.cpp index 37617cee8..1aaa6cd3a 100644 --- a/source/common/rendering/gl/renderer/gl_renderbuffers.cpp +++ b/source/common/rendering/gl/renderer/gl_renderbuffers.cpp @@ -44,8 +44,9 @@ namespace OpenGLRenderer // //========================================================================== -FGLRenderBuffers::FGLRenderBuffers() +FGLRenderBuffers::FGLRenderBuffers(int ms) { + gl_multisample = ms; glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples); } diff --git a/source/common/rendering/gl/renderer/gl_renderbuffers.h b/source/common/rendering/gl/renderer/gl_renderbuffers.h index d1fb45666..88b7360f0 100644 --- a/source/common/rendering/gl/renderer/gl_renderbuffers.h +++ b/source/common/rendering/gl/renderer/gl_renderbuffers.h @@ -101,8 +101,9 @@ private: class FGLRenderBuffers { + int gl_multisample = 0; // intentionally overload the global CVAR public: - FGLRenderBuffers(); + FGLRenderBuffers(int ms); ~FGLRenderBuffers(); void Setup(int width, int height, int sceneWidth, int sceneHeight); diff --git a/source/common/rendering/gl/renderer/gl_renderer.cpp b/source/common/rendering/gl/renderer/gl_renderer.cpp index 560f8cbe4..7bde82962 100644 --- a/source/common/rendering/gl/renderer/gl_renderer.cpp +++ b/source/common/rendering/gl/renderer/gl_renderer.cpp @@ -88,8 +88,8 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) void FGLRenderer::Initialize(int width, int height) { - mScreenBuffers = new FGLRenderBuffers(); - mSaveBuffers = new FGLRenderBuffers(); + mScreenBuffers = new FGLRenderBuffers(gl_multisample); + mSaveBuffers = new FGLRenderBuffers(0); mBuffers = mScreenBuffers; mPresentShader = new FPresentShader(); mPresent3dCheckerShader = new FPresent3DCheckerShader(); From 6ace2f8bf01a7ac505d408e3288fa8035bc1579d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Jan 2020 20:12:08 +0100 Subject: [PATCH 24/51] - added savepic generation to RR. --- source/rr/src/duke3d.h | 1 + source/rr/src/game.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/source/rr/src/duke3d.h b/source/rr/src/duke3d.h index 0b73ca1e5..1a840434c 100644 --- a/source/rr/src/duke3d.h +++ b/source/rr/src/duke3d.h @@ -148,6 +148,7 @@ struct GameInterface : ::GameInterface int app_main() override; void UpdateScreenSize() override; void FreeGameData() override; + bool GenerateSavePic() override; bool validate_hud(int) override; void set_hud_layout(int size) override; void set_hud_scale(int size) override; diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index ccaf44f5e..f33952647 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -1510,6 +1510,13 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) } } +bool GameInterface::GenerateSavePic() +{ + G_DrawRooms(myconnectindex, 65536); + return true; +} + + void G_DumpDebugInfo(void) { int32_t j,x; From e30975581be7c44ed602d091f6a51eacaa9544b4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Jan 2020 20:44:20 +0100 Subject: [PATCH 25/51] - enabled savegame pictures in Shadow Warrior. Unlike the original game this enables mirrors - no idea why they were disabled, some limitation of the software renderer, maybe? --- source/sw/src/draw.cpp | 20 ++++---------------- source/sw/src/game.h | 1 + 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index f3ccadacf..4d5c270b8 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -2049,7 +2049,7 @@ drawscreen(PLAYERp pp) DrawScreen = TRUE; PreDraw(); // part of new border refresh method - if (RedrawScreen) + if (RedrawScreen && !ScreenSavePic) { RedrawCompass = TRUE; RedrawScreen = FALSE; @@ -2189,7 +2189,7 @@ drawscreen(PLAYERp pp) DrawOverlapRoom(tx, ty, tz, tang, thoriz, tsectnum); OverlapDraw = FALSE; - if (dimensionmode != 6 && !ScreenSavePic) + if (dimensionmode != 6)// && !ScreenSavePic) { // TEST this! Changed to camerapp //JS_DrawMirrors(camerapp, tx, ty, tz, tang, thoriz); @@ -2444,27 +2444,15 @@ DrawCompass(PLAYERp pp) -#if 0 -int -ScreenSaveSetup(PLAYERp pp) +bool GameInterface::GenerateSavePic() { short i; - ScreenLoadSaveSetup(Player + myconnectindex); - - renderSetTarget(SAVE_SCREEN_TILE, SAVE_SCREEN_YSIZE, SAVE_SCREEN_XSIZE); - ScreenSavePic = TRUE; drawscreen(Player + myconnectindex); ScreenSavePic = FALSE; - - renderRestoreTarget(); - - return SAVE_SCREEN_TILE; + return true; } -#endif - - END_SW_NS diff --git a/source/sw/src/game.h b/source/sw/src/game.h index f4641109a..db19273f8 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -2431,6 +2431,7 @@ struct GameInterface : ::GameInterface int app_main() override; void UpdateScreenSize() override; void FreeGameData() override; + bool GenerateSavePic() override; bool validate_hud(int) override; void set_hud_layout(int size) override; void set_hud_scale(int size) override; From 8db6a4331baf508fd6fec9907ac17a28acb6bf49 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Jan 2020 21:20:46 +0100 Subject: [PATCH 26/51] - added savepic generation for Blood. --- source/blood/src/blood.h | 1 + source/blood/src/view.cpp | 11 ++++++++++- source/blood/src/view.h | 2 +- source/sw/src/draw.cpp | 2 -- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source/blood/src/blood.h b/source/blood/src/blood.h index 7ba2ed942..287c47863 100644 --- a/source/blood/src/blood.h +++ b/source/blood/src/blood.h @@ -85,6 +85,7 @@ struct GameInterface : ::GameInterface void faketimerhandler() override; int app_main() override; void UpdateScreenSize() override; + bool GenerateSavePic() override; void FreeGameData() override; bool validate_hud(int) override; void set_hud_layout(int size) override; diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index da9b99db8..a030850ef 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -3064,7 +3064,7 @@ int gLastPal = 0; int32_t g_frameRate; -void viewDrawScreen(void) +void viewDrawScreen(bool sceneonly) { int nPalette = 0; static ClockTicks lastUpdate; @@ -3406,6 +3406,7 @@ void viewDrawScreen(void) renderDrawMasks(); gView->pSprite->cstat = bakCstat; screen->FinishScene(); + if (sceneonly) return; if (v78 || bDelirium) { @@ -3593,6 +3594,14 @@ void viewDrawScreen(void) UpdateDacs(nPalette); } +bool GameInterface::GenerateSavePic() +{ + viewDrawScreen(true); + return true; +} + + + int nLoadingScreenTile; char pzLoadingScreenText1[256], pzLoadingScreenText2[256], pzLoadingScreenText3[256]; diff --git a/source/blood/src/view.h b/source/blood/src/view.h index adcae4f9c..804b1d598 100644 --- a/source/blood/src/view.h +++ b/source/blood/src/view.h @@ -144,7 +144,7 @@ void viewDisplayMessage(void); void viewSetErrorMessage(const char *pMessage); void DoLensEffect(void); void UpdateDacs(int nPalette, bool bNoTint = false); -void viewDrawScreen(void); +void viewDrawScreen(bool sceneonly = false); void viewLoadingScreenWide(void); void viewLoadingScreenUpdate(const char *pzText4 = NULL, int nPercent = -1); void viewLoadingScreen(int nTile, const char *pText, const char *pText2, const char *pText3); diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 4d5c270b8..dc1ed5609 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -2446,8 +2446,6 @@ DrawCompass(PLAYERp pp) bool GameInterface::GenerateSavePic() { - short i; - ScreenSavePic = TRUE; drawscreen(Player + myconnectindex); ScreenSavePic = FALSE; From 5739b4b024e80f7dff502bd7ac4d9b42082c56ae Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Jan 2020 21:48:01 +0100 Subject: [PATCH 27/51] - added savepic generation to Exhumed. --- source/exhumed/src/exhumed.h | 1 + source/exhumed/src/view.cpp | 41 ++++++++++++++++-------------------- source/exhumed/src/view.h | 2 +- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index 1196ad70b..08863fb25 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -275,6 +275,7 @@ struct GameInterface : ::GameInterface { int app_main() override; void UpdateScreenSize() override; + bool GenerateSavePic() override; bool validate_hud(int) override { return true; } void set_hud_layout(int size) override {} void set_hud_scale(int size) override {} diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index df8c9891c..5e14f9509 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -357,7 +357,7 @@ static inline fix16_t q16angle_interpolate16(fix16_t a, fix16_t b, int smooth) return a + mulscale16(((b+F16(1024)-a)&0x7FFFFFF)-F16(1024), smooth); } -void DrawView(int smoothRatio) +void DrawView(int smoothRatio, bool sceneonly) { int playerX; int playerY; @@ -366,27 +366,14 @@ void DrawView(int smoothRatio) fix16_t nAngle; fix16_t pan; -#if 0 - if (bgpages <= 0) - { - if (textpages > 0) - { - textpages--; - FlushMessageLine(); - } - } - else + + if (!sceneonly) { RefreshBackground(); - bgpages--; - } -#else - //FlushMessageLine(); - RefreshBackground(); -#endif - if (!bFullScreen) { - MaskStatus(); + if (!bFullScreen) { + MaskStatus(); + } } zbob = Sin(2 * bobangle) >> 3; @@ -395,7 +382,7 @@ void DrawView(int smoothRatio) int nPlayerOldCstat = sprite[nPlayerSprite].cstat; int nDoppleOldCstat = sprite[nDoppleSprite[nLocalPlayer]].cstat; - if (nSnakeCam >= 0) + if (nSnakeCam >= 0 && !sceneonly) { int nSprite = SnakeList[nSnakeCam].nSprites[0]; @@ -438,9 +425,9 @@ void DrawView(int smoothRatio) nCameraa = nAngle; - if (!bCamera || nFreeze) + if (!bCamera || nFreeze || sceneonly) { - if (nSnakeCam >= 0) + if (nSnakeCam >= 0 && !sceneonly) { pan = F16(92); viewz = playerZ; @@ -602,7 +589,7 @@ void DrawView(int smoothRatio) } } } - else + else if (!sceneonly) { if (nSnakeCam < 0) { @@ -637,6 +624,14 @@ void DrawView(int smoothRatio) flash = 0; } +bool GameInterface::GenerateSavePic() +{ + DrawView(65536, true); + return true; +} + + + void NoClip() { videoSetViewableArea(0, 0, xdim - 1, ydim - 1); diff --git a/source/exhumed/src/view.h b/source/exhumed/src/view.h index b583e8031..40e4db297 100644 --- a/source/exhumed/src/view.h +++ b/source/exhumed/src/view.h @@ -35,7 +35,7 @@ extern short bCamera; void InitView(); void SetView1(); void RefreshBackground(); -void DrawView(int smoothRatio); +void DrawView(int smoothRatio, bool sceneonly = false); void MySetView(int x1, int y1, int x2, int y2); void ResetView(); void NoClip(); From 4aacd6d95836370c92042dc95376c9f3e8128e8d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Jan 2020 22:37:23 +0100 Subject: [PATCH 28/51] - display the savepics. - fixed level name list in Exhumed. --- source/common/menu/savegamemanager.cpp | 2 +- source/common/textures/formats/pngtexture.cpp | 126 ++++++++++++++++++ source/glbackend/hw_draw2d.cpp | 1 + wadsrc/static/engine/language.csv | 66 ++++----- 4 files changed, 161 insertions(+), 34 deletions(-) diff --git a/source/common/menu/savegamemanager.cpp b/source/common/menu/savegamemanager.cpp index 45bf519f1..e1f20a9ca 100644 --- a/source/common/menu/savegamemanager.cpp +++ b/source/common/menu/savegamemanager.cpp @@ -403,7 +403,7 @@ unsigned FSavegameManager::ExtractSaveData(int index) PNGHandle *png = M_VerifyPNG(picreader); if (png != nullptr) { - SavePic = nullptr; // not yet implemented: PNGTexture_CreateFromFile(png, node->Filename); + SavePic = PNGTexture_CreateFromFile(png, node->Filename); delete png; if (SavePic && SavePic->GetWidth() == 1 && SavePic->GetHeight() == 1) { diff --git a/source/common/textures/formats/pngtexture.cpp b/source/common/textures/formats/pngtexture.cpp index df0c1a029..04b962871 100644 --- a/source/common/textures/formats/pngtexture.cpp +++ b/source/common/textures/formats/pngtexture.cpp @@ -511,3 +511,129 @@ int FPNGTexture::CopyPixels(FBitmap *bmp, int conversion) } +//========================================================================== +// +// A savegame picture +// This is essentially a stripped down version of the PNG texture +// only supporting the features actually present in a savegame +// that does not use an image source, because image sources are not +// meant to be transient data like the savegame picture. +// +//========================================================================== + +class FPNGFileTexture : public FTexture +{ +public: + FPNGFileTexture (FileReader &lump, int width, int height, uint8_t colortype); + virtual FBitmap GetBgraBitmap(const PalEntry *remap, int *trans) override; + +protected: + + FileReader fr; + uint8_t ColorType; + int PaletteSize; +}; + + +//========================================================================== +// +// +// +//========================================================================== + +FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename) +{ + if (M_FindPNGChunk(png, MAKE_ID('I','H','D','R')) == 0) + { + return nullptr; + } + + // Savegame images can only be either 8 bit paletted or 24 bit RGB + auto &data = png->File; + int width = data.ReadInt32BE(); + int height = data.ReadInt32BE(); + uint8_t bitdepth = data.ReadUInt8(); + uint8_t colortype = data.ReadUInt8(); + uint8_t compression = data.ReadUInt8(); + uint8_t filter = data.ReadUInt8(); + uint8_t interlace = data.ReadUInt8(); + + // Reject anything that cannot be put into a savegame picture by GZDoom itself. + if (compression != 0 || filter != 0 || interlace > 0 || bitdepth != 8 || (colortype != 2 && colortype != 3)) return nullptr; + else return new FPNGFileTexture (png->File, width, height, colortype); +} + +//========================================================================== +// +// +// +//========================================================================== + +FPNGFileTexture::FPNGFileTexture (FileReader &lump, int width, int height, uint8_t colortype) +: ColorType(colortype) +{ + Size.x = width; + Size.y = height; + fr = std::move(lump); +} + +//=========================================================================== +// +// FPNGTexture::CopyPixels +// +//=========================================================================== + +FBitmap FPNGFileTexture::GetBgraBitmap(const PalEntry *remap, int *trans) +{ + FBitmap bmp; + // Parse pre-IDAT chunks. I skip the CRCs. Is that bad? + PalEntry pe[256]; + uint32_t len, id; + int pixwidth = Size.x * (ColorType == 2? 3:1); + + FileReader *lump = &fr; + + bmp.Create(Size.x, Size.y); + lump->Seek(33, FileReader::SeekSet); + lump->Read(&len, 4); + lump->Read(&id, 4); + while (id != MAKE_ID('I','D','A','T') && id != MAKE_ID('I','E','N','D')) + { + len = BigLong((unsigned int)len); + if (id != MAKE_ID('P','L','T','E')) + lump->Seek (len, FileReader::SeekCur); + else + { + PaletteSize = std::min (len / 3, 256); + for(int i = 0; i < PaletteSize; i++) + { + pe[i].r = lump->ReadUInt8(); + pe[i].g = lump->ReadUInt8(); + pe[i].b = lump->ReadUInt8(); + pe[i].a = 255; + } + } + lump->Seek(4, FileReader::SeekCur); // Skip CRC + lump->Read(&len, 4); + id = MAKE_ID('I','E','N','D'); + lump->Read(&id, 4); + } + auto StartOfIDAT = (uint32_t)lump->Tell() - 8; + + TArray Pixels(pixwidth * Size.y); + + lump->Seek (StartOfIDAT, FileReader::SeekSet); + lump->Read(&len, 4); + lump->Read(&id, 4); + M_ReadIDAT (*lump, Pixels.Data(), Size.x, Size.y, pixwidth, 8, ColorType, 0, BigLong((unsigned int)len)); + + if (ColorType == 3) + { + bmp.CopyPixelData(0, 0, Pixels.Data(), Size.x, Size.y, 1, Size.x, 0, pe); + } + else + { + bmp.CopyPixelDataRGB(0, 0, Pixels.Data(), Size.x, Size.y, 3, pixwidth, 0, CF_RGB); + } + return bmp; +} \ No newline at end of file diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index a16f62a8f..e4ec15f20 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -164,6 +164,7 @@ void GLInstance::Draw2D(F2DDrawer *drawer) if (cmd.mTexture != nullptr) { auto tex = cmd.mTexture; + if (cmd.mType == F2DDrawer::DrawTypeRotateSprite) { // todo: Set up hictinting. (broken as the feature is...) diff --git a/wadsrc/static/engine/language.csv b/wadsrc/static/engine/language.csv index 724423de4..07f16bb2b 100644 --- a/wadsrc/static/engine/language.csv +++ b/wadsrc/static/engine/language.csv @@ -2090,36 +2090,36 @@ The Morgue/mortuary (dm),TXTS_T_MAP24,,,,,,,,,,,,,,,,,,,,,, Island Caves (dm),TXTS_T_MAP25,,,,,,,,,,,,,,,,,,,,,, Twin Dragon,TXTS_T_TITLE,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP00,Training,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP01,Abu Simbel,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP02,Dendur,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP03,Kalabash,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP04,El Subua,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP05,El Derr,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP06,Abu Churab,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP07,Philae,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP08,El Kab,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP09,Aswan,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP10,10,Does not have a readable name.,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP11,Qubbet el Kawa,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP12,Abydos,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP13,Edufu,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP14,West Bank,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP15,Luxor,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP16,Karnak,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP17,Saqqara,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP18,Mitrrahn,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP19,19,Does not have a readable name.,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP20,20,Does not have a readable name.,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP21,Level 21,No names exist for the MP levels,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP22,Level 22,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP23,Level 23,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP24,Level 24,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP25,Level 25,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP26,Level 26,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP27,Level 27,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP28,Level 28,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP29,Level 29,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP30,Level 30,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP31,Level 31,,,,,,,,,,,,,,,,,,,,,, -TXT_EX_MAP32,Level 32,,,,,,,,,,,,,,,,,,,,,, \ No newline at end of file +Training,TXT_EX_MAP00,,,,,,,,,,,,,,,,,,,,,, +Abu Simbel,TXT_EX_MAP01,,,,,,,,,,,,,,,,,,,,,, +Dendur,TXT_EX_MAP02,,,,,,,,,,,,,,,,,,,,,, +Kalabash,TXT_EX_MAP03,,,,,,,,,,,,,,,,,,,,,, +El Subua,TXT_EX_MAP04,,,,,,,,,,,,,,,,,,,,,, +El Derr,TXT_EX_MAP05,,,,,,,,,,,,,,,,,,,,,, +Abu Churab,TXT_EX_MAP06,,,,,,,,,,,,,,,,,,,,,, +Philae,TXT_EX_MAP07,,,,,,,,,,,,,,,,,,,,,, +El Kab,TXT_EX_MAP08,,,,,,,,,,,,,,,,,,,,,, +Aswan,TXT_EX_MAP09,,,,,,,,,,,,,,,,,,,,,, +10,TXT_EX_MAP10,Does not have a readable name.,,,,,,,,,,,,,,,,,,,,, +Qubbet el Kawa,TXT_EX_MAP11,,,,,,,,,,,,,,,,,,,,,, +Abydos,TXT_EX_MAP12,,,,,,,,,,,,,,,,,,,,,, +Edufu,TXT_EX_MAP13,,,,,,,,,,,,,,,,,,,,,, +West Bank,TXT_EX_MAP14,,,,,,,,,,,,,,,,,,,,,, +Luxor,TXT_EX_MAP15,,,,,,,,,,,,,,,,,,,,,, +Karnak,TXT_EX_MAP16,,,,,,,,,,,,,,,,,,,,,, +Saqqara,TXT_EX_MAP17,,,,,,,,,,,,,,,,,,,,,, +Mitrrahn,TXT_EX_MAP18,,,,,,,,,,,,,,,,,,,,,, +19,TXT_EX_MAP19,Does not have a readable name.,,,,,,,,,,,,,,,,,,,,, +20,TXT_EX_MAP20,Does not have a readable name.,,,,,,,,,,,,,,,,,,,,, +Level 21,TXT_EX_MAP21,No names exist for the MP levels,,,,,,,,,,,,,,,,,,,,, +Level 22,TXT_EX_MAP22,,,,,,,,,,,,,,,,,,,,,, +Level 23,TXT_EX_MAP23,,,,,,,,,,,,,,,,,,,,,, +Level 24,TXT_EX_MAP24,,,,,,,,,,,,,,,,,,,,,, +Level 25,TXT_EX_MAP25,,,,,,,,,,,,,,,,,,,,,, +Level 26,TXT_EX_MAP26,,,,,,,,,,,,,,,,,,,,,, +Level 27,TXT_EX_MAP27,,,,,,,,,,,,,,,,,,,,,, +Level 28,TXT_EX_MAP28,,,,,,,,,,,,,,,,,,,,,, +Level 29,TXT_EX_MAP29,,,,,,,,,,,,,,,,,,,,,, +Level 30,TXT_EX_MAP30,,,,,,,,,,,,,,,,,,,,,, +Level 31,TXT_EX_MAP31,,,,,,,,,,,,,,,,,,,,,, +Level 32,TXT_EX_MAP32,,,,,,,,,,,,,,,,,,,,,, \ No newline at end of file From c0c18db7cde744f17235811812038757bdfdd346 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Jan 2020 18:36:53 +0100 Subject: [PATCH 29/51] - dynamically allocate the large networking buffers. These waste a whopping 800MB of address space, which on 32 bit could be the deciding factor for exhausting available memory. --- source/duke3d/src/network.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/duke3d/src/network.cpp b/source/duke3d/src/network.cpp index 13b90b70d..80c581c9e 100644 --- a/source/duke3d/src/network.cpp +++ b/source/duke3d/src/network.cpp @@ -457,12 +457,12 @@ static uint32_t g_cl_InterpolatedRevision = 0; static netmapstate_t g_mapStartState; -static netmapstate_t g_cl_InterpolatedMapStateHistory[NET_REVISIONS]; +static TArray g_cl_InterpolatedMapStateHistory; // note that the map state number is not an index into here, // to get the index into this array out of a map state number, do % NET_REVISONS -static netmapstate_t g_mapStateHistory[NET_REVISIONS]; -static uint8_t tempnetbuf[MAX_WORLDBUFFER]; +static TArray g_mapStateHistory; +static TArray tempnetbuf; // Remember that this constant needs to be one bit longer than a struct index, so it can't be mistaken for a valid wall, sprite, or sector index static const int32_t cSTOP_PARSING_CODE = ((1 << NETINDEX_BITS) - 1); @@ -4211,8 +4211,8 @@ static void Net_SendWorldUpdate(uint32_t fromRevisionNumber, uint32_t toRevision return; } - Bassert(MAX_WORLDBUFFER == ARRAY_SIZE(tempnetbuf)); - Bassert(NET_REVISIONS == ARRAY_SIZE(g_mapStateHistory)); + //Bassert(MAX_WORLDBUFFER == ARRAY_SIZE(tempnetbuf)); + //Bassert(NET_REVISIONS == ARRAY_SIZE(g_mapStateHistory)); uint32_t playerRevisionIsTooOld = (toRevisionNumber - fromRevisionNumber) > NET_REVISIONS; @@ -4950,7 +4950,7 @@ void Net_SendServerUpdates(void) serverupdate.pause_on = ud.pause_on; serverupdate.numplayers = 0; - updatebuf = tempnetbuf + sizeof(serverupdate_t); + updatebuf = tempnetbuf.Data() + sizeof(serverupdate_t); for (TRAVERSE_CONNECT(i)) { @@ -4988,7 +4988,7 @@ void Net_SendServerUpdates(void) return; } - Bmemcpy(tempnetbuf, &serverupdate, sizeof(serverupdate_t)); + Bmemcpy(tempnetbuf.Data(), &serverupdate, sizeof(serverupdate_t)); enet_host_broadcast( g_netServer, CHAN_MOVE, @@ -5155,6 +5155,9 @@ void Net_InitMapStateHistory() void Net_StartNewGame() { + g_mapStateHistory.Resize(NET_REVISIONS); + g_cl_InterpolatedMapStateHistory.Resize(NET_REVISIONS); + tempnetbuf.Resize(MAX_WORLDBUFFER); Net_ResetPlayers(); Net_ExtractNewGame(&pendingnewgame, 0); From a4d8e68b9f60d4eae0c44eceb8d749e20a6bc647 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Jan 2020 20:39:41 +0100 Subject: [PATCH 30/51] - added an engine credits menu page. --- source/common/menu/menu.cpp | 10 + source/common/menu/optionmenuitems.h | 2 +- source/common/utility/namedef.h | 2 + source/duke3d/CMakeLists.txt | 1 - source/duke3d/src/menus.cpp | 225 ------------- source/duke3d/src/menus.h | 85 ----- source/rr/CMakeLists.txt | 1 - source/rr/src/menus.cpp | 62 ---- source/rr/src/menus.h | 462 --------------------------- wadsrc/static/engine/menudef.txt | 46 ++- 10 files changed, 58 insertions(+), 838 deletions(-) delete mode 100644 source/duke3d/src/menus.cpp delete mode 100644 source/rr/src/menus.cpp diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index 2ed7f564d..caf9888f7 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -466,6 +466,16 @@ bool M_SetMenu(FName menu, int param, FName caller) case NAME_SkillMenu: GameStartupInfo.Skill = param; break; + + case NAME_EngineCredits: + case NAME_EngineCredits2: + { + auto m = DMenu::CurrentMenu; + DMenu::CurrentMenu = m->mParentMenu; + m->mParentMenu = nullptr; + toDelete.Push(m); + break; + } } switch (menu) diff --git a/source/common/menu/optionmenuitems.h b/source/common/menu/optionmenuitems.h index b4cb5c4e2..48c94523d 100644 --- a/source/common/menu/optionmenuitems.h +++ b/source/common/menu/optionmenuitems.h @@ -67,7 +67,7 @@ public: bool Activate(FName caller) override { M_MenuSound(CursorSound); - M_SetMenu(mAction, mParam); + M_SetMenu(mAction, mParam, static_cast(DMenu::CurrentMenu)->GetDescriptor()->mMenuName); return true; } }; diff --git a/source/common/utility/namedef.h b/source/common/utility/namedef.h index 3f0048f4a..f63706660 100644 --- a/source/common/utility/namedef.h +++ b/source/common/utility/namedef.h @@ -50,4 +50,6 @@ xx(Alresamplers) xx(AdvSoundOptions) xx(JoystickConfigMenu) xx(JoystickOptions) +xx(EngineCredits) +xx(EngineCredits2) diff --git a/source/duke3d/CMakeLists.txt b/source/duke3d/CMakeLists.txt index 404cac0e8..53b8c1065 100644 --- a/source/duke3d/CMakeLists.txt +++ b/source/duke3d/CMakeLists.txt @@ -66,7 +66,6 @@ set( PCH_SOURCES src/gameexec.cpp src/gamevars.cpp src/global.cpp - src/menus.cpp src/namesdyn.cpp src/network.cpp src/osdcmds.cpp diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp deleted file mode 100644 index caa23f7f9..000000000 --- a/source/duke3d/src/menus.cpp +++ /dev/null @@ -1,225 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2016 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- - -#include "ns.h" // Must come before everything else! - -#include "cheats.h" -#include "compat.h" -#include "demo.h" -#include "duke3d.h" - -#include "menus.h" -#include "osdcmds.h" -#include "savegame.h" -#include "superfasthash.h" -#include "gamecvars.h" -#include "gamecontrol.h" -#include "c_bind.h" -#include "../../glbackend/glbackend.h" - -bool ShowOptionMenu(); - -namespace ImGui -{ - void ShowDemoWindow(bool*); -} - -BEGIN_DUKE_NS - -#if 0 - -void Menu_Init(void) -{ - int32_t i, j, k; - - if (FURY) - // prepare shareware - if (VOLUMEONE) - { - // blue out episodes beyond the first - for (i = 1; i < g_volumeCnt; ++i) - { - if (MEL_EPISODE[i]) - { - ME_EPISODE[i].entry = &MEO_EPISODE_SHAREWARE; - ME_EPISODE[i].flags |= MEF_LookDisabled; - } - } - M_EPISODE.numEntries = g_volumeCnt; // remove User Map (and spacer) - MEOS_NETOPTIONS_EPISODE.numOptions = 1; - MenuEntry_DisableOnCondition(&ME_NETOPTIONS_EPISODE, 1); - } - - -} - - - -static void Menu_PreDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) -{ - int32_t i, j, l = 0; - - switch (cm) - { - - case MENU_CREDITS4: // JBF 20031220 - { -#define MENU_YOFFSET 40 -#define MENU_INCREMENT(x) (oy += ((x) << 16)) // maybe this should have been MENU_EXCREMENT instead - - int32_t oy = origin.y; - - mgametextcenter(origin.x, MENU_INCREMENT(MENU_YOFFSET), "Developers"); - creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(11), "Richard \"TerminX\" Gobeille", 8); - creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(7), "Evan \"Hendricks266\" Ramos", 8); - creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(7), "Alex \"pogokeen\" Dawson", 8); - - mgametextcenter(origin.x, MENU_INCREMENT(11), "Retired developers"); - creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(11), "Pierre-Loup \"Plagman\" Griffais", 8); - creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(7), "Philipp \"Helixhorned\" Kutin", 8); - - mgametextcenter(origin.x, MENU_INCREMENT(11), "Special thanks to"); - creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(11), "Jonathon \"JonoF\" Fowler", 8); - - mgametextcenter(origin.x, MENU_INCREMENT(11), "Uses BUILD Engine technology by"); - creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(11), "Ken \"Awesoken\" Silverman", 8); - -#undef MENU_INCREMENT -#undef MENU_YOFFSET - } - break; - - case MENU_CREDITS5: - l = 7; - - mgametextcenter(origin.x, origin.y + ((38-l)<<16), "License and Other Contributors"); - { - static const char *header[] = - { - "This program is distributed under the terms of the", - "GNU General Public License version 2 as published by the", - "Free Software Foundation. See gpl-2.0.txt for details.", - "BUILD engine technology available under license. See buildlic.txt.", - nullptr, - "The EDuke32 team thanks the following people for their contributions:", - nullptr, - }; - static const char *body[] = - { - "Alexey Skrybykin", // Nuke.YKT - Polymost fixes - "Bioman", // GTK work, APT repository and package upkeep - "Brandon Bergren", // "Bdragon" - tiles.cfg - "Charlie Honig", // "CONAN" - showview command - "Dan Gaskill", // "DeeperThought" - testing - "David Koenig", // "Bargle" - Merged a couple of things from duke3d_w32 - "Ed Coolidge", // Mapster32 improvements - "Emile Belanger", // original Android work - "Fox", // various patches - "Hunter_rus", // tons of stuff - "James Bentler", // Mapster32 improvements - "Jasper Foreman", // netcode contributions - "Javier Martinez", // "Malone3D" - EDuke 2.1.1 components - "Jeff Hart", // website graphics - "Jonathan Strander", // "Mblackwell" - testing and feature speccing - "Jordon Moss", // "Striker" - various patches, OldMP work - "Jose del Castillo", // "Renegado" - EDuke 2.1.1 components - "Lachlan McDonald", // official EDuke32 icon - "LSDNinja", // OS X help and testing - "Marcus Herbert", // "rhoenie" - OS X compatibility work - "Matthew Palmer", // "Usurper" - testing and eduke32.com domain - "Matt Saettler", // original DOS EDuke/WW2GI enhancements - "NY00123", // Linux / SDL usability patches - "Ozkan Sezer", // SDL/GTK version checking improvements - "Peter Green", // "Plugwash" - dynamic remapping, custom gametypes - "Peter Veenstra", // "Qbix" - port to 64-bit - "Robin Green", // CON array support - "Ryan Gordon", // "icculus" - icculus.org Duke3D port sound code - "Stephen Anthony", // early 64-bit porting work - "tueidj", // Wii port - }; - EDUKE32_STATIC_ASSERT(ARRAY_SIZE(body) % 3 == 0); - static const char *footer[] = - { - nullptr, - "Visit eduke32.com for news and updates", - }; - - static constexpr int header_numlines = ARRAY_SIZE(header); - static constexpr int body_numlines = ARRAY_SIZE(body); - static constexpr int footer_numlines = ARRAY_SIZE(footer); - - static constexpr int CCOLUMNS = 3; - static constexpr int CCOLXBUF = 20; - - int c; - i = 0; - for (c = 0; c < header_numlines; c++) - if (header[c]) - creditsminitext(origin.x + (160<<16), origin.y + ((17+10+10+8+4+(c*7)-l)<<16), header[c], 8); - i += c; - for (c = 0; c < body_numlines; c++) - if (body[c]) - creditsminitext(origin.x + ((CCOLXBUF+((320-CCOLXBUF*2)/(CCOLUMNS*2)) +((320-CCOLXBUF*2)/CCOLUMNS)*(c/(body_numlines/CCOLUMNS)))<<16), origin.y + ((17+10+10+8+4+((c%(body_numlines/CCOLUMNS))*7)+(i*7)-l)<<16), body[c], 8); - i += c/CCOLUMNS; - for (c = 0; c < footer_numlines; c++) - if (footer[c]) - creditsminitext(origin.x + (160<<16), origin.y + ((17+10+10+8+4+(c*7)+(i*7)-l)<<16), footer[c], 8); - } - - break; - - default: - break; - } -} - - -/* -Functions where a "newValue" or similar is passed are run *before* the linked variable is actually changed. -That way you can compare the new and old values and potentially block the change. -*/ -static void Menu_EntryLinkActivate(MenuEntry_t *entry) -{ - else if (entry == &ME_NETHOST_LAUNCH) - { - // master does whatever it wants - if (g_netServer) - { - Net_FillNewGame(&pendingnewgame, 1); - Net_StartNewGame(); - Net_SendNewGame(1, NULL); - } - else if (voting == -1) - { - Net_SendMapVoteInitiate(); - Menu_Change(MENU_NETWAITVOTES); - } - } -} - - - - - -#endif - -END_DUKE_NS diff --git a/source/duke3d/src/menus.h b/source/duke3d/src/menus.h index fe29b6b3b..4d33c01c4 100644 --- a/source/duke3d/src/menus.h +++ b/source/duke3d/src/menus.h @@ -57,91 +57,6 @@ inline int G_CheckPlayerColor(int color) } -#if 0 - -enum MenuIndex_t { - MENU_NULL = INT32_MIN, // sentinel for "do nothing" - MENU_CLOSE = -2, // sentinel for "close the menu"/"no menu" - MENU_PREVIOUS = -1, // sentinel for "go to previous menu" - MENU_MAIN = 0, // done - MENU_MAIN_INGAME = 50, // done - MENU_EPISODE = 100, // done - MENU_USERMAP = 101, - MENU_NEWGAMECUSTOM = 102, // done - MENU_NEWGAMECUSTOMSUB = 103,// done - MENU_SKILL = 110, // done - MENU_OPTIONS = 202, - MENU_GAMESETUP = 200, - MENU_CHEATS = 800, // IF script hacked - MENU_CHEATENTRY = 801, // IF script hacked - MENU_CHEAT_WARP = 802, - MENU_CHEAT_SKILL = 803, - MENU_DISPLAYSETUP = 234, - MENU_SCREENSETUP = 233, // HUD - MENU_COLCORR = 231, // color correction - MENU_COLCORR_INGAME = 232, // almost the same for ingame - not needed - MENU_VIDEOSETUP = 203, - MENU_POLYMOST = 230, - MENU_POLYMER = 240, // Who needs a renderer that's folding performance-wise with a single light? - MENU_SOUND = 700, - MENU_SOUND_INGAME = 701, // Just the same with different exit logic. - MENU_ADVSOUND = 702, // Only needed for space reasons. Fold into main sound menu. - MENU_PLAYER = 20002, - MENU_MACROS = 20004, - MENU_CONTROLS = 220, - MENU_KEYBOARDSETUP = 204, - MENU_KEYBOARDKEYS = 209, - MENU_MOUSESETUP = 205, - MENU_MOUSEBTNS = 210, // folded with keyboard - MENU_MOUSEADVANCED = 212, - MENU_JOYSTICKSETUP = 206, - MENU_JOYSTICKBTNS = 207, - MENU_JOYSTICKAXES = 208, - MENU_JOYSTICKAXIS = 213, - MENU_LOAD = 300, - MENU_SAVE = 350, - MENU_STORY = 400, - MENU_F1HELP = 401, - MENU_CREDITS = 990, - MENU_CREDITS2 = 991, - MENU_CREDITS3 = 992, - MENU_CREDITS4 = 993, - MENU_CREDITS5 = 994, - MENU_QUIT = 500, - MENU_QUITTOTITLE = 501, - MENU_QUIT_INGAME = 502, - - MENU_SAVESETUP = 750, - - MENU_SAVECLEANVERIFY = 751, - MENU_LOADVERIFY = 1000, - MENU_LOADDELVERIFY = 1100, - MENU_NEWVERIFY = 1500, - MENU_SAVEVERIFY = 2000, - MENU_SAVEDELVERIFY = 2100, - MENU_COLCORRRESETVERIFY = 2200, - MENU_KEYSRESETVERIFY = 2201, - MENU_KEYSCLASSICVERIFY = 2202, - MENU_JOYSTANDARDVERIFY = 2203, - MENU_JOYPROVERIFY = 2204, - MENU_JOYCLEARVERIFY = 2205, - MENU_ADULTPASSWORD = 10001, - MENU_RESETPLAYER = 15000, - MENU_BUYDUKE = 20000, - - MENU_NETSETUP = 600, - MENU_NETWAITMASTER = 601, - MENU_NETWAITVOTES = 603, - MENU_NETWORK = 20001, - MENU_NETHOST = 20010, - MENU_NETOPTIONS = 20011, - MENU_NETUSERMAP = 20012, - MENU_NETJOIN = 20020, -}; - - -#endif - END_DUKE_NS #endif diff --git a/source/rr/CMakeLists.txt b/source/rr/CMakeLists.txt index 70c07e866..b523eea20 100644 --- a/source/rr/CMakeLists.txt +++ b/source/rr/CMakeLists.txt @@ -62,7 +62,6 @@ set( PCH_SOURCES src/gamedef.cpp src/gameexec.cpp src/global.cpp - src/menus.cpp src/namesdyn.cpp src/net.cpp src/osdcmds.cpp diff --git a/source/rr/src/menus.cpp b/source/rr/src/menus.cpp deleted file mode 100644 index 502cb4895..000000000 --- a/source/rr/src/menus.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2016 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- -#include "ns.h" // Must come before everything else! - -#include "compat.h" -#include "duke3d.h" -#include "osdcmds.h" -#include "savegame.h" -#include "demo.h" - -#include "menus.h" -#include "cheats.h" -#include "gamecvars.h" -#include "menu/menu.h" -#include "version.h" -#include "../../glbackend/glbackend.h" - -BEGIN_RR_NS - -#if 0 - - - case MENU_CREDITS31: - l = 7; - - mgametextcenter(origin.x, origin.y + ((55-l)<<16), "Developer"); - creditsminitext(origin.x + (160<<16), origin.y + ((60+10-l)<<16), "Alexey \"Nuke.YKT\" Skrybykin", 8); - - mgametextcenter(origin.x, origin.y + ((85-l)<<16), "Tester & support"); - creditsminitext(origin.x + (160<<16), origin.y + ((90+10-l)<<16), "Sergey \"Maxi Clouds\" Skrybykin", 8); - - mgametextcenter(origin.x, origin.y + ((115-l)<<16), "Special thanks to"); - creditsminitext(origin.x + (160<<16), origin.y + ((120+10-l)<<16), "Evan \"Hendricks266\" Ramos", 8); - creditsminitext(origin.x + (160<<16), origin.y + ((120+20-l)<<16), "Richard \"TerminX\" Gobeille", 8); - creditsminitext(origin.x + (160<<16), origin.y + ((120+30-l)<<16), "\"NY00123\"", 8); - creditsminitext(origin.x + (160<<16), origin.y + ((120+40-l)<<16), "\"MetHy\"", 8); - - break; - - -#endif - -END_RR_NS diff --git a/source/rr/src/menus.h b/source/rr/src/menus.h index dc2023d67..c0361757d 100644 --- a/source/rr/src/menus.h +++ b/source/rr/src/menus.h @@ -56,468 +56,6 @@ inline int G_CheckPlayerColor(int color) } -#if 0 - - -enum MenuIndex_t { - MENU_NULL = INT32_MIN, // sentinel for "do nothing" - MENU_CLOSE = -2, // sentinel for "close the menu"/"no menu" - MENU_PREVIOUS = -1, // sentinel for "go to previous menu" - MENU_MAIN = 0, - MENU_MAIN_INGAME = 50, - MENU_EPISODE = 100, - MENU_USERMAP = 101, - MENU_SKILL = 110, - MENU_GAMESETUP = 200, - MENU_OPTIONS = 202, - MENU_VIDEOSETUP = 203, - MENU_KEYBOARDSETUP = 204, - MENU_MOUSESETUP = 205, - MENU_JOYSTICKSETUP = 206, - MENU_JOYSTICKBTNS = 207, - MENU_JOYSTICKAXES = 208, - MENU_KEYBOARDKEYS = 209, - MENU_MOUSEBTNS = 210, - MENU_MOUSEADVANCED = 212, - MENU_JOYSTICKAXIS = 213, - MENU_TOUCHSETUP = 214, - MENU_TOUCHSENS = 215, - MENU_TOUCHBUTTONS = 216, - MENU_CONTROLS = 220, - MENU_POLYMOST = 230, - MENU_COLCORR = 231, - MENU_COLCORR_INGAME = 232, - MENU_SCREENSETUP = 233, - MENU_DISPLAYSETUP = 234, - MENU_POLYMER = 240, - MENU_LOAD = 300, - MENU_SAVE = 350, - MENU_STORY = 400, - MENU_F1HELP = 401, - MENU_F1HELP2 = 402, - MENU_QUIT = 500, - MENU_QUITTOTITLE = 501, - MENU_QUIT_INGAME = 502, - MENU_NETSETUP = 600, - MENU_NETWAITMASTER = 601, - MENU_NETWAITVOTES = 603, - MENU_SOUND = 700, - MENU_SOUND_INGAME = 701, - MENU_ADVSOUND = 702, - MENU_CDPLAYER = 703, - MENU_SAVESETUP = 750, - MENU_SAVECLEANVERIFY = 751, - MENU_CHEATS = 800, - MENU_CHEATENTRY = 801, - MENU_CHEAT_WARP = 802, - MENU_CHEAT_SKILL = 803, - MENU_CREDITS = 960, - MENU_CREDITS2 = 961, - MENU_CREDITS3 = 962, - MENU_CREDITS4 = 963, - MENU_CREDITS5 = 964, - MENU_CREDITS6 = 965, - MENU_CREDITS7 = 966, - MENU_CREDITS8 = 967, - MENU_CREDITS9 = 968, - MENU_CREDITS10 = 969, - MENU_CREDITS11 = 970, - MENU_CREDITS12 = 971, - MENU_CREDITS13 = 972, - MENU_CREDITS14 = 973, - MENU_CREDITS15 = 974, - MENU_CREDITS16 = 975, - MENU_CREDITS17 = 976, - MENU_CREDITS18 = 977, - MENU_CREDITS19 = 978, - MENU_CREDITS20 = 979, - MENU_CREDITS21 = 980, - MENU_CREDITS22 = 981, - MENU_CREDITS23 = 982, - MENU_CREDITS24 = 983, - MENU_CREDITS25 = 984, - MENU_CREDITS26 = 985, - MENU_CREDITS27 = 986, - MENU_CREDITS28 = 987, - MENU_CREDITS29 = 988, - MENU_CREDITS30 = 989, - MENU_CREDITS31 = 990, - MENU_CREDITS32 = 991, - MENU_CREDITS33 = 992, - MENU_LOADVERIFY = 1000, - MENU_LOADDELVERIFY = 1100, - MENU_NEWVERIFY = 1500, - MENU_SAVEVERIFY = 2000, - MENU_SAVEDELVERIFY = 2100, - MENU_ADULTPASSWORD = 10001, - MENU_RESETPLAYER = 15000, - MENU_BUYDUKE = 20000, - MENU_NETWORK = 20001, - MENU_PLAYER = 20002, - MENU_MACROS = 20004, - MENU_NETHOST = 20010, - MENU_NETOPTIONS = 20011, - MENU_NETUSERMAP = 20012, - MENU_NETJOIN = 20020, -}; - - - -typedef int32_t MenuID_t; - - -typedef enum MenuAnimationType_t -{ // Note: This enum is for logical categories, not visual types. - MA_None, - MA_Return, - MA_Advance, -} MenuAnimationType_t; - - -typedef enum MenuEntryType_t -{ - Dummy, - Link, - Option, - Custom2Col, - RangeInt32, - RangeFloat, -#ifdef MENU_ENABLE_RANGEDOUBLE - RangeDouble, -#endif - String, - Spacer, -} MenuEntryType_t; - -typedef struct MenuEntryFormat_t -{ - int32_t marginBottom; - int32_t indent; - int32_t width; // 0: center, >0: width of the label column (left-aligned options), <0: -width of everything (right-aligned) -} MenuEntryFormat_t; - - -typedef struct MenuMenuFormat_t -{ - vec2_t pos; - int32_t bottomcutoff; // >0: the bottom edge of the menu before automatic scrolling kicks in, <0: -total height for vertical justification -} MenuMenuFormat_t; - -typedef struct MenuLink_t -{ - // traits - MenuID_t linkID; - MenuAnimationType_t animation; -} MenuLink_t; -typedef struct MenuOptionSet_t -{ - // traits - char const **optionNames; - int32_t *optionValues; // If NULL, the identity of currentOption is assumed. - - // pop-up list appearance - MenuMenuFormat_t *menuFormat; - MenuEntryFormat_t *entryFormat; - MenuFont_t *font; - - // traits - int32_t numOptions; - - // pop-up list state - int32_t currentEntry; - int32_t scrollPos; - - // appearance - uint8_t features; // bit 1 = disable left/right arrows, bit 2 = disable list - - int32_t getMarginBottom() const { return mulscale16(entryFormat->marginBottom, font->zoom); } - int32_t getIndent() const { return mulscale16(entryFormat->indent, font->zoom); } -} MenuOptionSet_t; -typedef struct MenuOption_t -{ - // appearance - MenuFont_t *font; - - // traits - MenuOptionSet_t *options; // so that common sets such as Yes/No, On/Off can be reused - - // effect - FBaseCVar *cVar; - - // state - int32_t currentOption; -} MenuOption_t; -typedef struct MenuCustom2Col_t -{ - // effect - uint8_t *column[2]; - char const **key; - - // appearance - MenuFont_t *font; - - // effect - size_t numvalid; - - // appearance - int32_t columnWidth; - - // state - int8_t screenOpen; -} MenuCustom2Col_t; - -enum MenuRangeFlags_t -{ - DisplayTypeInteger = 1, - DisplayTypePercent = 2, - DisplayTypeNormalizedDecimal = 3, - DisplayTypeMask = (1<<0)|(1<<1), - - EnforceIntervals = 1<<7, -}; -typedef struct MenuRangeInt32_t -{ - // effect - FIntCVar *cVar; - - // appearance - MenuFont_t *font; - - // traits - int32_t min; - int32_t max; - int32_t onehundredpercent; // 0 implies max - int32_t steps; - - uint8_t flags; -} MenuRangeInt32_t; -typedef struct MenuRangeFloat_t -{ - // effect - FFloatCVar *cVar; - - // appearance - MenuFont_t *font; - - // traits - float min; - float max; - float onehundredpercent; // 0 implies 1.0 - int32_t steps; - - uint8_t flags; -} MenuRangeFloat_t; -#ifdef MENU_ENABLE_RANGEDOUBLE -typedef struct MenuRangeDouble_t -{ - // effect - double *variable; - - // appearance - MenuFont_t *font; - - // traits - double min; - double max; - double onehundredpercent; // 0 implies 1.0 - int32_t steps; - - uint8_t flags; -} MenuRangeDouble_t; -#endif -typedef struct MenuString_t -{ - // state - char* editfield; - - // effect - char* variable; - - // appearance - MenuFont_t *font; - - // effect - int32_t bufsize; - int32_t flags; -} MenuString_t; -typedef struct MenuSpacer_t -{ - int32_t height; -} MenuSpacer_t; - -// For internal use only. -enum MenuEntryFlags_t -{ - MEF_Disabled = 1<<0, - MEF_LookDisabled = 1<<1, - MEF_Hidden = 1<<2, -}; - -typedef struct MenuEntry_t -{ - // traits - const char *name; - - // appearance - MenuFont_t *font; - MenuEntryFormat_t *format; - - void *entry; - MenuEntryType_t type; - - // state - int32_t flags; - int32_t ytop, ybottom; - - int32_t getMarginBottom() const { return mulscale16(format->marginBottom, font->zoom); } - int32_t getIndent() const { return mulscale16(format->indent, font->zoom); } - int32_t getHeight() const - { - return type == Spacer ? mulscale16(((MenuSpacer_t *)entry)->height, font->zoom) : font->get_yline(); - } -} MenuEntry_t; - - -typedef enum MenuType_t -{ - Menu, - Panel, - Verify, - Message, - TextForm, - FileSelect, - CdPlayer, -} MenuType_t; - -typedef struct MenuMenu_t -{ - const char *title; - - MenuMenuFormat_t *format; - - MenuEntry_t **entrylist; - int32_t numEntries; - - // state - int32_t currentEntry, currentColumn; - int32_t scrollPos; -} MenuMenu_t; -typedef struct MenuPanel_t -{ - const char *title; - - MenuID_t previousID; - MenuAnimationType_t previousAnimation; - MenuID_t nextID; - MenuAnimationType_t nextAnimation; -} MenuPanel_t; -typedef struct MenuVerify_t -{ - vec2_t cursorpos; - - MenuID_t linkID; - MenuAnimationType_t animation; -} MenuVerify_t; -typedef struct MenuMessage_t -{ - vec2_t cursorpos; - - MenuID_t linkID; - MenuAnimationType_t animation; -} MenuMessage_t; -enum MenuTextFormFlags_t -{ - MTF_Password = 1<<0, -}; -typedef struct MenuTextForm_t -{ - // state - char *input; - - // traits - const char *instructions; - int32_t bufsize; - uint8_t flags; -} MenuTextForm_t; -typedef struct MenuFileSelect_t -{ - const char *title; - - // appearance - MenuMenuFormat_t *format[2]; - MenuFont_t *font[2]; - - // traits - const char *pattern; - char *destination; - - // state - //CACHE1D_FIND_REC *findhigh[2]; - int32_t scrollPos[2]; - - // appearance - int32_t marginBottom[2]; - - // state - //fnlist_t fnlist; - int32_t currentList; - - int32_t getMarginBottom(size_t index) const { return mulscale16(marginBottom[index], font[index]->zoom); } -} MenuFileSelect_t; - -typedef struct Menu_t -{ - void *object; - MenuID_t menuID; - MenuID_t parentID; - MenuAnimationType_t parentAnimation; - MenuType_t type; -} Menu_t; - -typedef struct MenuAnimation_t -{ - int32_t(*out)(struct MenuAnimation_t *); - int32_t(*in)(struct MenuAnimation_t *); - - Menu_t *previous; - Menu_t *current; - - int32_t start; - int32_t length; -} MenuAnimation_t; - -extern MenuAnimation_t m_animation; - -extern MenuID_t g_currentMenu; -extern Menu_t *m_currentMenu; - -extern int32_t g_quitDeadline; -extern int32_t voting; -int Menu_Change(MenuID_t cm); -void Menu_AnimateChange(int32_t cm, MenuAnimationType_t animtype); -int32_t Menu_IsTextInput(Menu_t *cm); -void Menu_Init(void); -void Menu_Open(uint8_t playerID); -void Menu_Close(uint8_t playerID); -void M_DisplayMenus(void); - -extern MenuFont_t MF_Redfont, MF_Bluefont, MF_Minifont; - -#define M_MOUSETIMEOUT 210 -extern int32_t m_mouselastactivity; - -extern int32_t m_mousewake_watchpoint, m_menuchange_watchpoint; -// alpha increments of 3 --> 255 / 3 = 85 --> round up to power of 2 --> 128 --> divide by 2 --> 64 alphatabs required -// use 16 anyway :P -# define MOUSEUSEALPHA (videoGetRenderMode() != REND_CLASSIC || numalphatabs >= 15) -# define MOUSEALPHA (MOUSEUSEALPHA ? clamp(((int32_t) totalclock - m_mouselastactivity - 90)*3, 0, 255) : 0) -# define CURSORALPHA (MOUSEUSEALPHA ? clamp(((int32_t) totalclock - m_mouselastactivity - 90)*2 + (255/3), (255/3), 255) : 255/3) -# define MOUSEACTIVECONDITION ((int32_t) totalclock - m_mouselastactivity < M_MOUSETIMEOUT) -# define MOUSEACTIVECONDITIONAL(condition) (MOUSEACTIVECONDITION && (condition)) -# define MOUSEINACTIVECONDITIONAL(condition) (!MOUSEACTIVECONDITION && (condition)) -# define MOUSEWATCHPOINTCONDITIONAL(condition) ((condition) || m_mousewake_watchpoint || m_menuchange_watchpoint == 3) - -#endif END_RR_NS diff --git a/wadsrc/static/engine/menudef.txt b/wadsrc/static/engine/menudef.txt index 55901caea..e8b87b9c1 100644 --- a/wadsrc/static/engine/menudef.txt +++ b/wadsrc/static/engine/menudef.txt @@ -656,9 +656,10 @@ OptionMenu "OptionsMenu" Submenu "$OPTMNU_GAMEPLAY", "GameplayOptions" Submenu "$OPTMNU_MISCELLANEOUS", "MiscOptions" StaticText " " + Submenu "$MNU_ENGINECREDITS", "EngineCredits" SafeCommand "$OPTMNU_DEFAULTS", "reset2defaults" SafeCommand "$OPTMNU_RESETTOSAVED", "reset2saved" - Command "$OPTMNU_CONSOLE", "menuconsole" + //Command "$OPTMNU_CONSOLE", "menuconsole" } //------------------------------------------------------------------------------------------- @@ -1726,3 +1727,46 @@ OptionMenu "MultiOptionsMenu" Option "$NETMNU_FFIRE", "m_ffire", "OnOff" SafeCommand "$NETMNU_ACCEPT", "MultiAccept" } + +OptionMenu "EngineCredits" +{ + title "$MNU_CREDITS" + Submenu " ---->", "EngineCredits2" + StaticText "Developer" + StaticText "Christoph Oelckers", 0 + StaticText " " + StaticText "Special thanks to" + StaticText "Rachael Alexanderson", 0 + StaticText "Magnus Norddahl", 0 + StaticText "Nigel Rowand", 0 + StaticText "Martin Howe", 0 + StaticText "Nash Muhandes", 0 + StaticText " " + +} + +OptionMenu "EngineCredits2" +{ + title "$MNU_CREDITS" + Submenu " <----", "EngineCredits" + StaticText "EDuke32 / VoidSW" + StaticText "Richard \"TerminX\" Gobeille", 0 + StaticText "Evan \"Hendricks266\" Ramos", 0 + StaticText "Alex \"pogokeen\" Dawson", 0 + StaticText "" + StaticText "Retired developers" + StaticText "Pierre-Loup \"Plagman\" Griffais", 0 + StaticText "Philipp \"Helixhorned\" Kutin", 0 + StaticText "" + StaticText "RedNukem / NBlood" + StaticText "Alexey \"Nuke.YKT\" Skrybykin", 0 + StaticText "" + StaticText "PCExhumed" + StaticText "Alexey \"Nuke.YKT\" Skrybykin", 0 + StaticText "sirlemonhead", 0 + StaticText "" + StaticText "Special thanks to" + StaticText "Jonathon \"JonoF\" Fowler", 0 +} + + \ No newline at end of file From 298bbb4c9786ea6b18c5833be59677d12b45cf27 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Jan 2020 20:52:36 +0100 Subject: [PATCH 31/51] - removed some leftover pieces of the original savepic code in RR. --- source/duke3d/src/savegame.cpp | 1 - source/rr/src/savegame.cpp | 4 ---- 2 files changed, 5 deletions(-) diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp index af50e2543..ec2937e02 100644 --- a/source/duke3d/src/savegame.cpp +++ b/source/duke3d/src/savegame.cpp @@ -615,7 +615,6 @@ bool GameInterface::SaveGame(FSaveGameNode* sv) else { videoNextPage(); // no idea if this is needed here. - return G_SavePlayer(sv); } } diff --git a/source/rr/src/savegame.cpp b/source/rr/src/savegame.cpp index 58cfb724e..c1c63fe6e 100644 --- a/source/rr/src/savegame.cpp +++ b/source/rr/src/savegame.cpp @@ -364,10 +364,6 @@ bool GameInterface::SaveGame(FSaveGameNode* sv) { videoNextPage(); // no idea if this is needed here. - g_screenCapture = 1; - G_DrawRooms(myconnectindex, 65536); - g_screenCapture = 0; - return G_SavePlayer(sv); } } From c21c7a0670e3043df3df481130e0a21e0935e582 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 17 Jan 2020 08:12:57 -0500 Subject: [PATCH 32/51] - fix scaling menu options --- wadsrc/static/engine/menudef.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wadsrc/static/engine/menudef.txt b/wadsrc/static/engine/menudef.txt index e8b87b9c1..e782c9b42 100644 --- a/wadsrc/static/engine/menudef.txt +++ b/wadsrc/static/engine/menudef.txt @@ -1491,8 +1491,8 @@ OptionValue Ratios } OptionValue ScaleModes { - 0, "$OPTVAL_SCALENEAREST" - 1, "$OPTVAL_SCALELINEAR" + 0, "$OPTVAL_SCALENORMAL" + 1, "$OPTVAL_SCALEMINIMAL" 2, "640x400" 3, "960x600" 4, "1280x800" @@ -1550,7 +1550,7 @@ OptionMenu VideoModeMenu //protected StaticText "$VIDMNU_CUSTOMRES" TextField "$VIDMNU_CUSTOMX", menu_resolution_custom_width TextField "$VIDMNU_CUSTOMY", menu_resolution_custom_height - Option "$VIDMNU_USELINEAR", "vid_scale_customlinear", "YesNo" + Option "$VIDMNU_USELINEAR", "vid_scale_linear", "YesNo" StaticText "" Command "$VIDMNU_APPLYW", "menu_resolution_commit_changes 0" Command "$VIDMNU_APPLYFS", "menu_resolution_commit_changes 1" From 1a916c0a760a1f2371909156afe8e2ebbf70f566 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 18 Jan 2020 12:34:27 +0100 Subject: [PATCH 33/51] - use the vertex buffer to render the post processed screen image. --- .../rendering/gl/renderer/gl_postprocess.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/source/common/rendering/gl/renderer/gl_postprocess.cpp b/source/common/rendering/gl/renderer/gl_postprocess.cpp index 49c8ad4ec..8f2f024e7 100644 --- a/source/common/rendering/gl/renderer/gl_postprocess.cpp +++ b/source/common/rendering/gl/renderer/gl_postprocess.cpp @@ -32,8 +32,9 @@ #include "gl/shaders/gl_shaderprogram.h" #include "hwrenderer/postprocessing/hw_postprocess.h" #include "hwrenderer/postprocessing/hw_postprocess_cvars.h" -//#include "hwrenderer/data/flatvertices.h" +#include "hwrenderer/data/flatvertices.h" #include "r_videoscale.h" +#include "v_video.h" extern bool vid_hdr_active; @@ -45,23 +46,9 @@ namespace OpenGLRenderer void FGLRenderer::RenderScreenQuad() { - // The buffer here needs to be enabled later again, of course. -#if 0 auto buffer = static_cast(screen->mVertexData->GetBufferObjects().first); buffer->Bind(nullptr); glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); -#else - glBegin(GL_TRIANGLE_STRIP); - glVertexAttrib2f(1, 0, 0); - glVertexAttrib2f(0, -1, -1); - glVertexAttrib2f(1, 0, 1); - glVertexAttrib2f(0, -1, 1); - glVertexAttrib2f(1, 1, 0); - glVertexAttrib2f(0, 1, -1); - glVertexAttrib2f(1, 1, 1); - glVertexAttrib2f(0, 1,1); - glEnd(); -#endif } void FGLRenderer::PostProcessScene(int fixedcm, const std::function &afterBloomDrawEndScene2D) From 2e06ccfec62efd142fad9de5730ac04d9bf15d26 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 18 Jan 2020 13:23:01 +0100 Subject: [PATCH 34/51] - draw the screen overlays using the vertex buffer. --- source/build/src/animvpx.cpp | 2 +- source/build/src/glsurface.cpp | 2 +- source/build/src/mdsprite.cpp | 2 +- source/build/src/polymost.cpp | 2 +- source/build/src/voxmodel.cpp | 4 +-- source/glbackend/glbackend.cpp | 56 ++++++++++++++++++++++++++-------- source/glbackend/glbackend.h | 10 ++---- source/glbackend/hw_draw2d.cpp | 24 ++++----------- 8 files changed, 58 insertions(+), 44 deletions(-) diff --git a/source/build/src/animvpx.cpp b/source/build/src/animvpx.cpp index 353437093..bce748dde 100644 --- a/source/build/src/animvpx.cpp +++ b/source/build/src/animvpx.cpp @@ -437,7 +437,7 @@ int32_t animvpx_render_frame(animvpx_codec_ctx *codec, double animvpx_aspect) vt[3].SetTexCoord(1.0,1.0); vt[3].SetVertex(x, -y, 0.0); - GLInterface.Draw(DT_TRIANGLE_FAN, data.first, 4); + GLInterface.DrawIm(DT_TRIANGLE_FAN, data.first, 4); t = timerGetTicks()-t; codec->sumtimes[2] += t; diff --git a/source/build/src/glsurface.cpp b/source/build/src/glsurface.cpp index d396eb7b2..d9be935f4 100644 --- a/source/build/src/glsurface.cpp +++ b/source/build/src/glsurface.cpp @@ -83,5 +83,5 @@ void glsurface_blitBuffer() vt[1].Set(-1.0f, -1.0f, 0.0f, 0.0f, 1.0f); //bottom-left vt[2].Set(1.0f, 1.0f, 0.0f, 1.0f, 0.0f); //top-right vt[3].Set(1.0f, -1.0f, 0.0f, 1.0f, 1.0f); //bottom-right - GLInterface.Draw(DT_TRIANGLE_STRIP, data.first, 4); + GLInterface.DrawIm(DT_TRIANGLE_STRIP, data.first, 4); } diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index b9abbd106..4d123d47d 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -1470,7 +1470,7 @@ static void md3draw_handle_triangles(const md3surf_t *s, uint16_t *indexhandle, vt->SetVertex(vertlist[k].x, vertlist[k].y); } } - GLInterface.Draw(DT_TRIANGLES, data.first, s->numtris *3); + GLInterface.DrawIm(DT_TRIANGLES, data.first, s->numtris *3); #ifndef USE_GLEXT UNREFERENCED_PARAMETER(texunits); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 9b42e38de..da1111e86 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -599,7 +599,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 r * (1.f / 1024.f)); } - GLInterface.Draw(DT_TRIANGLE_FAN, data.first, npoints); + GLInterface.DrawIm(DT_TRIANGLE_FAN, data.first, npoints); GLInterface.SetTinting(0, 0, PalEntry(255, 255, 255)); GLInterface.UseDetailMapping(false); diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index e844a7e40..9862e1396 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -1152,7 +1152,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) f = 1 /*clut[fi++]*/; if (qdone > 0) { - GLInterface.Draw(DT_TRIANGLES, qstart, qdone * 6); + GLInterface.DrawIm(DT_TRIANGLES, qstart, qdone * 6); qstart += qdone * 6; qdone = 0; } @@ -1182,7 +1182,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) qdone++; } - GLInterface.Draw(DT_TRIANGLES, qstart, qdone * 6); + GLInterface.DrawIm(DT_TRIANGLES, qstart, qdone * 6); GLInterface.SetClamp(prevClamp); //------------ GLInterface.SetCull(Cull_None); diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 3a3b91192..728a2e1c9 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -47,6 +47,7 @@ #include "gl_interface.h" #include "v_2ddrawer.h" #include "v_video.h" +#include "flatvertices.h" #include "gl_renderer.h" float shadediv[MAXPALOOKUPS]; @@ -174,6 +175,7 @@ void GLInstance::InitGLState(int fogmode, int multisample) screen->BeginFrame(); bool useSSAO = (gl_ssao != 0); OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(useSSAO); + ClearBufferState(); } void GLInstance::Deinit() @@ -212,6 +214,17 @@ void GLInstance::ResetFrame() } +void GLInstance::ClearBufferState() +{ + auto buffer = (screen->mVertexData->GetBufferObjects().first); + + SetVertexBuffer(buffer, 0, 0); + SetIndexBuffer(nullptr); + // Invalidate the pointers as well to make sure that if another buffer with the same address is used it actually gets bound. + LastVertexBuffer = (IVertexBuffer*)~intptr_t(0); + LastIndexBuffer = (IIndexBuffer*)~intptr_t(0); +} + std::pair GLInstance::AllocVertices(size_t num) { @@ -227,6 +240,36 @@ static GLint primtypes[] = GL_LINES }; +void GLInstance::DrawIm(EDrawType type, size_t start, size_t count) +{ + // Todo: Based on the current tinting flags and the texture type (indexed texture and APPLYOVERPALSWAP not set) this may have to reset the palette for the draw call / texture creation. + bool applied = false; + + if (activeShader == polymostShader) + { + glVertexAttrib4fv(2, renderState.Color); + if (renderState.Color[3] != 1.f) renderState.Flags &= ~RF_Brightmapping; // The way the colormaps are set up means that brightmaps cannot be used on translucent content at all. + renderState.Apply(polymostShader, lastState); + } + glBegin(primtypes[type]); + auto p = &Buffer[start]; + for (size_t i = 0; i < count; i++, p++) + { + glVertexAttrib2f(1, p->u, p->v); + glVertexAttrib3f(0, p->x, p->y, p->z); + } + glEnd(); + + if (MatrixChange) + { + if (MatrixChange & 1) SetIdentityMatrix(Matrix_Texture); + if (MatrixChange & 2) SetIdentityMatrix(Matrix_Detail); + MatrixChange = 0; + } + matrixArray.Resize(1); +} + + void GLInstance::Draw(EDrawType type, size_t start, size_t count) { // Todo: Based on the current tinting flags and the texture type (indexed texture and APPLYOVERPALSWAP not set) this may have to reset the palette for the draw call / texture creation. @@ -258,18 +301,7 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count) LastIndexBuffer = renderState.IndexBuffer; } } - if (!LastVertexBuffer) - { - glBegin(primtypes[type]); - auto p = &Buffer[start]; - for (size_t i = 0; i < count; i++, p++) - { - glVertexAttrib2f(1, p->u, p->v); - glVertexAttrib3f(0, p->x, p->y, p->z); - } - glEnd(); - } - else if (type != DT_LINES) + if (type != DT_LINES && renderState.IndexBuffer) { glDrawElements(primtypes[type], count, GL_UNSIGNED_INT, (void*)(intptr_t)(start * sizeof(uint32_t))); } diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 6446d0a79..1b668e7cd 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -228,6 +228,7 @@ public: GLInstance(); std::pair AllocVertices(size_t num); + void DrawIm(EDrawType type, size_t start, size_t count); void Draw(EDrawType type, size_t start, size_t count); FHardwareTexture* NewTexture(); @@ -246,14 +247,7 @@ public: { renderState.IndexBuffer = vb; } - void ClearBufferState() - { - SetVertexBuffer(nullptr, 0, 0); - SetIndexBuffer(nullptr); - // Invalidate the pointers as well to make sure that if another buffer with the same address is used it actually gets bound. - LastVertexBuffer = (IVertexBuffer*)~intptr_t(0); - LastIndexBuffer = (IIndexBuffer*)~intptr_t(0); - } + void ClearBufferState(); float GetProjectionM5() { return mProjectionM5; } void SetMatrix(int num, const VSMatrix *mat ); diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index e4ec15f20..3ee8b424c 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -40,6 +40,7 @@ #include "glbackend.h" #include "v_draw.h" #include "palette.h" +#include "flatvertices.h" extern int16_t numshades; //=========================================================================== @@ -244,12 +245,7 @@ void fullscreen_tint_gl(PalEntry pe) GLInterface.UseColorOnly(true); - auto data = GLInterface.AllocVertices(3); - auto vt = data.second; - vt[0].Set(-2.5f, 1.f); - vt[1].Set(2.5f, 1.f); - vt[2].Set(.0f, -2.5f); - GLInterface.Draw(DT_TRIANGLES, data.first, 3); + GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); GLInterface.UseColorOnly(false); } @@ -268,20 +264,12 @@ void fullscreen_tint_gl_blood(int tint_blood_r, int tint_blood_g, int tint_blood GLInterface.UseColorOnly(true); GLInterface.SetColorub(max(tint_blood_r, 0), max(tint_blood_g, 0), max(tint_blood_b, 0), 255); - auto data = GLInterface.AllocVertices(3); - auto vt = data.second; - vt[0].Set(-2.5f, 1.f); - vt[1].Set(2.5f, 1.f); - vt[2].Set(.0f, -2.5f); - GLInterface.Draw(DT_TRIANGLES, data.first, 3); + GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); + GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Subtract]); GLInterface.SetColorub(max(-tint_blood_r, 0), max(-tint_blood_g, 0), max(-tint_blood_b, 0), 255); - data = GLInterface.AllocVertices(3); - vt = data.second; - vt[0].Set(-2.5f, 1.f); - vt[1].Set(2.5f, 1.f); - vt[2].Set(.0f, -2.5f); - GLInterface.Draw(DT_TRIANGLES, data.first, 3); + GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); + GLInterface.SetColorub(255, 255, 255, 255); GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]); GLInterface.UseColorOnly(false); From 8cd9775513e5f8478649bb7672c0ed4bb8711bdb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 18 Jan 2020 15:18:04 +0100 Subject: [PATCH 35/51] - fixed VP8 video player. Also do the color space conversion on the CPU to avoid the shader hassle, performance wise it is utterly irrelevant here. --- source/build/src/animvpx.cpp | 125 ++++++++++++------- source/duke3d/src/anim.cpp | 14 +-- source/glbackend/glbackend.cpp | 25 ---- source/glbackend/glbackend.h | 3 - source/glbackend/hw_draw2d.cpp | 3 +- source/rr/src/anim.cpp | 11 +- wadsrc/static/engine/shaders/glsl/animvpx.fp | 29 ----- wadsrc/static/engine/shaders/glsl/animvpx.vp | 13 -- 8 files changed, 90 insertions(+), 133 deletions(-) delete mode 100644 wadsrc/static/engine/shaders/glsl/animvpx.fp delete mode 100644 wadsrc/static/engine/shaders/glsl/animvpx.vp diff --git a/source/build/src/animvpx.cpp b/source/build/src/animvpx.cpp index bce748dde..34ef50004 100644 --- a/source/build/src/animvpx.cpp +++ b/source/build/src/animvpx.cpp @@ -10,6 +10,9 @@ #include "matrix.h" #include "../../glbackend/glbackend.h" +#include "textures.h" +#include "bitmap.h" +#include "v_draw.h" #undef UNUSED #define VPX_CODEC_DISABLE_COMPAT 1 @@ -17,6 +20,74 @@ #include #include "animvpx.h" + +class VPXTexture : public FTexture +{ +public: + VPXTexture(); + void SetFrame(const void* data, int width, int height); + virtual FBitmap GetBgraBitmap(const PalEntry* remap, int* trans) override; + +protected: + + const void* data; + +public: + +}; + +//========================================================================== +// +// +// +//========================================================================== + +VPXTexture::VPXTexture() {} + +void VPXTexture::SetFrame(const void *data_, int width, int height) +{ + Size.x = width; + Size.y = height; + data = data_; + DeleteHardwareTextures(); +} + +//=========================================================================== +// +// FPNGTexture::CopyPixels +// +//=========================================================================== + +FBitmap VPXTexture::GetBgraBitmap(const PalEntry* remap, int* trans) +{ + FBitmap bmp; + + bmp.Create(Size.x, Size.y); + + auto spix = (uint8_t*)data; + auto dpix = bmp.GetPixels(); + for (int i = 0; i < Size.x * Size.y; i++) + { + int p = i * 4; + float y = spix[p] * (1/255.f); + float u = spix[p+1] * (1 / 255.f) - 0.5f; + float v = spix[p+2] * (1 / 255.f) - 0.5f; + + y = 1.1643f * (y - 0.0625f); + + float r = y + 1.5958f * v; + float g = y - 0.39173f * u - 0.81290f * v; + float b = y + 2.017f * u; + + dpix[p + 0] = (uint8_t)(clamp(b, 0, 1.f) * 255); + dpix[p + 1] = (uint8_t)(clamp(g, 0, 1.f) * 255); + dpix[p + 2] = (uint8_t)(clamp(r, 0, 1.f) * 255); + dpix[p + 3] = 255; + } + return bmp; +} + + const char *animvpx_read_ivf_header_errmsg[] = { "All OK", "couldn't read 32-byte IVF header", @@ -339,28 +410,13 @@ read_ivf_frame: /////////////// DRAWING! /////////////// -static FHardwareTexture* texture; static int sampler; -static int32_t texuploaded; +static VPXTexture* vpxtex; void animvpx_setup_glstate(int32_t animvpx_flags) { - static char logbuf[512]; - - GLInterface.SetVPXShader(); - - ////////// GL STATE ////////// - - //Force fullscreen (glox1=-1 forces it to restore afterwards) - GLInterface.SetViewport(0,0,xdim,ydim); glox1 = -1; - - GLInterface.EnableAlphaTest(false); - GLInterface.EnableDepthTest(false); - GLInterface.EnableBlend(false); - GLInterface.SetCull(Cull_None); - - texture = GLInterface.NewTexture(); + vpxtex = new VPXTexture; if ((animvpx_flags & CUTSCENE_TEXTUREFILTER && hw_texfilter == TEXFILTER_ON) || animvpx_flags & CUTSCENE_FORCEFILTER || (!(animvpx_flags & CUTSCENE_TEXTUREFILTER) && !(animvpx_flags & CUTSCENE_FORCENOFILTER))) // if no flags, then use filter for IVFs @@ -372,18 +428,14 @@ void animvpx_setup_glstate(int32_t animvpx_flags) sampler = SamplerNoFilterClampXY; } - texuploaded = 0; - //////////////////// GLInterface.ClearScreen(0, true); } void animvpx_restore_glstate(void) { - GLInterface.SetPolymostShader(); - delete texture; - texture = nullptr; - texuploaded = 0; + delete vpxtex; + vpxtex = nullptr; } int32_t animvpx_render_frame(animvpx_codec_ctx *codec, double animvpx_aspect) @@ -396,13 +448,7 @@ int32_t animvpx_render_frame(animvpx_codec_ctx *codec, double animvpx_aspect) if (codec->pic == NULL) return 2; // shouldn't happen - if (!texuploaded) - { - texture->CreateTexture(codec->width, codec->height, FHardwareTexture::TrueColor, false); - texuploaded = 1; - } - texture->LoadTexture(codec->pic); - GLInterface.BindTexture(0, texture, sampler); + vpxtex->SetFrame(codec->pic, codec->width, codec->height); float vid_wbyh = ((float)codec->width)/codec->height; if (animvpx_aspect > 0) @@ -422,22 +468,9 @@ int32_t animvpx_render_frame(animvpx_codec_ctx *codec, double animvpx_aspect) } #endif - auto data = GLInterface.AllocVertices(4); - auto vt = data.second; - - vt[0].SetTexCoord(0.0,1.0); - vt[0].SetVertex(-x, -y, 0.0); - - vt[1].SetTexCoord(0.0,0.0); - vt[1].SetVertex(-x, y, 0.0); - - vt[2].SetTexCoord(1.0,0.0); - vt[2].SetVertex(x, y, 0.0); - - vt[3].SetTexCoord(1.0,1.0); - vt[3].SetVertex(x, -y, 0.0); - - GLInterface.DrawIm(DT_TRIANGLE_FAN, data.first, 4); + x *= screen->GetWidth() / 2; + y *= screen->GetHeight() / 2; + DrawTexture(twod, vpxtex, screen->GetWidth() / 2 - int(x), screen->GetHeight()/2 - int(y), DTA_DestWidth, 2*int(x), DTA_DestHeight, 2*int(y), DTA_Masked, false, DTA_KeepRatio, true, TAG_DONE); t = timerGetTicks()-t; codec->sumtimes[2] += t; diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index 660fc3ca2..7fa7cee52 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "cmdlib.h" #include "compat.h" #include "build.h" +#include "v_2ddrawer.h" #include "../glbackend/glbackend.h" @@ -303,6 +304,10 @@ int32_t Anim_Play(const char *fn) // OSD_Printf("msecs per frame: %d\n", msecsperframe); GLInterface.EnableNonTransparent255(true); + + // Dummy rotatesprite call. Without this the movie won't render. Apparently some state isn't initialized properly and gets reset by this. + // Needs to be investigated. Leave this in as a workaround for now... + rotatesprite_fs(int(160 * 65536), int(100 * 65536) + ((28) << 16), 65536L, 0, 2499, 0, 0, 10); do { nextframetime += msecsperframe; @@ -325,7 +330,7 @@ int32_t Anim_Play(const char *fn) VM_OnEventWithReturn(EVENT_PRECUTSCENE, g_player[screenpeek].ps->i, screenpeek, framenum); - videoClearScreen(0); + twod->ClearScreen(); ototalclock = totalclock + 1; // pause game like ANMs @@ -376,12 +381,7 @@ int32_t Anim_Play(const char *fn) } } - // this and showframe() instead of nextpage() are so that - // nobody tramples on our carefully set up GL state! - palfadedelta = 0; - videoShowFrame(0); - - // inputState.ClearAllInput(); + videoNextPage(); do { diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 728a2e1c9..91acf88f1 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -92,7 +92,6 @@ void GLInstance::Init(int ydim) new(&renderState) PolymostRenderState; // reset to defaults. LoadSurfaceShader(); - LoadVPXShader(); LoadPolymostShader(); #if 0 IMGUI_CHECKVERSION(); @@ -128,19 +127,6 @@ void GLInstance::LoadPolymostShader() SetPolymostShader(); } -void GLInstance::LoadVPXShader() -{ - auto fr1 = GetResource("engine/shaders/glsl/animvpx.vp"); - TArray Vert = fr1.Read(); - fr1 = GetResource("engine/shaders/glsl/animvpx.fp"); - TArray Frag = fr1.Read(); - // Zero-terminate both strings. - Vert.Push(0); - Frag.Push(0); - vpxShader = new FShader(); - vpxShader->Load("VPXShader", (const char*)Vert.Data(), (const char*)Frag.Data()); -} - void GLInstance::LoadSurfaceShader() { auto fr1 = GetResource("engine/shaders/glsl/glsurface.vp"); @@ -194,8 +180,6 @@ void GLInstance::Deinit() polymostShader = nullptr; if (surfaceShader) delete surfaceShader; surfaceShader = nullptr; - if (vpxShader) delete vpxShader; - vpxShader = nullptr; activeShader = nullptr; palmanager.DeleteAllTextures(); lastPalswapIndex = -1; @@ -349,15 +333,6 @@ void GLInstance::SetSurfaceShader() } } -void GLInstance::SetVPXShader() -{ - if (activeShader != vpxShader) - { - vpxShader->Bind(); - activeShader = vpxShader; - } -} - void GLInstance::SetPalette(int index) { palmanager.BindPalette(index); diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 1b668e7cd..9d869ba0c 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -202,7 +202,6 @@ class GLInstance FShader* activeShader; PolymostShader* polymostShader; SurfaceShader* surfaceShader; - FShader* vpxShader; public: @@ -213,7 +212,6 @@ public: void InitGLState(int fogmode, int multisample); void LoadPolymostShader(); void LoadSurfaceShader(); - void LoadVPXShader(); void Draw2D(F2DDrawer* drawer); void DrawImGui(ImDrawData*); void ResetFrame(); @@ -262,7 +260,6 @@ public: void SetPolymostShader(); void SetSurfaceShader(); - void SetVPXShader(); void SetPalette(int palette); void ReadPixels(int w, int h, uint8_t* buffer); diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index 3ee8b424c..9f2390ab4 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -172,15 +172,14 @@ void GLInstance::Draw2D(F2DDrawer *drawer) SetShade(cmd.mRemapIndex >> 16, numshades); SetFadeDisable(false); SetTexture(0, tex, cmd.mRemapIndex & 0xffff, 4/*DAMETH_CLAMPED*/, cmd.mFlags & F2DDrawer::DTF_Wrap ? SamplerRepeat : SamplerClampXY); - EnableBlend(!(cmd.mRenderStyle.Flags & STYLEF_Alpha1)); } else { SetFadeDisable(true); SetShade(0, numshades); SetNamedTexture(cmd.mTexture, cmd.mRemapIndex, cmd.mFlags & F2DDrawer::DTF_Wrap ? SamplerRepeat : SamplerClampXY); - EnableBlend(true); } + EnableBlend(!(cmd.mRenderStyle.Flags & STYLEF_Alpha1)); UseColorOnly(false); } else diff --git a/source/rr/src/anim.cpp b/source/rr/src/anim.cpp index 0c08ae27a..b01da71be 100644 --- a/source/rr/src/anim.cpp +++ b/source/rr/src/anim.cpp @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "animlib.h" #include "compat.h" #include "cmdlib.h" +#include "v_2ddrawer.h" #include "../glbackend/glbackend.h" @@ -359,7 +360,7 @@ int32_t Anim_Play(const char *fn) if (!pic) break; // no more pics! - videoClearScreen(0); + twod->ClearScreen(); ototalclock = totalclock + 1; // pause game like ANMs @@ -408,13 +409,7 @@ int32_t Anim_Play(const char *fn) } } - // this and showframe() instead of nextpage() are so that - // nobody tramples on our carefully set up GL state! - palfadedelta = 0; - videoShowFrame(0); - - // inputState.ClearAllInput(); - + videoNextPage(); do { G_HandleAsync(); diff --git a/wadsrc/static/engine/shaders/glsl/animvpx.fp b/wadsrc/static/engine/shaders/glsl/animvpx.fp deleted file mode 100644 index 5bc67fb8b..000000000 --- a/wadsrc/static/engine/shaders/glsl/animvpx.fp +++ /dev/null @@ -1,29 +0,0 @@ -// YUV->RGB conversion fragment shader adapted from -// http://www.fourcc.org/fccyvrgb.php: Want some sample code? -// direct link: http://www.fourcc.org/source/YUV420P-OpenGL-GLSLang.c -#version 330 - -uniform sampler2D tex; -in vec2 v_texCoord; -out vec4 FragColor; - -void main(void) { - - float r,g,b,y,u,v; - vec3 yuv; - - yuv = texture2D(tex, v_texCoord.st).rgb; - y = yuv.r; - u = yuv.g; - v = yuv.b; - - y = 1.1643*(y-0.0625); - u = u-0.5; - v = v-0.5; - - r = y + 1.5958*v; - g = y - 0.39173*u - 0.81290*v; - b = y + 2.017*u; - - FragColor = vec4(r,g,b,1.0); -}; diff --git a/wadsrc/static/engine/shaders/glsl/animvpx.vp b/wadsrc/static/engine/shaders/glsl/animvpx.vp deleted file mode 100644 index 19db847f1..000000000 --- a/wadsrc/static/engine/shaders/glsl/animvpx.vp +++ /dev/null @@ -1,13 +0,0 @@ -#version 330 - -in vec4 i_vertPos; -in vec4 i_texCoord; - -out vec2 v_texCoord; - -void main() -{ - gl_Position = i_vertPos; - v_texCoord = i_texCoord.st; -} - From 2bc170887027384d4ff1efc6259dd5e9f70dca36 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 18 Jan 2020 16:13:39 +0100 Subject: [PATCH 36/51] - removed the complete crosshair color hackery. The code needs to be refactored anyway to allow better crosshair control but this also seemed to affect global render state, considering how poorly it was all implemented. --- source/blood/src/blood.cpp | 1 - source/blood/src/osdcmd.cpp | 31 ----------- source/blood/src/view.cpp | 52 +------------------ source/blood/src/view.h | 5 -- source/build/src/mdsprite.cpp | 4 +- source/build/src/polymost.cpp | 4 +- source/build/src/voxmodel.cpp | 4 +- source/common/2d/v_draw.cpp | 4 +- source/duke3d/src/anim.cpp | 3 -- source/duke3d/src/game.cpp | 6 --- source/duke3d/src/game.h | 7 --- source/duke3d/src/osdcmds.cpp | 23 --------- source/duke3d/src/premap.cpp | 3 -- source/duke3d/src/premap.h | 2 - source/duke3d/src/screens.cpp | 86 +------------------------------ source/exhumed/src/osdcmds.cpp | 1 - source/glbackend/gl_renderstate.h | 2 +- source/rr/src/game.cpp | 6 --- source/rr/src/game.h | 7 --- source/rr/src/osdcmds.cpp | 21 -------- source/rr/src/premap.cpp | 3 -- source/rr/src/premap.h | 2 - source/rr/src/screens.cpp | 79 +--------------------------- 23 files changed, 13 insertions(+), 343 deletions(-) diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index acc799692..7cb521331 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -1223,7 +1223,6 @@ RESTART: UpdateNetworkMenus(); if (!gDemo.at0 && gDemo.at59ef > 0 && gGameOptions.nGameType == 0 && !bNoDemo) gDemo.SetupPlayback(NULL); - viewSetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b); gQuitGame = 0; gRestartGame = 0; if (gGameOptions.nGameType > 0) diff --git a/source/blood/src/osdcmd.cpp b/source/blood/src/osdcmd.cpp index 115e5a63f..718902875 100644 --- a/source/blood/src/osdcmd.cpp +++ b/source/blood/src/osdcmd.cpp @@ -102,35 +102,6 @@ static int osdcmd_demo(osdcmdptr_t parm) } -static int osdcmd_crosshaircolor(osdcmdptr_t parm) -{ - if (parm->numparms != 3) - { - OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b); - return OSDCMD_SHOWHELP; - } - - uint8_t const r = Batol(parm->parms[0]); - uint8_t const g = Batol(parm->parms[1]); - uint8_t const b = Batol(parm->parms[2]); - - g_isAlterDefaultCrosshair = true; - viewSetCrosshairColor(r,g,b); - - OSD_Printf("%s\n", parm->raw); - - return OSDCMD_OK; -} - -static int osdcmd_resetcrosshair(osdcmdptr_t UNUSED(parm)) -{ - UNREFERENCED_CONST_PARAMETER(parm); - g_isAlterDefaultCrosshair = false; - viewResetCrosshairToDefault(); - - return OSDCMD_OK; -} - static int osdcmd_give(osdcmdptr_t parm) { if (numplayers != 1 || !gGameStarted || gMe->pXSprite->health == 0) @@ -236,8 +207,6 @@ int32_t registerosdcommands(void) { OSD_RegisterFunction("map","map : loads the given user map", osdcmd_map); OSD_RegisterFunction("demo","demo : starts the given demo", osdcmd_demo); - OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor); - OSD_RegisterFunction("crosshairreset", "crosshairreset: restores the original crosshair", osdcmd_resetcrosshair); OSD_RegisterFunction("give","give : gives requested item", osdcmd_give); OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index a030850ef..2d48d450c 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -1857,7 +1857,6 @@ void viewResizeView(int size) } videoSetViewableArea(gViewX0, gViewY0, gViewX1, gViewY1); gGameMessageMgr.SetCoordinates(gViewX0S + 1, gViewY0S + 1); - viewSetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b); viewUpdatePages(); } @@ -3484,7 +3483,7 @@ void viewDrawScreen(bool sceneonly) { if (cl_crosshair) { - rotatesprite(160<<16, defaultHoriz<<16, 65536, 0, kCrosshairTile, 0, g_isAlterDefaultCrosshair ? CROSSHAIR_PAL : 0, 2, gViewX0, gViewY0, gViewX1, gViewY1); + rotatesprite(160<<16, defaultHoriz<<16, 65536, 0, kCrosshairTile, 0, 0, 2, gViewX0, gViewY0, gViewX1, gViewY1); } cX = (v4c >> 8) + 160; cY = (v48 >> 8) + 220 + (zDelta >> 7); @@ -3689,55 +3688,6 @@ void viewLoadingScreen(int nTile, const char *pText, const char *pText2, const c viewLoadingScreenUpdate(NULL, -1); } -palette_t CrosshairColors = { 255, 255, 255, 0 }; -bool g_isAlterDefaultCrosshair = false; - -void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b) -{ - if (!g_isAlterDefaultCrosshair) - return; - - CrosshairColors.r = r; - CrosshairColors.g = g; - CrosshairColors.b = b; - - auto ptr = TileFiles.tileMakeWritable(kCrosshairTile); - if (!ptr) return; - - int32_t ii = tilesiz[kCrosshairTile].x * tilesiz[kCrosshairTile].y; - - dassert(ii > 0); - - int32_t i = (videoGetRenderMode() == REND_CLASSIC) - ? paletteGetClosestColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b) - : paletteGetClosestColor(255, 255, 255); // use white in GL so we can tint it to the right color - - do - { - if (*ptr != 255) - *ptr = i; - ptr++; - } while (--ii); - - paletteMakeLookupTable(CROSSHAIR_PAL, NULL, CrosshairColors.r, CrosshairColors.g, CrosshairColors.b, 1); - -#ifdef USE_OPENGL - // XXX: this makes us also load all hightile textures tinted with the crosshair color! - polytint_t & crosshairtint = hictinting[CROSSHAIR_PAL]; - crosshairtint.tint.r = CrosshairColors.r; - crosshairtint.tint.g = CrosshairColors.g; - crosshairtint.tint.b = CrosshairColors.b; - crosshairtint.f = HICTINT_USEONART | HICTINT_GRAYSCALE; -#endif - tileInvalidate(kCrosshairTile, -1, -1); -} - -void viewResetCrosshairToDefault(void) -{ - paletteFreeLookupTable(CROSSHAIR_PAL); - tileLoad(kCrosshairTile); -} - #define COLOR_RED redcol #define COLOR_WHITE whitecol diff --git a/source/blood/src/view.h b/source/blood/src/view.h index 804b1d598..342dc1a3f 100644 --- a/source/blood/src/view.h +++ b/source/blood/src/view.h @@ -63,7 +63,6 @@ enum INTERPOLATE_TYPE { INTERPOLATE_TYPE_SHORT, }; -#define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1) #define kCrosshairTile 2319 #define kLoadScreen 2049 #define kLoadScreenCRC -2051908571 @@ -98,8 +97,6 @@ extern CGameMessageMgr gGameMessageMgr; extern int gViewXCenter, gViewYCenter; extern int gViewX0, gViewY0, gViewX1, gViewY1; extern int gViewX0S, gViewY0S, gViewX1S, gViewY1S; -extern palette_t CrosshairColors; -extern bool g_isAlterDefaultCrosshair; extern int gLastPal; @@ -150,8 +147,6 @@ void viewLoadingScreenUpdate(const char *pzText4 = NULL, int nPercent = -1); void viewLoadingScreen(int nTile, const char *pText, const char *pText2, const char *pText3); void viewUpdateDelirium(void); void viewUpdateShake(void); -void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b); -void viewResetCrosshairToDefault(void); void viewSetSystemMessage(const char* pMessage, ...); void viewPrecacheTiles(void); diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index 4d123d47d..c6cd880cb 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -1792,8 +1792,8 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) VSMatrix identity(0); GLInterface.SetIdentityMatrix(Matrix_ModelView); - GLInterface.SetTinting(0, 0, PalEntry(255, 255, 255)); - GLInterface.SetClamp(prevClamp); + GLInterface.SetTinting(-1, 0xffffff, 0xffffff); + GLInterface.SetClamp(prevClamp); globalnoeffect=0; return 1; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index da1111e86..b577934d3 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -601,8 +601,8 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 } GLInterface.DrawIm(DT_TRIANGLE_FAN, data.first, npoints); - GLInterface.SetTinting(0, 0, PalEntry(255, 255, 255)); - GLInterface.UseDetailMapping(false); + GLInterface.SetTinting(-1, 0xffffff, 0xffffff); + GLInterface.UseDetailMapping(false); GLInterface.UseGlowMapping(false); GLInterface.SetNpotEmulation(false, 1.f, 0.f); diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 9862e1396..1e2123e14 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -1194,8 +1194,8 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) VSMatrix identity(0); GLInterface.SetIdentityMatrix(Matrix_ModelView); GLInterface.SetFadeDisable(false); - GLInterface.SetTinting(0, 0, PalEntry(255, 255, 255)); - return 1; + GLInterface.SetTinting(-1, 0xffffff, 0xffffff); + return 1; } #endif diff --git a/source/common/2d/v_draw.cpp b/source/common/2d/v_draw.cpp index 8a0a03da9..a46003805 100644 --- a/source/common/2d/v_draw.cpp +++ b/source/common/2d/v_draw.cpp @@ -655,14 +655,16 @@ bool ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t tag, Va_Li parms->style = STYLE_Stencil; } } - else if (parms->Alpha < 1.f) + else //if (parms->Alpha < 1.f) { parms->style = STYLE_Translucent; } + /* else { parms->style = STYLE_Normal; } + */ } return true; } diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index 7fa7cee52..28c9b1674 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -305,9 +305,6 @@ int32_t Anim_Play(const char *fn) GLInterface.EnableNonTransparent255(true); - // Dummy rotatesprite call. Without this the movie won't render. Apparently some state isn't initialized properly and gets reset by this. - // Needs to be investigated. Leave this in as a workaround for now... - rotatesprite_fs(int(160 * 65536), int(100 * 65536) + ((28) << 16), 65536L, 0, 2499, 0, 0, 10); do { nextframetime += msecsperframe; diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index e3fe74915..81c43fc57 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -5880,12 +5880,6 @@ MAIN_LOOP_RESTART: } - if (g_networkMode != NET_DEDICATED_SERVER) - { - G_GetCrosshairColor(); - G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b); - } - if (ud.warp_on == 1) { G_NewGame_EnterLevel(); diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index 1983cde1d..9735115e4 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -236,11 +236,6 @@ extern int32_t voting; //extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen; -#define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1) - -extern palette_t CrosshairColors; -extern palette_t DefaultCrosshairColors; - int32_t A_CheckInventorySprite(spritetype *s); int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr, uint8_t s_yr, int16_t s_a, int16_t s_ve, int16_t s_zv, int16_t s_ow, int16_t s_ss); @@ -282,12 +277,10 @@ void G_DrawRooms(int32_t playerNum,int32_t smoothratio); void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z); void G_GameExit(const char *msg) ATTRIBUTE((noreturn)); void G_GameQuit(void); -void G_GetCrosshairColor(void); void G_HandleLocalKeys(void); void G_HandleSpecialKeys(void); void G_PrintGameQuotes(int32_t snum); //void G_SE40(int32_t smoothratio); -void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b); void G_Shutdown(void); void G_UpdatePlayerFromMenu(void); void P_DoQuote(int32_t q,DukePlayer_t *p); diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index b4a7e2f69..6f838eaa0 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -370,27 +370,6 @@ static int osdcmd_setactorvar(osdcmdptr_t parm) } - - -static int osdcmd_crosshaircolor(osdcmdptr_t parm) -{ - if (parm->numparms != 3) - { - OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b); - return OSDCMD_SHOWHELP; - } - - uint8_t const r = Batol(parm->parms[0]); - uint8_t const g = Batol(parm->parms[1]); - uint8_t const b = Batol(parm->parms[2]); - - G_SetCrosshairColor(r,g,b); - - OSD_Printf("%s\n", parm->raw); - - return OSDCMD_OK; -} - static int osdcmd_give(osdcmdptr_t parm) { int32_t i; @@ -739,8 +718,6 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("demo","demo : starts the given demo", osdcmd_demo); } - OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor); - OSD_RegisterFunction("give","give : gives requested item", osdcmd_give); OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); OSD_RegisterFunction("activatecheat","activatecheat : activates a cheat code", osdcmd_activatecheat); diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp index 2f40194a7..c7da84b34 100644 --- a/source/duke3d/src/premap.cpp +++ b/source/duke3d/src/premap.cpp @@ -534,9 +534,6 @@ void G_UpdateScreenArea(void) videoSetViewableArea(v1.x, v1.y, v2.x-1, v2.y-1); - G_GetCrosshairColor(); - G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b); - pub = NUMPAGES; pus = NUMPAGES; } diff --git a/source/duke3d/src/premap.h b/source/duke3d/src/premap.h index a0888a05f..5c1292e45 100644 --- a/source/duke3d/src/premap.h +++ b/source/duke3d/src/premap.h @@ -27,7 +27,6 @@ BEGIN_DUKE_NS extern int32_t g_levelTextTime; extern int32_t voting,vote_map,vote_episode; -extern palette_t CrosshairColors; void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName); int G_EnterLevel(int gameMode); int G_FindLevelByFile(const char *fileName); @@ -35,7 +34,6 @@ void G_CacheMapData(void); void G_FreeMapState(int levelNum); void G_NewGame(int volumeNum, int levelNum, int skillNum); void G_ResetTimers(bool saveMoveCnt); -void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b); void G_UpdateScreenArea(void); void P_MoveToRandomSpawnPoint(int playerNum); void P_ResetInventory(int playerNum); diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 5436ed35f..218499502 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -43,8 +43,6 @@ BEGIN_DUKE_NS #define quotepulseshade (sintable[((uint32_t)totalclock<<5)&2047]>>11) -palette_t CrosshairColors = { 255, 255, 255, 0 }; -palette_t DefaultCrosshairColors = { 0, 0, 0, 0 }; int32_t g_crosshairSum = -1; // yxaspect and viewingrange just before the 'main' drawrooms call int32_t dr_yxaspect, dr_viewingrange; @@ -93,86 +91,6 @@ void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set) videoSetPalette(0, palid, set); } -void G_GetCrosshairColor(void) -{ - if (FURY) - return; - - if (DefaultCrosshairColors.f) - return; - - tileLoad(CROSSHAIR); - - auto ptr = tilePtr(CROSSHAIR); - if (!ptr) return; - - // find the brightest color in the original 8-bit tile - int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y; - int32_t bri = 0, j = 0, i; - - Bassert(ii > 0); - - do - { - if (*ptr != 255) - { - i = curpalette[(int32_t) *ptr].r+curpalette[(int32_t) *ptr].g+curpalette[(int32_t) *ptr].b; - if (i > j) { j = i; bri = *ptr; } - } - ptr++; - } while (--ii); - - Bmemcpy(&CrosshairColors, &curpalette[bri], sizeof(palette_t)); - Bmemcpy(&DefaultCrosshairColors, &curpalette[bri], sizeof(palette_t)); - DefaultCrosshairColors.f = 1; // this flag signifies that the color has been detected -} - -void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b) -{ - if (FURY) - return; - - if (g_crosshairSum == r+(g<<8)+(b<<16)) - return; - - auto ptr = TileFiles.tileMakeWritable(CROSSHAIR); - if (!ptr) return; - - if (!DefaultCrosshairColors.f) - G_GetCrosshairColor(); - - g_crosshairSum = r+(g<<8)+(b<<16); - CrosshairColors.r = r; - CrosshairColors.g = g; - CrosshairColors.b = b; - - int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y; - - Bassert(ii > 0); - - int32_t i = (videoGetRenderMode() == REND_CLASSIC) - ? paletteGetClosestColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b) - : paletteGetClosestColor(255, 255, 255); // use white in GL so we can tint it to the right color - - do - { - if (*ptr != 255) - *ptr = i; - ptr++; - } while (--ii); - - paletteMakeLookupTable(CROSSHAIR_PAL, NULL, CrosshairColors.r, CrosshairColors.g, CrosshairColors.b, 1); - -#ifdef USE_OPENGL - // XXX: this makes us also load all hightile textures tinted with the crosshair color! - polytint_t & crosshairtint = hictinting[CROSSHAIR_PAL]; - crosshairtint.tint.r = CrosshairColors.r; - crosshairtint.tint.g = CrosshairColors.g; - crosshairtint.tint.b = CrosshairColors.b; - crosshairtint.f = HICTINT_USEONART | HICTINT_GRAYSCALE; -#endif - tileInvalidate(CROSSHAIR, -1, -1); -} #define SCORESHEETOFFSET -20 static void G_ShowScores(void) @@ -956,7 +874,6 @@ void G_DisplayRest(int32_t smoothratio) if ((unsigned) a < MAXTILES) { vec2_t crosshairpos = { ud.returnvar[0], ud.returnvar[1] }; - uint8_t crosshair_pal = CROSSHAIR_PAL; uint32_t crosshair_o = 1|2; uint32_t crosshair_scale = divscale16(cl_crosshairscale, 100); @@ -966,12 +883,11 @@ void G_DisplayRest(int32_t smoothratio) crosshairpos.x = scale(crosshairpos.x - (320<<15), ydim << 2, xdim * 3) + (320<<15); crosshairpos.y = scale(crosshairpos.y - (200<<15), (ydim << 2) * 6, (xdim * 3) * 5) + (200<<15); crosshair_scale = scale(crosshair_scale, ydim << 2, xdim * 3) >> 1; - crosshair_pal = 0; crosshair_o |= 1024; renderSetAspect(viewingrange, 65536); } - rotatesprite_win(crosshairpos.x, crosshairpos.y, crosshair_scale, 0, a, 0, crosshair_pal, crosshair_o); + rotatesprite_win(crosshairpos.x, crosshairpos.y, crosshair_scale, 0, a, 0, 0, crosshair_o); if (FURY) renderSetAspect(viewingrange, oyxaspect); diff --git a/source/exhumed/src/osdcmds.cpp b/source/exhumed/src/osdcmds.cpp index 2e6598703..06a1f205f 100644 --- a/source/exhumed/src/osdcmds.cpp +++ b/source/exhumed/src/osdcmds.cpp @@ -105,7 +105,6 @@ int32_t registerosdcommands(void) //} //OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu); - //OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor); //OSD_RegisterFunction("give","give : gives requested item", osdcmd_give); diff --git a/source/glbackend/gl_renderstate.h b/source/glbackend/gl_renderstate.h index 997bea5bf..ea912f20f 100644 --- a/source/glbackend/gl_renderstate.h +++ b/source/glbackend/gl_renderstate.h @@ -69,7 +69,7 @@ struct PolymostRenderState bool AlphaTest = true; float Color[4] = { 1,1,1,1 }; short matrixIndex[NUMMATRICES] = { -1,-1,-1,-1,-1 }; - PalEntry fullscreenTint = 0xffffff, hictint = 0, hictint_overlay = 0xffffff; + PalEntry fullscreenTint = 0xffffff, hictint = 0xffffff, hictint_overlay = 0xffffff; int hictint_flags = 0; int StateFlags = STF_COLORMASK|STF_DEPTHMASK; diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index f33952647..8a55cfed3 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -7332,12 +7332,6 @@ MAIN_LOOP_RESTART: for (int & q : user_quote_time) q = 0; - //if (g_networkMode != NET_DEDICATED_SERVER) - { - G_GetCrosshairColor(); - G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b); - } - if (ud.warp_on == 1) { G_NewGame_EnterLevel(); diff --git a/source/rr/src/game.h b/source/rr/src/game.h index 66a364508..1109cf492 100644 --- a/source/rr/src/game.h +++ b/source/rr/src/game.h @@ -235,11 +235,6 @@ extern int32_t voting; //extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen; -#define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1) - -extern palette_t CrosshairColors; -extern palette_t DefaultCrosshairColors; - int32_t A_CheckInventorySprite(spritetype *s); int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr, uint8_t s_yr, int16_t s_a, int16_t s_ve, int16_t s_zv, int16_t s_ow, int16_t s_ss); @@ -280,12 +275,10 @@ void G_DrawRooms(int32_t playerNum,int32_t smoothratio); void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z); void G_GameExit(const char *msg) ATTRIBUTE((noreturn)); void G_GameQuit(void); -void G_GetCrosshairColor(void); void G_HandleLocalKeys(void); void G_HandleSpecialKeys(void); void G_PrintGameQuotes(int32_t snum); //void G_SE40(int32_t smoothratio); -void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b); void G_Shutdown(void); void G_UpdatePlayerFromMenu(void); void P_DoQuote(int32_t q,DukePlayer_t *p); diff --git a/source/rr/src/osdcmds.cpp b/source/rr/src/osdcmds.cpp index 27bd8f795..a7f6ec6ef 100644 --- a/source/rr/src/osdcmds.cpp +++ b/source/rr/src/osdcmds.cpp @@ -274,25 +274,6 @@ static int osdcmd_spawn(osdcmdptr_t parm) } -static int osdcmd_crosshaircolor(osdcmdptr_t parm) -{ - if (parm->numparms != 3) - { - OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b); - return OSDCMD_SHOWHELP; - } - - uint8_t const r = Batol(parm->parms[0]); - uint8_t const g = Batol(parm->parms[1]); - uint8_t const b = Batol(parm->parms[2]); - - G_SetCrosshairColor(r,g,b); - - OSD_Printf("%s\n", parm->raw); - - return OSDCMD_OK; -} - static int osdcmd_give(osdcmdptr_t parm) { int32_t i; @@ -577,8 +558,6 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("demo","demo : starts the given demo", osdcmd_demo); } - OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor); - #if !defined NETCODE_DISABLE OSD_RegisterFunction("connect","connect: connects to a multiplayer game", osdcmd_connect); OSD_RegisterFunction("disconnect","disconnect: disconnects from the local multiplayer game", osdcmd_disconnect); diff --git a/source/rr/src/premap.cpp b/source/rr/src/premap.cpp index 73a4ed2db..693e132cb 100644 --- a/source/rr/src/premap.cpp +++ b/source/rr/src/premap.cpp @@ -720,9 +720,6 @@ void G_UpdateScreenArea(void) videoSetViewableArea(x1,y1,x2-1,y2-1); } - G_GetCrosshairColor(); - G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b); - pub = NUMPAGES; pus = NUMPAGES; } diff --git a/source/rr/src/premap.h b/source/rr/src/premap.h index 73854f4aa..53117c2d4 100644 --- a/source/rr/src/premap.h +++ b/source/rr/src/premap.h @@ -29,7 +29,6 @@ extern int16_t g_ambientLotag[64]; extern int16_t g_ambientHitag[64]; extern int32_t g_levelTextTime; extern int32_t voting,vote_map,vote_episode; -extern palette_t CrosshairColors; void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName, int levelNum); int G_EnterLevel(int gameMode); int G_FindLevelByFile(const char *fileName); @@ -37,7 +36,6 @@ void G_CacheMapData(void); void G_FreeMapState(int levelNum); void G_NewGame(int volumeNum, int levelNum, int skillNum); void G_ResetTimers(uint8_t keepgtics); -void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b); void G_UpdateScreenArea(void); void P_RandomSpawnPoint(int playerNum); void P_ResetInventory(int playerNum); diff --git a/source/rr/src/screens.cpp b/source/rr/src/screens.cpp index f5e4bc01e..908193256 100644 --- a/source/rr/src/screens.cpp +++ b/source/rr/src/screens.cpp @@ -43,8 +43,6 @@ BEGIN_RR_NS #define quotepulseshade (sintable[((uint32_t)totalclock<<5)&2047]>>11) -palette_t CrosshairColors = { 255, 255, 255, 0 }; -palette_t DefaultCrosshairColors = { 0, 0, 0, 0 }; int32_t g_crosshairSum = -1; // yxaspect and viewingrange just before the 'main' drawrooms call int32_t dr_yxaspect, dr_viewingrange; @@ -92,80 +90,6 @@ void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set) videoSetPalette(0, palid, set); } -void G_GetCrosshairColor(void) -{ - if (DefaultCrosshairColors.f) - return; - - tileLoad(CROSSHAIR); - - auto ptr = tilePtr(CROSSHAIR); - if (!ptr) return; - - // find the brightest color in the original 8-bit tile - int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y; - int32_t bri = 0, j = 0, i; - - Bassert(ii > 0); - - do - { - if (*ptr != 255) - { - i = curpalette[(int32_t) *ptr].r+curpalette[(int32_t) *ptr].g+curpalette[(int32_t) *ptr].b; - if (i > j) { j = i; bri = *ptr; } - } - ptr++; - } while (--ii); - - Bmemcpy(&CrosshairColors, &curpalette[bri], sizeof(palette_t)); - Bmemcpy(&DefaultCrosshairColors, &curpalette[bri], sizeof(palette_t)); - DefaultCrosshairColors.f = 1; // this flag signifies that the color has been detected -} - -void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b) -{ - if (g_crosshairSum == r+(g<<8)+(b<<16)) - return; - - auto ptr = TileFiles.tileMakeWritable(CROSSHAIR); - if (!ptr) return; - - if (!DefaultCrosshairColors.f) - G_GetCrosshairColor(); - - g_crosshairSum = r+(g<<8)+(b<<16); - CrosshairColors.r = r; - CrosshairColors.g = g; - CrosshairColors.b = b; - - int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y; - - Bassert(ii > 0); - - int32_t i = (videoGetRenderMode() == REND_CLASSIC) - ? paletteGetClosestColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b) - : paletteGetClosestColor(255, 255, 255); // use white in GL so we can tint it to the right color - - do - { - if (*ptr != 255) - *ptr = i; - ptr++; - } while (--ii); - - paletteMakeLookupTable(CROSSHAIR_PAL, NULL, CrosshairColors.r, CrosshairColors.g, CrosshairColors.b, 1); - -#ifdef USE_OPENGL - // XXX: this makes us also load all hightile textures tinted with the crosshair color! - polytint_t & crosshairtint = hictinting[CROSSHAIR_PAL]; - crosshairtint.tint.r = CrosshairColors.r; - crosshairtint.tint.g = CrosshairColors.g; - crosshairtint.tint.b = CrosshairColors.b; - crosshairtint.f = HICTINT_USEONART | HICTINT_GRAYSCALE; -#endif - tileInvalidate(CROSSHAIR, -1, -1); -} #define SCORESHEETOFFSET -20 static void G_ShowScores(void) @@ -979,13 +903,12 @@ void G_DisplayRest(int32_t smoothratio) if ((unsigned) a < MAXTILES) { vec2_t crosshairpos = { (160<<16) - (g_player[myconnectindex].ps->look_ang<<15), 100<<16 }; - uint8_t crosshair_pal = CROSSHAIR_PAL; uint32_t crosshair_o = 1|2; uint32_t crosshair_scale = divscale16(cl_crosshairscale, 100); if (RR) crosshair_scale >>= 1; - rotatesprite_win(crosshairpos.x, crosshairpos.y, crosshair_scale, 0, a, 0, crosshair_pal, crosshair_o); + rotatesprite_win(crosshairpos.x, crosshairpos.y, crosshair_scale, 0, a, 0, 0, crosshair_o); } } From 454f796b690c7193af84b59c048bd7b9b101bf5e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 18 Jan 2020 22:41:08 +0100 Subject: [PATCH 37/51] - collect all 3D geometry in a list so that it can be rendered later. With this out of the way the renderer can now be switched to the core profile. --- source/build/include/build.h | 2 +- source/build/src/glsurface.cpp | 11 +- source/build/src/mdsprite.cpp | 16 +-- source/build/src/polymost.cpp | 8 +- source/build/src/voxmodel.cpp | 12 +- source/common/2d/v_2ddrawer.h | 2 +- .../rendering/gl/system/gl_framebuffer.cpp | 1 + .../hwrenderer/data/flatvertices.cpp | 22 +++- .../rendering/hwrenderer/data/flatvertices.h | 14 +++ source/common/rendering/v_framebuffer.cpp | 4 + source/glbackend/gl_renderstate.h | 9 +- source/glbackend/gl_texture.cpp | 19 ++-- source/glbackend/glbackend.cpp | 106 +++++++----------- source/glbackend/glbackend.h | 60 ++-------- source/glbackend/hw_draw2d.cpp | 4 +- source/platform/win32/win32glvideo.cpp | 2 +- 16 files changed, 127 insertions(+), 165 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 432a020c8..b59c98051 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -331,7 +331,7 @@ typedef struct { int16_t angoff, pitch, roll; vec3_t pivot_offset, position_offset; uint8_t flags; - uint8_t xpanning, ypanning; + uint8_t xpanning, ypanning; // EDuke script hacks. uint8_t filler; uint32_t filler2; float alpha; diff --git a/source/build/src/glsurface.cpp b/source/build/src/glsurface.cpp index d9be935f4..d0fe897a1 100644 --- a/source/build/src/glsurface.cpp +++ b/source/build/src/glsurface.cpp @@ -10,6 +10,7 @@ #include "baselayer.h" #include "build.h" #include "tarray.h" +#include "flatvertices.h" #include "../../glbackend/glbackend.h" static TArray buffer; @@ -75,13 +76,5 @@ void glsurface_blitBuffer() bufferTexture->LoadTexture(buffer.Data()); GLInterface.BindTexture(0, bufferTexture, SamplerNoFilterClampXY); - - auto data = GLInterface.AllocVertices(4); - auto vt = data.second; - - vt[0].Set(-1.0f, 1.0f, 0.0f, 0.0f, 0.0f); //top-left - vt[1].Set(-1.0f, -1.0f, 0.0f, 0.0f, 1.0f); //bottom-left - vt[2].Set(1.0f, 1.0f, 0.0f, 1.0f, 0.0f); //top-right - vt[3].Set(1.0f, -1.0f, 0.0f, 1.0f, 1.0f); //bottom-right - GLInterface.DrawIm(DT_TRIANGLE_STRIP, data.first, 4); + GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); } diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index c6cd880cb..d135a5ae9 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -15,6 +15,8 @@ #include "palette.h" #include "textures.h" #include "bitmap.h" +#include "v_video.h" +#include "flatvertices.h" #include "../../glbackend/glbackend.h" static int32_t curextra=MAXTILES; @@ -1454,8 +1456,8 @@ static void md3draw_handle_triangles(const md3surf_t *s, uint16_t *indexhandle, int32_t i; - auto data = GLInterface.AllocVertices(s->numtris * 3); - auto vt = data.second; + auto data = screen->mVertexData->AllocVertices(s->numtris * 3); + auto vt = data.first; for (i=s->numtris-1; i>=0; i--) { uint16_t tri = M ? M->indexes[i] : i; @@ -1470,7 +1472,7 @@ static void md3draw_handle_triangles(const md3surf_t *s, uint16_t *indexhandle, vt->SetVertex(vertlist[k].x, vertlist[k].y); } } - GLInterface.DrawIm(DT_TRIANGLES, data.first, s->numtris *3); + GLInterface.Draw(DT_TRIANGLES, data.second, s->numtris *3); #ifndef USE_GLEXT UNREFERENCED_PARAMETER(texunits); @@ -1638,9 +1640,6 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) k3 = (float)sintable[sext->roll&2047] * (1.f/16384.f); } - float const xpanning = (float)sext->xpanning * (1.f/256.f); - float const ypanning = (float)sext->ypanning * (1.f/256.f); - int prevClamp = GLInterface.GetClamp(); GLInterface.SetClamp(0); @@ -1720,10 +1719,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) } glow = hw_glowmapping ? mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, GLOWPAL, surfi, nullptr) : 0; } - GLInterface.SetModelTexture(tex, globalpal, xpanning, ypanning, det, detscale, glow); - - VSMatrix texmat(0); - texmat.translate(xpanning, ypanning, 1.0f); + GLInterface.SetModelTexture(tex, globalpal, det, detscale, glow); if (tspr->clipdist & TSPR_FLAGS_MDHACK) { diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index b577934d3..90ee8081e 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -16,6 +16,8 @@ Ken Silverman's official web site: http://www.advsys.net/ken #include "../../glbackend/glbackend.h" #include "c_cvars.h" #include "gamecvars.h" +#include "v_video.h" +#include "flatvertices.h" CVAR(Bool, hw_detailmapping, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, hw_glowmapping, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) @@ -581,8 +583,8 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 GLInterface.SetColor(pc[0], pc[1], pc[2], pc[3]); vec2f_t const scale = { 1.f / tsiz2.x, 1.f / tsiz2.y }; - auto data = GLInterface.AllocVertices(npoints); - auto vt = data.second; + auto data = screen->mVertexData->AllocVertices(npoints); + auto vt = data.first; for (bssize_t i = 0; i < npoints; ++i, vt++) { float const r = 1.f / dd[i]; @@ -599,7 +601,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 r * (1.f / 1024.f)); } - GLInterface.DrawIm(DT_TRIANGLE_FAN, data.first, npoints); + GLInterface.Draw(DT_TRIANGLE_FAN, data.second, npoints); GLInterface.SetTinting(-1, 0xffffff, 0xffffff); GLInterface.UseDetailMapping(false); diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 1e2123e14..8dc6dd486 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -10,6 +10,8 @@ #include "hightile.h" #include "polymost.h" #include "mdsprite.h" +#include "v_video.h" +#include "flatvertices.h" #include "palette.h" #include "../../glbackend/glbackend.h" @@ -1140,10 +1142,10 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) GLInterface.UseDetailMapping(false); #endif - auto data = GLInterface.AllocVertices(m->qcnt * 6); - auto vt = data.second; + auto data = screen->mVertexData->AllocVertices(m->qcnt * 6); + auto vt = data.first; - int qstart = 0; + int qstart = data.second; int qdone = 0; for (bssize_t i=0, fi=0; iqcnt; i++) { @@ -1152,7 +1154,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) f = 1 /*clut[fi++]*/; if (qdone > 0) { - GLInterface.DrawIm(DT_TRIANGLES, qstart, qdone * 6); + GLInterface.Draw(DT_TRIANGLES, qstart, qdone * 6); qstart += qdone * 6; qdone = 0; } @@ -1182,7 +1184,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) qdone++; } - GLInterface.DrawIm(DT_TRIANGLES, qstart, qdone * 6); + GLInterface.Draw(DT_TRIANGLES, qstart, qdone * 6); GLInterface.SetClamp(prevClamp); //------------ GLInterface.SetCull(Cull_None); diff --git a/source/common/2d/v_2ddrawer.h b/source/common/2d/v_2ddrawer.h index df71a8eec..8c282fa71 100644 --- a/source/common/2d/v_2ddrawer.h +++ b/source/common/2d/v_2ddrawer.h @@ -14,7 +14,7 @@ struct F2DPolygons TArray vertices; TArray indices; - unsigned AllocVertices(int num) // Allocates a triangle fan. There's no code that needs a triangle strip. + unsigned AllocVertices(int num) { auto vindex = vertices.Reserve(num); indices.Push(num); diff --git a/source/common/rendering/gl/system/gl_framebuffer.cpp b/source/common/rendering/gl/system/gl_framebuffer.cpp index b76b7bb35..affefa675 100644 --- a/source/common/rendering/gl/system/gl_framebuffer.cpp +++ b/source/common/rendering/gl/system/gl_framebuffer.cpp @@ -207,6 +207,7 @@ void OpenGLFrameBuffer::Update() Swap(); Super::Update(); + screen->mVertexData->Reset(); } //=========================================================================== diff --git a/source/common/rendering/hwrenderer/data/flatvertices.cpp b/source/common/rendering/hwrenderer/data/flatvertices.cpp index eae6a42e9..bdee1e5c1 100644 --- a/source/common/rendering/hwrenderer/data/flatvertices.cpp +++ b/source/common/rendering/hwrenderer/data/flatvertices.cpp @@ -36,6 +36,7 @@ #include "flatvertices.h" #include "v_video.h" #include "cmdlib.h" +#include "printf.h" #include "hwrenderer/data/buffers.h" //========================================================================== @@ -89,7 +90,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) }; mVertexBuffer->SetFormat(1, 2, sizeof(FFlatVertex), format); - mIndex = mCurIndex = 0; + mIndex = mCurIndex = NUM_RESERVED; mNumReserved = NUM_RESERVED; Copy(0, NUM_RESERVED); } @@ -129,6 +130,25 @@ void FFlatVertexBuffer::OutputResized(int width, int height) // //========================================================================== +std::pair FFlatVertexBuffer::AllocVertices(unsigned int count) +{ + FFlatVertex *p = GetBuffer(); + auto index = mCurIndex.fetch_add(count); + auto offset = index; + if (index + count >= BUFFER_SIZE_TO_USE) + { + // If a single scene needs 2'000'000 vertices there must be something very wrong. + I_FatalError("Out of vertex memory. Tried to allocate more than %u vertices for a single frame", index + count); + } + return std::make_pair(p, index); +} + +//========================================================================== +// +// +// +//========================================================================== + void FFlatVertexBuffer::Copy(int start, int count) { Map(); diff --git a/source/common/rendering/hwrenderer/data/flatvertices.h b/source/common/rendering/hwrenderer/data/flatvertices.h index 58c383013..c53941ff1 100644 --- a/source/common/rendering/hwrenderer/data/flatvertices.h +++ b/source/common/rendering/hwrenderer/data/flatvertices.h @@ -24,6 +24,20 @@ struct FFlatVertex u = uu; v = vv; } + + void SetVertex(float _x, float _y, float _z = 0) + { + x = _x; + z = _y; + y = _z; + } + + void SetTexCoord(float _u = 0, float _v = 0) + { + u = _u; + v = _v; + } + }; class FFlatVertexBuffer diff --git a/source/common/rendering/v_framebuffer.cpp b/source/common/rendering/v_framebuffer.cpp index 3ccb89de2..f27ad9c23 100644 --- a/source/common/rendering/v_framebuffer.cpp +++ b/source/common/rendering/v_framebuffer.cpp @@ -46,6 +46,7 @@ #include "i_time.h" #include "v_2ddrawer.h" #include "build.h" +#include "../glbackend/glbackend.h" /* #include "hwrenderer/scene/hw_portal.h" #include "hwrenderer/utility/hw_clock.h" @@ -390,5 +391,8 @@ void DFrameBuffer::FinishScene() if (videoGetRenderMode() < REND_POLYMOST) return; assert(BufferLock > 0); if (--BufferLock == 0) + { mVertexData->Unmap(); + GLInterface.DoDraw(); + } } diff --git a/source/glbackend/gl_renderstate.h b/source/glbackend/gl_renderstate.h index ea912f20f..9174c8117 100644 --- a/source/glbackend/gl_renderstate.h +++ b/source/glbackend/gl_renderstate.h @@ -50,13 +50,14 @@ enum PRSFlags STF_CLEARCOLOR = 1024, STF_CLEARDEPTH = 2048, STF_VIEWPORTSET = 4096, - STF_SCISSORSET = 4096, + STF_SCISSORSET = 8192, }; struct PolymostRenderState { + int vindex, vcount, primtype; float Shade; float NumShades = 64.f; float ShadeDiv = 62.f; @@ -70,7 +71,7 @@ struct PolymostRenderState float Color[4] = { 1,1,1,1 }; short matrixIndex[NUMMATRICES] = { -1,-1,-1,-1,-1 }; PalEntry fullscreenTint = 0xffffff, hictint = 0xffffff, hictint_overlay = 0xffffff; - int hictint_flags = 0; + int hictint_flags = -1; int StateFlags = STF_COLORMASK|STF_DEPTHMASK; FRenderStyle Style{}; @@ -82,9 +83,5 @@ struct PolymostRenderState PalEntry FogColor; - IVertexBuffer* VertexBuffer = nullptr; - int VB_Offset[2] = {}; - IIndexBuffer* IndexBuffer = nullptr; - void Apply(PolymostShader *shader, GLState &oldstate); }; diff --git a/source/glbackend/gl_texture.cpp b/source/glbackend/gl_texture.cpp index 1b36948c2..b2fa7a6e1 100644 --- a/source/glbackend/gl_texture.cpp +++ b/source/glbackend/gl_texture.cpp @@ -150,7 +150,7 @@ FHardwareTexture* GLInstance::LoadTexture(FTexture* tex, int textype, int palid) // //=========================================================================== -bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int method, int sampleroverride, float xpanning, float ypanning, FTexture *det, float detscale, FTexture *glow) +bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int method, int sampleroverride, FTexture *det, float detscale, FTexture *glow) { if (tex->GetWidth() <= 0 || tex->GetHeight() <= 0) return false; int usepalette = fixpalette >= 1 ? fixpalette - 1 : curbasepal; @@ -158,6 +158,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int GLInterface.SetPalette(usepalette); GLInterface.SetPalswap(usepalswap); bool texbound[3] = {}; + int MatrixChange = 0; TextureType = hw_useindexedcolortextures? TT_INDEXED : TT_TRUECOLOR; @@ -209,13 +210,12 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int UseBrightmaps(false); BindTexture(0, mtex, sampler); - if (rep && (rep->scale.x != 1.0f || rep->scale.y != 1.0f || xpanning != 0 || ypanning != 0)) + // Needs a) testing and b) verification for correctness. This doesn't look like it makes sense. + if (rep && (rep->scale.x != 1.0f || rep->scale.y != 1.0f)) { - texmat.loadIdentity(); - texmat.translate(xpanning, ypanning, 0); - texmat.scale(rep->scale.x, rep->scale.y, 1.0f); - GLInterface.SetMatrix(Matrix_Texture, &texmat); - MatrixChange |= 1; + //texmat.loadIdentity(); + //texmat.scale(rep->scale.x, rep->scale.y, 1.0f); + //GLInterface.SetMatrix(Matrix_Texture, &texmat); } // Also load additional layers needed for this texture. @@ -239,16 +239,17 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int BindTexture(3, htex, SamplerRepeat); texbound[0] = true; - // Q: Pass the scale factor as a separate uniform to get rid of the additional matrix? + + /* todo: instead of a matrix, just pass a two-component uniform. Using a full matrix here is problematic. if (MatrixChange & 1) MatrixChange |= 2; else texmat.loadIdentity(); - if ((detscalex != 1.0f) || (detscaley != 1.0f)) { texmat.scale(detscalex, detscaley, 1.0f); MatrixChange |= 2; } if (MatrixChange & 2) GLInterface.SetMatrix(Matrix_Detail, &texmat); + */ } } if (hw_glowmapping && hw_hightile) diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 91acf88f1..7257ce950 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -198,24 +198,25 @@ void GLInstance::ResetFrame() } +void GLInstance::SetVertexBuffer(IVertexBuffer* vb, int offset1, int offset2) +{ + int o[] = { offset1, offset2 }; + static_cast(vb)->Bind(o); +} + +void GLInstance::SetIndexBuffer(IIndexBuffer* vb) +{ + if (vb) static_cast(vb)->Bind(); + else glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); +} + void GLInstance::ClearBufferState() { - auto buffer = (screen->mVertexData->GetBufferObjects().first); - - SetVertexBuffer(buffer, 0, 0); + SetVertexBuffer(screen->mVertexData->GetBufferObjects().first, 0, 0); SetIndexBuffer(nullptr); - // Invalidate the pointers as well to make sure that if another buffer with the same address is used it actually gets bound. - LastVertexBuffer = (IVertexBuffer*)~intptr_t(0); - LastIndexBuffer = (IIndexBuffer*)~intptr_t(0); } -std::pair GLInstance::AllocVertices(size_t num) -{ - Buffer.resize(num); - return std::make_pair((size_t)0, Buffer.data()); -} - static GLint primtypes[] = { GL_TRIANGLES, @@ -224,37 +225,19 @@ static GLint primtypes[] = GL_LINES }; -void GLInstance::DrawIm(EDrawType type, size_t start, size_t count) -{ - // Todo: Based on the current tinting flags and the texture type (indexed texture and APPLYOVERPALSWAP not set) this may have to reset the palette for the draw call / texture creation. - bool applied = false; - - if (activeShader == polymostShader) - { - glVertexAttrib4fv(2, renderState.Color); - if (renderState.Color[3] != 1.f) renderState.Flags &= ~RF_Brightmapping; // The way the colormaps are set up means that brightmaps cannot be used on translucent content at all. - renderState.Apply(polymostShader, lastState); - } - glBegin(primtypes[type]); - auto p = &Buffer[start]; - for (size_t i = 0; i < count; i++, p++) - { - glVertexAttrib2f(1, p->u, p->v); - glVertexAttrib3f(0, p->x, p->y, p->z); - } - glEnd(); - - if (MatrixChange) - { - if (MatrixChange & 1) SetIdentityMatrix(Matrix_Texture); - if (MatrixChange & 2) SetIdentityMatrix(Matrix_Detail); - MatrixChange = 0; - } - matrixArray.Resize(1); -} - void GLInstance::Draw(EDrawType type, size_t start, size_t count) +{ + renderState.vindex = start; + renderState.vcount = count; + renderState.primtype = type; + rendercommands.Push(renderState); + SetIdentityMatrix(Matrix_Texture); + SetIdentityMatrix(Matrix_Detail); + renderState.StateFlags &= ~(STF_CLEARCOLOR | STF_CLEARDEPTH | STF_VIEWPORTSET | STF_SCISSORSET); +} + +void GLInstance::DrawElement(EDrawType type, size_t start, size_t count, PolymostRenderState &renderState) { // Todo: Based on the current tinting flags and the texture type (indexed texture and APPLYOVERPALSWAP not set) this may have to reset the palette for the draw call / texture creation. bool applied = false; @@ -264,28 +247,8 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count) glVertexAttrib4fv(2, renderState.Color); if (renderState.Color[3] != 1.f) renderState.Flags &= ~RF_Brightmapping; // The way the colormaps are set up means that brightmaps cannot be used on translucent content at all. renderState.Apply(polymostShader, lastState); - if (renderState.VertexBuffer != LastVertexBuffer || LastVB_Offset[0] != renderState.VB_Offset[0] || LastVB_Offset[1] != renderState.VB_Offset[1]) - { - if (renderState.VertexBuffer) - { - static_cast(renderState.VertexBuffer)->Bind(renderState.VB_Offset); - } - else glBindBuffer(GL_ARRAY_BUFFER, 0); - LastVertexBuffer = renderState.VertexBuffer; - LastVB_Offset[0] = renderState.VB_Offset[0]; - LastVB_Offset[1] = renderState.VB_Offset[1]; - } - if (renderState.IndexBuffer != LastIndexBuffer) - { - if (renderState.IndexBuffer) - { - static_cast(renderState.IndexBuffer)->Bind(); - } - else glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - LastIndexBuffer = renderState.IndexBuffer; - } } - if (type != DT_LINES && renderState.IndexBuffer) + if (type != DT_LINES) { glDrawElements(primtypes[type], count, GL_UNSIGNED_INT, (void*)(intptr_t)(start * sizeof(uint32_t))); } @@ -293,13 +256,22 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count) { glDrawArrays(primtypes[type], start, count); } - if (MatrixChange) +} + +void GLInstance::DoDraw() +{ + for (auto& rs : rendercommands) { - if (MatrixChange & 1) SetIdentityMatrix(Matrix_Texture); - if (MatrixChange & 2) SetIdentityMatrix(Matrix_Detail); - MatrixChange = 0; + // Todo: Based on the current tinting flags and the texture type (indexed texture and APPLYOVERPALSWAP not set) this may have to reset the palette for the draw call / texture creation. + bool applied = false; + + glVertexAttrib4fv(2, rs.Color); + if (rs.Color[3] != 1.f) rs.Flags &= ~RF_Brightmapping; // The way the colormaps are set up means that brightmaps cannot be used on translucent content at all. + rs.Apply(polymostShader, lastState); + glDrawArrays(primtypes[rs.primtype], rs.vindex, rs.vcount); } - matrixArray.Resize(1); + rendercommands.Clear(); + matrixArray.Clear(); } diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 9d869ba0c..14bfabfcf 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -95,34 +95,6 @@ struct glinfo_t { float maxanisotropy; }; -struct BaseVertex -{ - float x, y, z; - float u, v; - - void SetVertex(float _x, float _y, float _z = 0) - { - x = _x; - y = _y; - z = _z; - } - - void SetTexCoord(float _u = 0, float _v = 0) - { - u = _u; - v = _v; - } - - void Set(float _x, float _y, float _z = 0, float _u = 0, float _v = 0) - { - x = _x; - y = _y; - z = _z; - u = _u; - v = _v; - } -}; - enum EDrawType { DT_TRIANGLES, @@ -180,7 +152,7 @@ struct GLState class GLInstance { - std::vector Buffer; // cheap-ass implementation. The primary purpose is to get the GL accesses out of polymost.cpp, not writing something performant right away. + TArray rendercommands; int maxTextureSize; PaletteManager palmanager; int lastPalswapIndex = -1; @@ -193,10 +165,6 @@ class GLInstance // Cached GL state. GLState lastState; - IVertexBuffer* LastVertexBuffer = nullptr; - int LastVB_Offset[2] = {}; - IIndexBuffer* LastIndexBuffer = nullptr; - float mProjectionM5 = 1.0f; // needed by ssao PolymostRenderState renderState; FShader* activeShader; @@ -225,26 +193,18 @@ public: } GLInstance(); - std::pair AllocVertices(size_t num); - void DrawIm(EDrawType type, size_t start, size_t count); void Draw(EDrawType type, size_t start, size_t count); - + void DoDraw(); + void DrawElement(EDrawType type, size_t start, size_t count, PolymostRenderState& renderState); + FHardwareTexture* NewTexture(); void EnableNonTransparent255(bool on) { g_nontransparent255 = on; } - void SetVertexBuffer(IVertexBuffer* vb, int offset1, int offset2) - { - renderState.VertexBuffer = vb; - renderState.VB_Offset[0] = offset1; - renderState.VB_Offset[1] = offset2; - } - void SetIndexBuffer(IIndexBuffer* vb) - { - renderState.IndexBuffer = vb; - } + void SetVertexBuffer(IVertexBuffer* vb, int offset1, int offset2); + void SetIndexBuffer(IIndexBuffer* vb); void ClearBufferState(); float GetProjectionM5() { return mProjectionM5; } @@ -542,18 +502,18 @@ public: FHardwareTexture* CreateIndexedTexture(FTexture* tex); FHardwareTexture* CreateTrueColorTexture(FTexture* tex, int palid, bool checkfulltransparency = false, bool rgb8bit = false); FHardwareTexture *LoadTexture(FTexture* tex, int texturetype, int palid); - bool SetTextureInternal(int globalpicnum, FTexture* tex, int palette, int method, int sampleroverride, float xpanning, float ypanning, FTexture *det, float detscale, FTexture *glow); + bool SetTextureInternal(int globalpicnum, FTexture* tex, int palette, int method, int sampleroverride, FTexture *det, float detscale, FTexture *glow); bool SetNamedTexture(FTexture* tex, int palette, int sampleroverride); bool SetTexture(int globalpicnum, FTexture* tex, int palette, int method, int sampleroverride) { - return SetTextureInternal(globalpicnum, tex, palette, method, sampleroverride, 0, 0, nullptr, 1, nullptr); + return SetTextureInternal(globalpicnum, tex, palette, method, sampleroverride, nullptr, 1, nullptr); } - bool SetModelTexture(FTexture *tex, int palette, float xpanning, float ypanning, FTexture *det, float detscale, FTexture *glow) + bool SetModelTexture(FTexture *tex, int palette, FTexture *det, float detscale, FTexture *glow) { - return SetTextureInternal(-1, tex, palette, 8/*DAMETH_MODEL*/, -1, xpanning, ypanning, det, detscale, glow); + return SetTextureInternal(-1, tex, palette, 8/*DAMETH_MODEL*/, -1, det, detscale, glow); } }; diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index 9f2390ab4..7d4dfc87d 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -191,11 +191,11 @@ void GLInstance::Draw2D(F2DDrawer *drawer) { case F2DDrawer::DrawTypeTriangles: case F2DDrawer::DrawTypeRotateSprite: - Draw(DT_TRIANGLES, cmd.mIndexIndex, cmd.mIndexCount); + DrawElement(DT_TRIANGLES, cmd.mIndexIndex, cmd.mIndexCount, renderState); break; case F2DDrawer::DrawTypeLines: - Draw(DT_LINES, cmd.mVertIndex, cmd.mVertCount); + DrawElement(DT_LINES, cmd.mVertIndex, cmd.mVertCount, renderState); break; case F2DDrawer::DrawTypePoints: diff --git a/source/platform/win32/win32glvideo.cpp b/source/platform/win32/win32glvideo.cpp index b32d24c82..60982b48c 100644 --- a/source/platform/win32/win32glvideo.cpp +++ b/source/platform/win32/win32glvideo.cpp @@ -405,7 +405,7 @@ bool Win32GLVideo::InitHardware(HWND Window, int multisample) int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; const char *version = Args->CheckValue("-glversion"); - prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; // At the moment the renderer still needs the compatibility profile. + //prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; // At the moment the renderer still needs the compatibility profile. for (; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++) { From c7ffed4867bc49c670419ab1075286ff02ab18e2 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Sat, 18 Jan 2020 21:18:08 +1100 Subject: [PATCH 38/51] Blood: change fallthrough annotations to fix clang build Remove some fallthrough annotations so clang does not fatally error: source/blood/src/aiunicult.cpp:1983:13: error: fallthrough annotation does not directly precede switch label source/blood/src/triggers.cpp:1045:33: error: fallthrough annotation does not directly precede switch label # Conflicts: # source/blood/src/aiunicult.cpp # source/blood/src/triggers.cpp --- source/blood/src/aiunicult.cpp | 1 - source/blood/src/triggers.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/source/blood/src/aiunicult.cpp b/source/blood/src/aiunicult.cpp index 6940349d8..44102939b 100644 --- a/source/blood/src/aiunicult.cpp +++ b/source/blood/src/aiunicult.cpp @@ -1987,7 +1987,6 @@ bool genDudePrepare(spritetype* pSprite, int propId) { pSprite->clipdist = ClipRange((pSprite->xrepeat + pSprite->yrepeat) >> 1, 4, 120); if (propId) break; - break; } } diff --git a/source/blood/src/triggers.cpp b/source/blood/src/triggers.cpp index 1b3b2a2e7..514702938 100644 --- a/source/blood/src/triggers.cpp +++ b/source/blood/src/triggers.cpp @@ -1045,7 +1045,6 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case 4: for (int i = 0; i < 8; i++) pPlayer->hasKey[i] = false; if (pXSprite->data2) break; - break; } break; From 352c099b5ad67043c21383e49f7e9ad473c1c30a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jan 2020 08:40:03 +0100 Subject: [PATCH 39/51] - basics for hardware rendered camera textures. --- .../rendering/gl/renderer/gl_renderer.cpp | 12 +++--- .../rendering/gl/renderer/gl_renderer.h | 12 +----- .../rendering/gl/system/gl_framebuffer.h | 1 - source/common/textures/textures.h | 1 - source/glbackend/gl_hwtexture.cpp | 42 +++++++++++++++++++ source/glbackend/gl_hwtexture.h | 11 ++--- 6 files changed, 55 insertions(+), 24 deletions(-) diff --git a/source/common/rendering/gl/renderer/gl_renderer.cpp b/source/common/rendering/gl/renderer/gl_renderer.cpp index 7bde82962..1c6bfa7cc 100644 --- a/source/common/rendering/gl/renderer/gl_renderer.cpp +++ b/source/common/rendering/gl/renderer/gl_renderer.cpp @@ -59,6 +59,7 @@ //#include "r_data/models/models.h" #include "gl/renderer/gl_postprocessstate.h" #include "gl/system/gl_buffers.h" +#include "../glbackend/gl_hwtexture.h" #include "build.h" EXTERN_CVAR(Int, screenblocks) @@ -168,20 +169,17 @@ void FGLRenderer::EndOffscreen() // //=========================================================================== -void FGLRenderer::BindToFrameBuffer(FMaterial *mat) +void FGLRenderer::BindToFrameBuffer(FTexture *mat) { -#if 0 - auto BaseLayer = static_cast(mat->GetLayer(0, 0)); + auto pBaseLayer = mat->GetHardwareTexture(0); + auto BaseLayer = pBaseLayer ? *pBaseLayer : nullptr; if (BaseLayer == nullptr) { // must create the hardware texture first - BaseLayer->BindOrCreate(mat->sourcetex, 0, 0, 0, 0); - FHardwareTexture::Unbind(0); - gl_RenderState.ClearLastMaterial(); + BaseLayer->CreateTexture(mat->GetWidth(), mat->GetHeight(), FHardwareTexture::TrueColor, false); } BaseLayer->BindToFrameBuffer(mat->GetWidth(), mat->GetHeight()); -#endif } //=========================================================================== diff --git a/source/common/rendering/gl/renderer/gl_renderer.h b/source/common/rendering/gl/renderer/gl_renderer.h index f588440db..b3a2ec6b6 100644 --- a/source/common/rendering/gl/renderer/gl_renderer.h +++ b/source/common/rendering/gl/renderer/gl_renderer.h @@ -88,20 +88,12 @@ public: bool StartOffscreen(); void EndOffscreen(); - void BindToFrameBuffer(FMaterial *mat); + void BindToFrameBuffer(FTexture* tex); private: void DrawScene(HWDrawInfo *di, int drawmode); - bool QuadStereoCheckInitialRenderContextState(); - void PresentAnaglyph(bool r, bool g, bool b); - void PresentSideBySide(); - void PresentTopBottom(); - void prepareInterleavedPresent(FPresentShaderBase& shader); - void PresentColumnInterleaved(); - void PresentRowInterleaved(); - void PresentCheckerInterleaved(); - void PresentQuadStereo(); + }; diff --git a/source/common/rendering/gl/system/gl_framebuffer.h b/source/common/rendering/gl/system/gl_framebuffer.h index 6f9b0e7c9..aeda7cada 100644 --- a/source/common/rendering/gl/system/gl_framebuffer.h +++ b/source/common/rendering/gl/system/gl_framebuffer.h @@ -8,7 +8,6 @@ namespace OpenGLRenderer { -class FHardwareTexture; class FGLDebug; class OpenGLFrameBuffer : public SystemGLFrameBuffer diff --git a/source/common/textures/textures.h b/source/common/textures/textures.h index ba7621719..5bd9e877f 100644 --- a/source/common/textures/textures.h +++ b/source/common/textures/textures.h @@ -139,7 +139,6 @@ class FSerializer; namespace OpenGLRenderer { class FGLRenderState; - class FHardwareTexture; } union FContentIdBuilder diff --git a/source/glbackend/gl_hwtexture.cpp b/source/glbackend/gl_hwtexture.cpp index ae1beebe8..6288c93c9 100644 --- a/source/glbackend/gl_hwtexture.cpp +++ b/source/glbackend/gl_hwtexture.cpp @@ -39,6 +39,7 @@ #include "bitmap.h" #include "c_dispatch.h" #include "printf.h" +#include "gl_interface.h" //#include "compat.h" // Workaround to avoid including the dirty 'compat.h' header. This will hopefully not be needed anymore once the texture format uses something better. @@ -145,6 +146,7 @@ FHardwareTexture::~FHardwareTexture() { alltexturesize -= allocated; if (glTexID != 0) glDeleteTextures(1, &glTexID); + if (glBufferID != 0) glDeleteBuffers(1, &glBufferID); } @@ -153,4 +155,44 @@ unsigned int FHardwareTexture::GetTextureHandle() return glTexID; } +static int GetTexDimension(int value) +{ + if (value > gl.max_texturesize) return gl.max_texturesize; + return value; +} + +//=========================================================================== +// +// Creates a depth buffer for this texture +// +//=========================================================================== + +int FHardwareTexture::GetDepthBuffer(int width, int height) +{ + if (glDepthID == 0) + { + glGenRenderbuffers(1, &glDepthID); + glBindRenderbuffer(GL_RENDERBUFFER, glDepthID); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); + glBindRenderbuffer(GL_RENDERBUFFER, 0); + } + return glDepthID; +} + + +//=========================================================================== +// +// Binds this texture's surfaces to the current framrbuffer +// +//=========================================================================== + +void FHardwareTexture::BindToFrameBuffer(int width, int height) +{ + width = GetTexDimension(width); + height = GetTexDimension(height); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexID, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer(width, height)); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer(width, height)); +} + diff --git a/source/glbackend/gl_hwtexture.h b/source/glbackend/gl_hwtexture.h index a4c9be5a5..f2db59b54 100644 --- a/source/glbackend/gl_hwtexture.h +++ b/source/glbackend/gl_hwtexture.h @@ -1,7 +1,4 @@ - -#ifndef __GLTEXTURE_H -#define __GLTEXTURE_H - +#pragma once class FBitmap; class FTexture; @@ -22,12 +19,16 @@ private: int mSampler = 0; unsigned int glTexID = 0; + unsigned int glDepthID = 0; // only used by camera textures + unsigned int glBufferID = 0; int internalType = TrueColor; bool mipmapped = true; int mWidth = 0, mHeight = 0; int colorId = 0; uint32_t allocated = 0; + int GetDepthBuffer(int w, int h); + public: ~FHardwareTexture(); @@ -43,9 +44,9 @@ public: int GetSampler() { return mSampler; } void SetSampler(int sampler) { mSampler = sampler; } bool isIndexed() const { return internalType == Indexed; } + void BindToFrameBuffer(int w, int h); friend class FGameTexture; }; -#endif From c4429cf15d206fcf282b730c9b60b6aeb732917a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jan 2020 13:50:31 +0100 Subject: [PATCH 40/51] - fixed voxel rendering. --- source/build/src/voxmodel.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 8dc6dd486..18a7359ce 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -1177,9 +1177,10 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) #else vt->SetTexCoord(((float)vptr[j].u)*ru, ((float)vptr[j].v)*rv); #endif - vt->x = ((float)vptr[j].x) - phack[xx>vptr[j].x*2] + phack[xxy = ((float)vptr[j].y) - phack[yy>vptr[j].y*2] + phack[yyz = ((float)vptr[j].z) - phack[zz>vptr[j].z*2] + phack[zzSetVertex( + ((float)vptr[j].x) - phack[xx > vptr[j].x * 2] + phack[xx < vptr[j].x * 2], + ((float)vptr[j].y) - phack[yy > vptr[j].y * 2] + phack[yy < vptr[j].y * 2], + ((float)vptr[j].z) - phack[zz > vptr[j].z * 2] + phack[zz < vptr[j].z * 2]); } qdone++; } From 7a5f60e14d18536f6693b623d816bdf29c4451e6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jan 2020 13:57:24 +0100 Subject: [PATCH 41/51] - removed gl_projectionhacks and the SOFTROTMAT code path. Both were hard coded not to be used. --- source/build/include/build.h | 1 - source/build/src/polymost.cpp | 104 +++++++--------------------------- 2 files changed, 22 insertions(+), 83 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index b59c98051..a1b4ea091 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1111,7 +1111,6 @@ enum { TEXFILTER_ON = 5, // GL_LINEAR_MIPMAP_LINEAR }; -extern int32_t glprojectionhacks; extern int32_t gltexmaxsize; void gltexapplyprops (void); void texcache_invalidate(void); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 90ee8081e..85cf8bc93 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -26,7 +26,6 @@ CVARD(Bool, hw_animsmoothing, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/di CVARD(Bool, hw_hightile, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable hightile texture rendering") CVARD(Bool, hw_models, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable model rendering") CVARD(Bool, hw_parallaxskypanning, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable parallaxed floor/ceiling panning when drawing a parallaxing sky") -//{ "r_projectionhack", "enable/disable projection hack", (void*)&glprojectionhacks, CVAR_INT, 0, 2 }, What is this? CVARD(Bool, hw_shadeinterpolate, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable shade interpolation") CVARD(Float, hw_shadescale, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "multiplier for shading") CVARD(Bool, hw_useindexedcolortextures, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable indexed color texture rendering") @@ -102,8 +101,9 @@ static float ghorizcorrect; double gxyaspect; float gyxscale, ghalfx, grhalfxdown10, grhalfxdown10x, ghalfy; float gcosang, gsinang, gcosang2, gsinang2; -float gchang, gshang, gctang, gstang; float gtang = 0.f; + +float gchang = 0, gshang = 0, gctang = 0, gstang = 0; float gvrcorrection = 1.f; static vec3d_t xtex, ytex, otex, xtex2, ytex2, otex2; @@ -119,7 +119,6 @@ static int32_t drawpoly_srepeat = 0, drawpoly_trepeat = 0; static int32_t lastglpolygonmode = 0; //FUK -int32_t glprojectionhacks = 2; static FHardwareTexture *polymosttext = 0; int32_t glrendmode = REND_POLYMOST; @@ -256,26 +255,6 @@ void polymost_glinit() } -static float get_projhack_ratio(void) -{ - if ((glprojectionhacks == 1) && !r_yshearing) - { - // calculates the extend of the zenith glitch - float verticalfovtan = (fviewingrange * (windowxy2.y-windowxy1.y) * 5.f) / ((float)yxaspect * (windowxy2.x-windowxy1.x) * 4.f); - float verticalfov = atanf(verticalfovtan) * (2.f / fPI); - static constexpr float const maxhorizangle = 0.6361136f; // horiz of 199 in degrees - float zenglitch = verticalfov + maxhorizangle - 0.95f; // less than 1 because the zenith glitch extends a bit - if (zenglitch <= 0.f) - return 1.f; - float const zenglitchtan = tanf((verticalfov - zenglitch) * (fPI / 2.f)); - static constexpr float const maxcoshoriz = 0.54097117f; // 128/sqrt(128^2+199^2) = cos of an horiz diff of 199 - return 1.f + (((verticalfovtan / zenglitchtan) - 1.f) * ((1.f - Bfabsf(gchang)) / maxcoshoriz )); - } - - // No projection hacks (legacy or new-aspect) - return 1.f; -} - static void resizeglcheck(void) { //FUK @@ -292,7 +271,7 @@ static void resizeglcheck(void) if ((glox1 != windowxy1.x) || (gloy1 != windowxy1.y) || (glox2 != windowxy2.x) || (gloy2 != windowxy2.y) || (gloxyaspect != gxyaspect) || (gloyxscale != gyxscale) || (glohoriz2 != ghoriz2) || (glohorizcorrect != ghorizcorrect) || (glotang != gtang)) { const int32_t ourxdimen = (windowxy2.x-windowxy1.x+1); - float ratio = get_projhack_ratio(); + float ratio = 1; const int32_t fovcorrect = (int32_t)(ourxdimen*ratio - ourxdimen); ratio = 1.f/ratio; @@ -323,7 +302,6 @@ static void resizeglcheck(void) m[2][3] = 1.f; m[3][2] = -(2.f * farclip * nearclip) / (farclip - nearclip); GLInterface.SetMatrix(Matrix_Projection, &m[0][0]); - VSMatrix identity(0); GLInterface.SetIdentityMatrix(Matrix_ModelView); } } @@ -395,34 +373,22 @@ int32_t polymost_spriteHasTranslucency(tspritetype const * const tspr) static void polymost_updaterotmat(void) { - if (1) - { - float matrix[16] = { - 1.f, 0.f, 0.f, 0.f, - 0.f, 1.f, 0.f, 0.f, - 0.f, 0.f, 1.f, 0.f, - 0.f, 0.f, 0.f, 1.f, - }; -#if !SOFTROTMAT - //Up/down rotation - float udmatrix[16] = { - 1.f, 0.f, 0.f, 0.f, - 0.f, gchang, -gshang*gvrcorrection, 0.f, - 0.f, gshang/gvrcorrection, gchang, 0.f, - 0.f, 0.f, 0.f, 1.f, - }; - // Tilt rotation - float tiltmatrix[16] = { - gctang, -gstang, 0.f, 0.f, - gstang, gctang, 0.f, 0.f, - 0.f, 0.f, 1.f, 0.f, - 0.f, 0.f, 0.f, 1.f, - }; - multiplyMatrix4f(matrix, udmatrix); - multiplyMatrix4f(matrix, tiltmatrix); -#endif - GLInterface.SetMatrix(Matrix_View, matrix); - } + //Up/down rotation + float matrix[16] = { + 1.f, 0.f, 0.f, 0.f, + 0.f, gchang, -gshang*gvrcorrection, 0.f, + 0.f, gshang/gvrcorrection, gchang, 0.f, + 0.f, 0.f, 0.f, 1.f, + }; + // Tilt rotation + float tiltmatrix[16] = { + gctang, -gstang, 0.f, 0.f, + gstang, gctang, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f, + }; + multiplyMatrix4f(matrix, tiltmatrix); + GLInterface.SetMatrix(Matrix_View, matrix); } static void polymost_identityrotmat(void) @@ -476,34 +442,9 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 int j = 0; float px[8], py[8], dd[8], uu[8], vv[8]; -#if SOFTROTMAT - float const ozgs = (ghalfx / gvrcorrection) * gshang, - ozgc = (ghalfx / gvrcorrection) * gchang; -#endif for (bssize_t i=0; i= 3) && (px[j-1] == px[0]) && (py[j-1] == py[0])) j--; @@ -3240,7 +3180,7 @@ void polymost_drawrooms() GLInterface.SetBrightness(r_scenebrightness); gvrcorrection = viewingrange*(1.f/65536.f); - if (glprojectionhacks == 2) + //if (glprojectionhacks == 2) { // calculates the extend of the zenith glitch float verticalfovtan = (fviewingrange * (windowxy2.y-windowxy1.y) * 5.f) / ((float)yxaspect * (windowxy2.x-windowxy1.x) * 4.f); @@ -3286,7 +3226,7 @@ void polymost_drawrooms() ghoriz = (float)(ydimen>>1); resizeglcheck(); - float const ratio = 1.f/get_projhack_ratio(); + float const ratio = 1.f; //global cos/sin tilt angle gctang = cosf(gtang); @@ -3703,7 +3643,7 @@ void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang //POGO: prepare necessary globals for drawing, as we intend to call this outside of drawrooms gvrcorrection = viewingrange*(1.f/65536.f); - if (glprojectionhacks == 2) + //if (glprojectionhacks == 2) { // calculates the extend of the zenith glitch float verticalfovtan = (fviewingrange * (windowxy2.y-windowxy1.y) * 5.f) / ((float)yxaspect * (windowxy2.x-windowxy1.x) * 4.f); From 57a455d6cb19fe66043a8f742a7261d6a54ea7a7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jan 2020 13:59:45 +0100 Subject: [PATCH 42/51] - swapped order of matrix application. Model rotation must come before view rotation, this just never showed up because EDuke32 doesn't have both non-identity at the same time. --- wadsrc/static/engine/shaders/glsl/polymost.vp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/wadsrc/static/engine/shaders/glsl/polymost.vp b/wadsrc/static/engine/shaders/glsl/polymost.vp index b8b0b8f17..3784f3db0 100644 --- a/wadsrc/static/engine/shaders/glsl/polymost.vp +++ b/wadsrc/static/engine/shaders/glsl/polymost.vp @@ -19,13 +19,11 @@ in vec4 i_texCoord; in vec4 i_color; -const float c_zero = 0.0; -const float c_one = 1.0; void main() { - vec4 vertex = u_rotMatrix * i_vertPos; - vec4 eyeCoordPosition = u_modelMatrix * vertex; + vec4 vertex = u_modelMatrix * i_vertPos; + vec4 eyeCoordPosition = u_rotMatrix * vertex; v_eyeCoordPosition = eyeCoordPosition; gl_Position = u_projectionMatrix * eyeCoordPosition; From b209b1f960a69e28ec557d10601cfcbe77bab14b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jan 2020 14:08:48 +0100 Subject: [PATCH 43/51] - make sure that the first matrix is always the identity matrix. It was just random luck that it was always put there before. - let the matrix setters return the previous value for easy restoring without creating yet another matrix. --- source/glbackend/glbackend.cpp | 15 ++++++--------- source/glbackend/glbackend.h | 14 ++++++++++---- source/glbackend/hw_draw2d.cpp | 6 +++--- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 7257ce950..b2b366d11 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -73,7 +73,8 @@ GLInstance GLInterface; GLInstance::GLInstance() :palmanager(this) { - + VSMatrix mat(0); + matrixArray.Push(mat); } void ImGui_Init_Backend(); @@ -239,9 +240,6 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count) void GLInstance::DrawElement(EDrawType type, size_t start, size_t count, PolymostRenderState &renderState) { - // Todo: Based on the current tinting flags and the texture type (indexed texture and APPLYOVERPALSWAP not set) this may have to reset the palette for the draw call / texture creation. - bool applied = false; - if (activeShader == polymostShader) { glVertexAttrib4fv(2, renderState.Color); @@ -262,24 +260,23 @@ void GLInstance::DoDraw() { for (auto& rs : rendercommands) { - // Todo: Based on the current tinting flags and the texture type (indexed texture and APPLYOVERPALSWAP not set) this may have to reset the palette for the draw call / texture creation. - bool applied = false; - glVertexAttrib4fv(2, rs.Color); if (rs.Color[3] != 1.f) rs.Flags &= ~RF_Brightmapping; // The way the colormaps are set up means that brightmaps cannot be used on translucent content at all. rs.Apply(polymostShader, lastState); glDrawArrays(primtypes[rs.primtype], rs.vindex, rs.vcount); } rendercommands.Clear(); - matrixArray.Clear(); + matrixArray.Resize(1); } -void GLInstance::SetMatrix(int num, const VSMatrix *mat) +int GLInstance::SetMatrix(int num, const VSMatrix *mat) { + int r = renderState.matrixIndex[num]; if (num == Matrix_Projection) mProjectionM5 = mat->get()[5]; renderState.matrixIndex[num] = matrixArray.Size(); matrixArray.Push(*mat); + return r; } void GLInstance::ReadPixels(int xdim, int ydim, uint8_t* buffer) diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 14bfabfcf..ca281e096 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -208,14 +208,20 @@ public: void ClearBufferState(); float GetProjectionM5() { return mProjectionM5; } - void SetMatrix(int num, const VSMatrix *mat ); - void SetMatrix(int num, const float *mat) + int SetMatrix(int num, const VSMatrix *mat ); + int SetMatrix(int num, const float *mat) { - SetMatrix(num, reinterpret_cast(mat)); + return SetMatrix(num, reinterpret_cast(mat)); } - void SetIdentityMatrix(int num) + int SetIdentityMatrix(int num) { + auto r = renderState.matrixIndex[num]; renderState.matrixIndex[num] = 0; + return r; + } + void RestoreMatrix(int num, int index) + { + renderState.matrixIndex[num] = index; } void SetPolymostShader(); diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index 7d4dfc87d..60a6140e1 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -97,9 +97,9 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 void GLInstance::Draw2D(F2DDrawer *drawer) { VSMatrix mat(0); - SetMatrix(Matrix_View, mat.get()); - SetMatrix(Matrix_ModelView, mat.get()); - SetMatrix(Matrix_Detail, mat.get()); + SetIdentityMatrix(Matrix_View); + SetIdentityMatrix(Matrix_ModelView); + SetIdentityMatrix(Matrix_Detail); mat.ortho(0, xdim, ydim, 0, -1, 1); SetMatrix(Matrix_Projection, mat.get()); SetViewport(0, 0, xdim, ydim); From 11cbdb9fefead7a6647388ae0f1d8352890b4074 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 19 Jan 2020 15:52:00 +0100 Subject: [PATCH 44/51] Fix some uninitialized variables --- libraries/zmusic/decoder/mpg123_decoder.h | 2 +- libraries/zmusic/decoder/sndfile_decoder.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/zmusic/decoder/mpg123_decoder.h b/libraries/zmusic/decoder/mpg123_decoder.h index d6c8675e4..83ed6be33 100644 --- a/libraries/zmusic/decoder/mpg123_decoder.h +++ b/libraries/zmusic/decoder/mpg123_decoder.h @@ -35,7 +35,7 @@ private: mpg123_handle *MPG123; bool Done; - MusicIO::FileInterface* Reader; + MusicIO::FileInterface* Reader = nullptr; static off_t file_lseek(void *handle, off_t offset, int whence); static ssize_t file_read(void *handle, void *buffer, size_t bytes); diff --git a/libraries/zmusic/decoder/sndfile_decoder.h b/libraries/zmusic/decoder/sndfile_decoder.h index 33aad19d8..2761ec7c4 100644 --- a/libraries/zmusic/decoder/sndfile_decoder.h +++ b/libraries/zmusic/decoder/sndfile_decoder.h @@ -31,7 +31,7 @@ private: SNDFILE *SndFile; SF_INFO SndInfo; - MusicIO::FileInterface* Reader; + MusicIO::FileInterface* Reader = nullptr; static sf_count_t file_get_filelen(void *user_data); static sf_count_t file_seek(sf_count_t offset, int whence, void *user_data); static sf_count_t file_read(void *ptr, sf_count_t count, void *user_data); From c8fa2443d3034f890e7fef3b14ad486d57991cf0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jan 2020 16:06:31 +0100 Subject: [PATCH 45/51] - completely separated view and model matrix. This way the view matrix will remain constant per scene and an update of the model matrix is only needed for rendering a model or voxel, reducing the total amount of generated matrices to the point where they can be written to a buffer instead of constantly uploading them as uniforms. --- source/build/src/mdsprite.cpp | 26 +++++----- source/build/src/polymost.cpp | 42 +++++----------- source/build/src/voxmodel.cpp | 4 +- source/glbackend/gl_renderstate.h | 4 +- source/glbackend/glbackend.cpp | 4 +- source/glbackend/hw_draw2d.cpp | 82 +++++++++++++------------------ 6 files changed, 67 insertions(+), 95 deletions(-) diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index d135a5ae9..5414a9ed9 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -1427,23 +1427,26 @@ int md3postload_polymer(md3model_t *m) void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float mat[16]) { - float g; float k0, k1, k2, k3, k4, k5, k6, k7; k0 = ((float)(tspr->x+spriteext[tspr->owner].position_offset.x-globalposx))*f*(1.f/1024.f); k1 = ((float)(tspr->y+spriteext[tspr->owner].position_offset.y-globalposy))*f*(1.f/1024.f); - f = gcosang2*gshang/gvrcorrection; - g = gsinang2*gshang/gvrcorrection; k4 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+1024)&2047] * (1.f/16384.f); k5 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+ 512)&2047] * (1.f/16384.f); k2 = k0*(1-k4)+k1*k5; k3 = k1*(1-k4)-k0*k5; - k6 = f*gstang - gsinang*gctang; k7 = g*gstang + gcosang*gctang; - mat[0] = k4*k6 + k5*k7; mat[4] = gchang*gstang; mat[ 8] = k4*k7 - k5*k6; mat[12] = k2*k6 + k3*k7; - k6 = f*gctang + gsinang*gstang; k7 = g*gctang - gcosang*gstang; - mat[1] = k4*k6 + k5*k7; mat[5] = gchang*gctang; mat[ 9] = k4*k7 - k5*k6; mat[13] = k2*k6 + k3*k7; - k6 = gcosang2*gchang; k7 = gsinang2*gchang; - mat[2] = k4*k6 + k5*k7; mat[6] =-gshang*gvrcorrection; mat[10] = k4*k7 - k5*k6; mat[14] = k2*k6 + k3*k7; + k6 = - gsinang; + k7 = gcosang; + mat[0] = k4*k6 + k5*k7; mat[4] = 0; mat[ 8] = k4*k7 - k5*k6; mat[12] = k2*k6 + k3*k7; + + mat[1] = 0; mat[5] = 1; mat[ 9] = 0; mat[13] = 0; + + k6 = gcosang2; + k7 = gsinang2; + mat[2] = k4*k6 + k5*k7; + mat[6] =0; + mat[10] = k4*k7 - k5*k6; + mat[14] = k2*k6 + k3*k7; mat[12] = (mat[12] + a0->y*mat[0]) + (a0->z*mat[4] + a0->x*mat[ 8]); mat[13] = (mat[13] + a0->y*mat[1]) + (a0->z*mat[5] + a0->x*mat[ 9]); @@ -1642,6 +1645,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) int prevClamp = GLInterface.GetClamp(); GLInterface.SetClamp(0); + auto matrixindex = GLInterface.SetIdentityMatrix(Matrix_Model); for (surfi=0; surfihead.numsurfs; surfi++) { @@ -1696,7 +1700,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) //Let OpenGL (and perhaps hardware :) handle the matrix rotation mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f; - GLInterface.SetMatrix(Matrix_ModelView, mat); + GLInterface.SetMatrix(Matrix_Model, mat); // PLAG: End bool exact = false; @@ -1786,7 +1790,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) GLInterface.SetCull(Cull_None); VSMatrix identity(0); - GLInterface.SetIdentityMatrix(Matrix_ModelView); + GLInterface.RestoreMatrix(Matrix_Model, matrixindex); GLInterface.SetTinting(-1, 0xffffff, 0xffffff); GLInterface.SetClamp(prevClamp); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 85cf8bc93..37174f6fc 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -302,7 +302,7 @@ static void resizeglcheck(void) m[2][3] = 1.f; m[3][2] = -(2.f * farclip * nearclip) / (farclip - nearclip); GLInterface.SetMatrix(Matrix_Projection, &m[0][0]); - GLInterface.SetIdentityMatrix(Matrix_ModelView); + GLInterface.SetIdentityMatrix(Matrix_Model); } } @@ -391,11 +391,6 @@ static void polymost_updaterotmat(void) GLInterface.SetMatrix(Matrix_View, matrix); } -static void polymost_identityrotmat(void) -{ - GLInterface.SetIdentityMatrix(Matrix_View); -} - static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, int32_t method, const vec2_16_t& tilesiz); static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32_t method, const vec2_16_t &tilesize) @@ -3232,7 +3227,7 @@ void polymost_drawrooms() gctang = cosf(gtang); gstang = sinf(gtang); - if (Bfabsf(gstang) < .001f) // This hack avoids nasty precision bugs in domost() + if (Bfabsf(gstang) < .001f) // This avoids nasty precision bugs in domost() { gstang = 0.f; gctang = (gctang > 0.f) ? 1.f : -1.f; @@ -3257,10 +3252,9 @@ void polymost_drawrooms() v = { o2.x, o2.y * gchang + o2.z * gshang, o2.z * gchang - o2.y * gshang }; } -#if !SOFTROTMAT if (inpreparemirror) gstang = -gstang; -#endif + polymost_updaterotmat(); //Clip to SCISDIST plane int n = 0; @@ -3354,8 +3348,6 @@ void polymost_drawrooms() //else if (!g_nodraw) { videoEndDrawing(); return; } #endif - polymost_updaterotmat(); - numscans = numbunches = 0; // MASKWALL_BAD_ACCESS @@ -3418,7 +3410,6 @@ void polymost_drawrooms() } GLInterface.SetDepthFunc(Depth_LessEqual); - polymost_identityrotmat(); videoEndDrawing(); } @@ -3626,9 +3617,7 @@ static void polymost_drawmaskwallinternal(int32_t wallIndex) pow2xsplit = 0; skyclamphack = 0; - polymost_updaterotmat(); polymost_drawpoly(dpxy, n, method, tilesiz[globalpicnum]); - polymost_identityrotmat(); } void polymost_drawmaskwall(int32_t damaskwallcnt) @@ -3692,6 +3681,7 @@ void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang gstang = 0.f; gctang = (gctang > 0.f) ? 1.f : -1.f; } + polymost_updaterotmat(); grhalfxdown10x = grhalfxdown10; //POGO: write the mirror region to the stencil buffer to allow showing mirrors & skyboxes at the same time @@ -3899,8 +3889,6 @@ void polymost_drawsprite(int32_t snum) if (tsiz.x <= 0 || tsiz.y <= 0) return; - polymost_updaterotmat(); - vec2f_t const ftsiz = { (float) tsiz.x, (float) tsiz.y }; switch ((globalorientation >> 4) & 3) @@ -4421,7 +4409,7 @@ void polymost_drawsprite(int32_t snum) show2dsprite[spritenum>>3] |= pow2char[spritenum&7]; _drawsprite_return: - polymost_identityrotmat(); + ; } EDUKE32_STATIC_ASSERT((int)RS_YFLIP == (int)HUDFLAG_FLIPPED); @@ -4462,18 +4450,19 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a, polymost_outputGLDebugMessage(3, "polymost_dorotatespritemodel(sx:%d, sy:%d, z:%d, a:%hd, picnum:%hd, dashade:%hhd, dapalnum:%hhu, dastat:%d, daalpha:%hhu, dablend:%hhu, uniqid:%d)", sx, sy, z, a, picnum, dashade, dapalnum, dastat, daalpha, dablend, uniqid); - float const ogchang = gchang; gchang = 1.f; - float const ogshang = gshang; gshang = 0.f; d = (float) z*(1.0f/(65536.f*16384.f)); - float const ogctang = gctang; gctang = (float) sintable[(a+512)&2047]*d; - float const ogstang = gstang; gstang = (float) sintable[a&2047]*d; + gchang = 1.f; + gshang = 0.f; d = (float) z*(1.0f/(65536.f*16384.f)); + gctang = (float) sintable[(a+512)&2047]*d; + gstang = (float) sintable[a&2047]*d; + gvrcorrection = 1.f; + polymost_updaterotmat(); + int const ogshade = globalshade; globalshade = dashade; int const ogpal = globalpal; globalpal = (int32_t) ((uint8_t) dapalnum); double const ogxyaspect = gxyaspect; gxyaspect = 1.f; int const oldviewingrange = viewingrange; viewingrange = 65536; float const oldfviewingrange = fviewingrange; fviewingrange = 65536.f; - float const ogvrcorrection = gvrcorrection; gvrcorrection = 1.f; - polymost_updaterotmat(); vec1 = hud->add; @@ -4572,7 +4561,6 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a, GLInterface.SetMatrix(Matrix_Projection, &m[0][0]); VSMatrix identity(0); - GLInterface.SetIdentityMatrix(Matrix_ModelView); } if (hud->flags & HUDFLAG_NODEPTH) @@ -4596,17 +4584,11 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a, if (videoGetRenderMode() == REND_POLYMOST) polymost_mddraw(&tspr); - gvrcorrection = ogvrcorrection; viewingrange = oldviewingrange; fviewingrange = oldfviewingrange; gxyaspect = ogxyaspect; globalshade = ogshade; globalpal = ogpal; - gchang = ogchang; - gshang = ogshang; - gctang = ogctang; - gstang = ogstang; - polymost_identityrotmat(); } diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 18a7359ce..7fd28ed4d 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -1120,7 +1120,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) //Let OpenGL (and perhaps hardware :) handle the matrix rotation mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f; - GLInterface.SetMatrix(Matrix_ModelView, mat); + int matrixindex = GLInterface.SetMatrix(Matrix_Model, mat); const float ru = 1.f/((float)m->mytexx); const float rv = 1.f/((float)m->mytexy); @@ -1195,7 +1195,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) GLInterface.SetDepthFunc(Depth_Less); } VSMatrix identity(0); - GLInterface.SetIdentityMatrix(Matrix_ModelView); + GLInterface.RestoreMatrix(Matrix_Model, matrixindex); GLInterface.SetFadeDisable(false); GLInterface.SetTinting(-1, 0xffffff, 0xffffff); return 1; diff --git a/source/glbackend/gl_renderstate.h b/source/glbackend/gl_renderstate.h index 9174c8117..a7a290246 100644 --- a/source/glbackend/gl_renderstate.h +++ b/source/glbackend/gl_renderstate.h @@ -10,7 +10,7 @@ enum EMatrixType { Matrix_View, Matrix_Projection, - Matrix_ModelView, + Matrix_Model, Matrix_Detail, Matrix_Texture, // These are the only ones being used. @@ -69,7 +69,7 @@ struct PolymostRenderState float AlphaThreshold = 0.5f; bool AlphaTest = true; float Color[4] = { 1,1,1,1 }; - short matrixIndex[NUMMATRICES] = { -1,-1,-1,-1,-1 }; + short matrixIndex[NUMMATRICES] = { 0,0,0,0,0 }; PalEntry fullscreenTint = 0xffffff, hictint = 0xffffff, hictint_overlay = 0xffffff; int hictint_flags = -1; diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index b2b366d11..f9891e7e8 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -464,8 +464,8 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState) shader->RotMatrix.Set(matrixArray[matrixIndex[Matrix_View]].get()); if (matrixIndex[Matrix_Projection] != -1) shader->ProjectionMatrix.Set(matrixArray[matrixIndex[Matrix_Projection]].get()); - if (matrixIndex[Matrix_ModelView] != -1) - shader->ModelMatrix.Set(matrixArray[matrixIndex[Matrix_ModelView]].get()); + if (matrixIndex[Matrix_Model] != -1) + shader->ModelMatrix.Set(matrixArray[matrixIndex[Matrix_Model]].get()); if (matrixIndex[Matrix_Detail] != -1) shader->DetailMatrix.Set(matrixArray[matrixIndex[Matrix_Detail]].get()); if (matrixIndex[Matrix_Texture] != -1) diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index 60a6140e1..00b9a9cf1 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -98,7 +98,7 @@ void GLInstance::Draw2D(F2DDrawer *drawer) { VSMatrix mat(0); SetIdentityMatrix(Matrix_View); - SetIdentityMatrix(Matrix_ModelView); + SetIdentityMatrix(Matrix_Model); SetIdentityMatrix(Matrix_Detail); mat.ortho(0, xdim, ydim, 0, -1, 1); SetMatrix(Matrix_Projection, mat.get()); @@ -226,62 +226,48 @@ void GLInstance::Draw2D(F2DDrawer *drawer) //drawer->mIsFirstPass = false; EnableBlend(true); EnableMultisampling(true); + SetIdentityMatrix(Matrix_Projection); } -void fullscreen_tint_gl(PalEntry pe) -{ - // Todo: reroute to the 2D drawer - GLInterface.SetIdentityMatrix(Matrix_Projection); - GLInterface.SetIdentityMatrix(Matrix_ModelView); - - GLInterface.EnableDepthTest(false); - GLInterface.EnableAlphaTest(false); - - GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]); - GLInterface.EnableBlend(true); - GLInterface.SetColorub (pe.r, pe.g, pe.b, pe.a); - - GLInterface.UseColorOnly(true); - - GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); - GLInterface.UseColorOnly(false); -} - -void fullscreen_tint_gl_blood(int tint_blood_r, int tint_blood_g, int tint_blood_b) -{ - if (!(tint_blood_r | tint_blood_g | tint_blood_b)) - return; - GLInterface.SetIdentityMatrix(Matrix_Projection); - GLInterface.SetIdentityMatrix(Matrix_ModelView); - - GLInterface.EnableDepthTest(false); - GLInterface.EnableAlphaTest(false); - - GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Add]); - GLInterface.EnableBlend(true); - - GLInterface.UseColorOnly(true); - GLInterface.SetColorub(max(tint_blood_r, 0), max(tint_blood_g, 0), max(tint_blood_b, 0), 255); - GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); - - GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Subtract]); - GLInterface.SetColorub(max(-tint_blood_r, 0), max(-tint_blood_g, 0), max(-tint_blood_b, 0), 255); - GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); - - GLInterface.SetColorub(255, 255, 255, 255); - GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]); - GLInterface.UseColorOnly(false); -} - static int32_t tint_blood_r = 0, tint_blood_g = 0, tint_blood_b = 0; extern palette_t palfadergb; extern char palfadedelta ; void DrawFullscreenBlends() { - if (palfadedelta) fullscreen_tint_gl(PalEntry(palfadedelta, palfadergb.r, palfadergb.g, palfadergb.b)); - fullscreen_tint_gl_blood(tint_blood_r, tint_blood_g, tint_blood_b); + GLInterface.SetIdentityMatrix(Matrix_Projection); + GLInterface.SetIdentityMatrix(Matrix_Model); + GLInterface.SetIdentityMatrix(Matrix_View); + + GLInterface.EnableDepthTest(false); + GLInterface.EnableAlphaTest(false); + GLInterface.EnableBlend(true); + GLInterface.UseColorOnly(true); + + if (palfadedelta) + { + // Todo: reroute to the 2D drawer + GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]); + GLInterface.SetColorub(palfadergb.r, palfadergb.g, palfadergb.b, palfadedelta); + GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); + } + if (tint_blood_r | tint_blood_g | tint_blood_b) + { + GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Add]); + + GLInterface.SetColorub(max(tint_blood_r, 0), max(tint_blood_g, 0), max(tint_blood_b, 0), 255); + GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); + + GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Subtract]); + GLInterface.SetColorub(max(-tint_blood_r, 0), max(-tint_blood_g, 0), max(-tint_blood_b, 0), 255); + GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); + + GLInterface.SetColorub(255, 255, 255, 255); + GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]); + } + GLInterface.UseColorOnly(false); + } From aa1361acbb2015594fdd8d5b6c247865d950dfa1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jan 2020 23:18:38 +0100 Subject: [PATCH 46/51] - make palfadedelta explicitly unsigned --- source/build/include/palette.h | 2 +- source/build/src/palette.cpp | 2 +- source/glbackend/hw_draw2d.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/build/include/palette.h b/source/build/include/palette.h index 94df7d90b..09fdd2f6b 100644 --- a/source/build/include/palette.h +++ b/source/build/include/palette.h @@ -51,7 +51,7 @@ typedef struct { } rgb24_t; extern palette_t curpalette[256], curpalettefaded[256], palfadergb; -extern char palfadedelta; +extern unsigned char palfadedelta; void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal); void paletteSetColorTable(int32_t id, uint8_t const *table, bool transient = false); void paletteFreeColorTable(int32_t id); diff --git a/source/build/src/palette.cpp b/source/build/src/palette.cpp index 49153d1aa..ca018f02a 100644 --- a/source/build/src/palette.cpp +++ b/source/build/src/palette.cpp @@ -27,7 +27,7 @@ uint32_t g_lastpalettesum = 0; palette_t curpalette[256]; // the current palette, unadjusted for brightness or tint palette_t curpalettefaded[256]; // the current palette, adjusted for brightness and tint (ie. what gets sent to the card) palette_t palfadergb = { 0, 0, 0, 0 }; -char palfadedelta = 0; +unsigned char palfadedelta = 0; int32_t realmaxshade; float frealmaxshade; diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index 00b9a9cf1..ac16511f2 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -232,7 +232,7 @@ void GLInstance::Draw2D(F2DDrawer *drawer) static int32_t tint_blood_r = 0, tint_blood_g = 0, tint_blood_b = 0; extern palette_t palfadergb; -extern char palfadedelta ; +extern unsigned char palfadedelta ; void DrawFullscreenBlends() { @@ -245,7 +245,7 @@ void DrawFullscreenBlends() GLInterface.EnableBlend(true); GLInterface.UseColorOnly(true); - if (palfadedelta) + if (palfadedelta > 0) { // Todo: reroute to the 2D drawer GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]); From b066f725d44a16d1010cbe8192a81145221249dd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jan 2020 23:27:59 +0100 Subject: [PATCH 47/51] - clear the matrix list after rendering the 2D content. --- source/glbackend/glbackend.cpp | 2 +- source/glbackend/hw_draw2d.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index f9891e7e8..dbe5e2851 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -56,7 +56,7 @@ static int blendstyles[] = { GL_ZERO, GL_ONE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALP static int renderops[] = { GL_FUNC_ADD, GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT }; int depthf[] = { GL_ALWAYS, GL_LESS, GL_EQUAL, GL_LEQUAL }; -static TArray matrixArray; +TArray matrixArray; FileReader GetResource(const char* fn) { diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index ac16511f2..bde5359aa 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -43,6 +43,8 @@ #include "flatvertices.h" extern int16_t numshades; +extern TArray matrixArray; + //=========================================================================== // // Vertex buffer for 2D drawer @@ -227,6 +229,7 @@ void GLInstance::Draw2D(F2DDrawer *drawer) EnableBlend(true); EnableMultisampling(true); SetIdentityMatrix(Matrix_Projection); + matrixArray.Resize(1); } From 6f39b87d5b7ed4a8d4133cf4d50e015da050bfbe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jan 2020 23:49:53 +0100 Subject: [PATCH 48/51] - actually draw the fullscreen blends. --- source/glbackend/hw_draw2d.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index bde5359aa..e02568908 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -269,6 +269,7 @@ void DrawFullscreenBlends() GLInterface.SetColorub(255, 255, 255, 255); GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]); } + GLInterface.DoDraw(); GLInterface.UseColorOnly(false); } From bd1523ef2d600cff2416d137a7cfa465bc286476 Mon Sep 17 00:00:00 2001 From: BSzili Date: Sun, 19 Jan 2020 20:49:01 +0100 Subject: [PATCH 49/51] Rednukem: fix building with NETCODE_DISABLE # Conflicts: # source/rr/src/game.cpp # source/rr/src/net.h --- source/rr/src/game.cpp | 26 +++++++++++++------------- source/rr/src/net.h | 7 +++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 8a55cfed3..cca7fa239 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------- +//------------------------------------------------------------------------- /* Copyright (C) 2016 EDuke32 developers and contributors @@ -7428,23 +7428,23 @@ MAIN_LOOP_RESTART: { do { - //if (g_networkMode != NET_DEDICATED_SERVER) - //{ - // if (RRRA && g_player[myconnectindex].ps->on_motorcycle) - // P_GetInputMotorcycle(myconnectindex); - // else if (RRRA && g_player[myconnectindex].ps->on_boat) - // P_GetInputBoat(myconnectindex); - // else - // P_GetInput(myconnectindex); - //} - - //Bmemcpy(&inputfifo[0][myconnectindex], &localInput, sizeof(input_t)); - if (!frameJustDrawn) break; frameJustDrawn = false; +#ifdef NETCODE_DISABLE + if (RRRA && g_player[myconnectindex].ps->on_motorcycle) + P_GetInputMotorcycle(myconnectindex); + else if (RRRA && g_player[myconnectindex].ps->on_boat) + P_GetInputBoat(myconnectindex); + else + P_GetInput(myconnectindex); + + inputfifo[g_player[myconnectindex].movefifoend&(MOVEFIFOSIZ-1)][myconnectindex] = localInput; + g_player[myconnectindex].movefifoend++; +#endif + do { if (ready2send == 0) break; diff --git a/source/rr/src/net.h b/source/rr/src/net.h index f678c4ea0..f994192be 100644 --- a/source/rr/src/net.h +++ b/source/rr/src/net.h @@ -398,6 +398,13 @@ void Net_SendRTS(int ridiculeNum); #define Net_SendTaunt(...) ((void)0) #define Net_SendRTS(...) ((void)0) +#define Net_WaitForEverybody(...) ((void)0) +#define initsynccrc(...) ((void)0) +#define Net_GetSyncStat(...) ((void)0) +#define Net_DisplaySyncMsg(...) ((void)0) +#define Net_ClearFIFO(...) ((void)0) +#define Net_GetInput(...) ((void)0) + #endif END_RR_NS From d7d5da93f63b26819f7993bc9651ccb88d03989a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 20 Jan 2020 00:24:25 +0100 Subject: [PATCH 50/51] - properly set up info.plist for macOS --- source/CMakeLists.txt | 2 +- .../posix/osx/{zdoom-info.plist => raze-info.plist} | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) rename source/platform/posix/osx/{zdoom-info.plist => raze-info.plist} (86%) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 89aeae8e6..7666b6527 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -985,7 +985,7 @@ if( APPLE ) set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${LINK_FRAMEWORKS}" - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/${PROJECT_NAME}-info.plist" ) + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/platform/posix/osx/${PROJECT_NAME}-info.plist" ) # Dymanic libraries like libvulkan.dylib or libMoltenVK.dylib will be loaded by dlopen() # if placed in the directory with the main executable diff --git a/source/platform/posix/osx/zdoom-info.plist b/source/platform/posix/osx/raze-info.plist similarity index 86% rename from source/platform/posix/osx/zdoom-info.plist rename to source/platform/posix/osx/raze-info.plist index f0bbbf3d9..298674518 100644 --- a/source/platform/posix/osx/zdoom-info.plist +++ b/source/platform/posix/osx/raze-info.plist @@ -9,11 +9,11 @@ CFBundleIconFile zdoom.icns CFBundleIdentifier - org.drdteam.gzdoom + org.drdteam.raze CFBundleInfoDictionaryVersion 6.0 CFBundleName - GZDoom + Raze CFBundlePackageType APPL CFBundleShortVersionString @@ -28,19 +28,16 @@ CFBundleTypeName - Doom Resource File + Build Engine Resource File CFBundleTypeRole Viewer CFBundleTypeExtensions - wad + grp pk3 zip pk7 7z - iwad - ipk3 - ipk7 From ef3ade08d3b280b3a1c7ae479337a077a4ed3eaa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 20 Jan 2020 00:42:40 +0100 Subject: [PATCH 51/51] - silence debug diagnostics for non-test builds --- source/duke3d/src/anim.cpp | 3 ++- source/rr/src/anim.cpp | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index 28c9b1674..a0748abc0 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -392,8 +392,9 @@ int32_t Anim_Play(const char *fn) } while (timerGetTicks() < nextframetime); } while (running); GLInterface.EnableNonTransparent255(false); - +#ifdef DEBUGGINGAIDS animvpx_print_stats(&codec); +#endif // animvpx_restore_glstate(); diff --git a/source/rr/src/anim.cpp b/source/rr/src/anim.cpp index b01da71be..4096a7fdf 100644 --- a/source/rr/src/anim.cpp +++ b/source/rr/src/anim.cpp @@ -423,7 +423,9 @@ int32_t Anim_Play(const char *fn) } while (running); GLInterface.EnableNonTransparent255(false); - animvpx_print_stats(&codec); + #ifdef DEBUGGINGAIDS + animvpx_print_stats(&codec); + #endif // animvpx_restore_glstate();