From fb4e34d1783fa9c82e3523423280425c106aa1f5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 8 Dec 2016 13:07:52 +0100 Subject: [PATCH 1/7] Fix crash reporter for 64 bit --- src/win32/i_main.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index db92467bc..0931aff99 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -1184,6 +1184,11 @@ void CALLBACK ExitFatally (ULONG_PTR dummy) // //========================================================================== +namespace +{ + CONTEXT MainThreadContext; +} + LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info) { #ifdef _DEBUG @@ -1208,11 +1213,7 @@ LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info) // Otherwise, put the crashing thread to sleep and signal the main thread to clean up. if (GetCurrentThreadId() == MainThreadID) { -#ifndef _M_X64 - info->ContextRecord->Eip = (DWORD_PTR)ExitFatally; -#else - info->ContextRecord->Rip = (DWORD_PTR)ExitFatally; -#endif + *info->ContextRecord = MainThreadContext; } else { @@ -1304,6 +1305,15 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE nothing, LPSTR cmdline, int n if (MainThread != INVALID_HANDLE_VALUE) { SetUnhandledExceptionFilter (CatchAllExceptions); + + static bool setJumpResult = false; + RtlCaptureContext(&MainThreadContext); + if (setJumpResult) + { + ExitFatally(0); + return 0; + } + setJumpResult = true; } #endif From 8f4566408923e8fb952c46fe06725b0c704e6061 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Dec 2016 17:00:15 +0100 Subject: [PATCH 2/7] - fixed: Fog boundaries were not drawn on line portals. There's two restrictions, though: * on one-sided-line portals fog boundaries will not be drawn. * the filler sector behind the portal may not have a sky ceiling texture. This is because the drawing code contains several sky checks which get in the way here. --- src/gl/scene/gl_walls.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index db16a941a..30e10b73f 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1654,7 +1654,10 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) /* mid texture */ - bool drawfogboundary = gl_CheckFog(frontsector, backsector); + bool isportal = seg->linedef->isVisualPortal() && seg->sidedef == seg->linedef->sidedef[0]; + sector_t *backsec = isportal? seg->linedef->getPortalDestination()->frontsector : backsector; + + bool drawfogboundary = gl_CheckFog(frontsector, backsec); FTexture *tex = TexMan(seg->sidedef->GetTexture(side_t::mid)); if (tex != NULL) { @@ -1672,7 +1675,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); } - if (seg->linedef->isVisualPortal() && seg->sidedef == seg->linedef->sidedef[0]) + if (isportal) { lineportal = linePortalToGL[seg->linedef->portalindex]; ztop[0] = bch1; From a4d2468d34ee2fffa80367a121bab8b63ab0089e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Dec 2016 17:51:13 +0100 Subject: [PATCH 3/7] - disable weapon interpolation for offset changes. This has been causing far too many problems so now it will only be done if a A_Weaponoffset is either used with WOF_ADD or WOF_INTERPOLATE. --- src/p_pspr.cpp | 8 ++++++-- wadsrc/static/zscript/constants.txt | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 2bd3696d4..3ef74da73 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -390,13 +390,14 @@ void DPSprite::SetState(FState *newstate, bool pending) if (ID != PSP_FLASH) { // It's still possible to set the flash layer's offsets with the action function. + // Anything going through here cannot be reliably interpolated so this has to reset the interpolation coordinates if it changes the values. if (newstate->GetMisc1()) { // Set coordinates. - x = newstate->GetMisc1(); + oldx = x = newstate->GetMisc1(); } if (newstate->GetMisc2()) { - y = newstate->GetMisc2(); + oldy = y = newstate->GetMisc2(); } } @@ -1041,6 +1042,7 @@ enum WOFFlags WOF_KEEPX = 1, WOF_KEEPY = 1 << 1, WOF_ADD = 1 << 2, + WOF_INTERPOLATE = 1 << 3, }; void A_OverlayOffset(AActor *self, int layer, double wx, double wy, int flags) @@ -1069,6 +1071,7 @@ void A_OverlayOffset(AActor *self, int layer, double wx, double wy, int flags) else { psp->x = wx; + if (!(flags & WOF_INTERPOLATE)) psp->oldx = psp->x; } } if (!(flags & WOF_KEEPY)) @@ -1080,6 +1083,7 @@ void A_OverlayOffset(AActor *self, int layer, double wx, double wy, int flags) else { psp->y = wy; + if (!(flags & WOF_INTERPOLATE)) psp->oldy = psp->y; } } } diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index 147b23e4e..6597f8323 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -703,6 +703,7 @@ enum EWeaponOffsetFlags WOF_KEEPX = 1, WOF_KEEPY = 1 << 1, WOF_ADD = 1 << 2, + WOF_INTERPOLATE = 1 << 3, }; // Flags for psprite layers From d46ceafd35b204430b05327c31cb4dabda3bfb62 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Dec 2016 19:07:10 +0100 Subject: [PATCH 4/7] - fixed: A_Face* had the sign for the pitch inverted (In Doom, negative pitch is upward, this had positive pitch upward.) --- src/p_enemy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index da4e3cc45..4b99a5f52 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -3061,7 +3061,7 @@ void A_Face(AActor *self, AActor *other, DAngle max_turn, DAngle max_pitch, DAng double dist_z = target_z - source_z; double ddist = g_sqrt(dist.X*dist.X + dist.Y*dist.Y + dist_z*dist_z); - DAngle other_pitch = DAngle::ToDegrees(g_asin(dist_z / ddist)).Normalized180(); + DAngle other_pitch = -DAngle::ToDegrees(g_asin(dist_z / ddist)).Normalized180(); if (max_pitch != 0) { From 6c628c9584530da716a16c34068af336c547be59 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Dec 2016 19:27:49 +0100 Subject: [PATCH 5/7] - changed sprite setup to work without global work variables. --- src/r_data/sprites.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index fbb01b24d..3e0cb80cc 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -15,6 +15,8 @@ #include "r_data/voxels.h" #include "textures/textures.h" +void gl_InitModels(); + // variables used to look up // and range check thing_t sprites patches TArray sprites; @@ -24,10 +26,8 @@ DWORD NumStdSprites; // The first x sprites that don't belong to skins. struct spriteframewithrotate : public spriteframe_t { int rotate; -} -sprtemp[MAX_SPRITE_FRAMES]; -int maxframe; -char* spritename; +}; + // [RH] skin globals FPlayerSkin *skins; @@ -44,7 +44,7 @@ PalEntry OtherGameSkinPalette[256]; // [RH] Removed checks for coexistance of rotation 0 with other // rotations and made it look more like BOOM's version. // -static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool flipped) +static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool flipped, spriteframewithrotate *sprtemp, int &maxframe) { unsigned rotation; @@ -117,7 +117,7 @@ static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool // [RH] Seperated out of R_InitSpriteDefs() -static void R_InstallSprite (int num) +static void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxframe) { int frame; int framestart; @@ -265,6 +265,8 @@ void R_InitSpriteDefs () unsigned int i, j, smax, vmax; DWORD intname; + spriteframewithrotate sprtemp[MAX_SPRITE_FRAMES]; + // Create a hash table to speed up the process smax = TexMan.NumTextures(); hashes = new Hasher[smax]; @@ -346,7 +348,7 @@ void R_InitSpriteDefs () sprtemp[j].Voxel = NULL; } - maxframe = -1; + int maxframe = -1; intname = sprites[i].dwName; // scan the lumps, filling in the frames for whatever is found @@ -356,10 +358,10 @@ void R_InitSpriteDefs () FTexture *tex = TexMan[hash]; if (TEX_DWNAME(tex) == intname) { - bool res = R_InstallSpriteLump (FTextureID(hash), tex->Name[4] - 'A', tex->Name[5], false); + bool res = R_InstallSpriteLump (FTextureID(hash), tex->Name[4] - 'A', tex->Name[5], false, sprtemp, maxframe); if (tex->Name[6] && res) - R_InstallSpriteLump (FTextureID(hash), tex->Name[6] - 'A', tex->Name[7], true); + R_InstallSpriteLump (FTextureID(hash), tex->Name[6] - 'A', tex->Name[7], true, sprtemp, maxframe); } hash = hashes[hash].Next; } @@ -396,7 +398,7 @@ void R_InitSpriteDefs () hash = vh->Next; } - R_InstallSprite ((int)i); + R_InstallSprite ((int)i, sprtemp, maxframe); } delete[] hashes; @@ -760,13 +762,14 @@ void R_InitSkins (void) for(int spr = 0; spr<2; spr++) { + spriteframewithrotate sprtemp[MAX_SPRITE_FRAMES]; memset (sprtemp, 0xFFFF, sizeof(sprtemp)); for (k = 0; k < MAX_SPRITE_FRAMES; ++k) { sprtemp[k].Flip = 0; sprtemp[k].Voxel = NULL; } - maxframe = -1; + int maxframe = -1; if (spr == 1) { @@ -790,10 +793,10 @@ void R_InitSkins (void) if (lnameint == intname) { FTextureID picnum = TexMan.CreateTexture(k, FTexture::TEX_SkinSprite); - bool res = R_InstallSpriteLump (picnum, lname[4] - 'A', lname[5], false); + bool res = R_InstallSpriteLump (picnum, lname[4] - 'A', lname[5], false, sprtemp, maxframe); if (lname[6] && res) - R_InstallSpriteLump (picnum, lname[6] - 'A', lname[7], true); + R_InstallSpriteLump (picnum, lname[6] - 'A', lname[7], true, sprtemp, maxframe); } } @@ -809,7 +812,7 @@ void R_InitSkins (void) int sprno = (int)sprites.Push (temp); if (spr==0) skins[i].sprite = sprno; else skins[i].crouchsprite = sprno; - R_InstallSprite (sprno); + R_InstallSprite (sprno, sprtemp, maxframe); } } @@ -985,6 +988,8 @@ void R_InitSprites () // [RH] Sort the skins, but leave base as skin 0 //qsort (&skins[PlayerClasses.Size ()], numskins-PlayerClasses.Size (), sizeof(FPlayerSkin), skinsorter); + + gl_InitModels(); } void R_DeinitSpriteData() From 3fbe41957d88b59df7d3f36e9ba997b5fd36a410 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Dec 2016 21:05:31 +0100 Subject: [PATCH 6/7] - removed GZDoom call. --- src/r_data/sprites.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index 3e0cb80cc..10b63d993 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -15,8 +15,6 @@ #include "r_data/voxels.h" #include "textures/textures.h" -void gl_InitModels(); - // variables used to look up // and range check thing_t sprites patches TArray sprites; @@ -989,7 +987,6 @@ void R_InitSprites () // [RH] Sort the skins, but leave base as skin 0 //qsort (&skins[PlayerClasses.Size ()], numskins-PlayerClasses.Size (), sizeof(FPlayerSkin), skinsorter); - gl_InitModels(); } void R_DeinitSpriteData() From 8a6d3b8e7b485e24460c654e03edca21d7c64840 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Dec 2016 21:05:53 +0100 Subject: [PATCH 7/7] - sprites.cpp --- src/r_data/sprites.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index 80c2d9488..3e0cb80cc 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -26,10 +26,8 @@ DWORD NumStdSprites; // The first x sprites that don't belong to skins. struct spriteframewithrotate : public spriteframe_t { int rotate; -} -sprtemp[MAX_SPRITE_FRAMES]; -int maxframe; -char* spritename; +}; + // [RH] skin globals FPlayerSkin *skins; @@ -46,7 +44,7 @@ PalEntry OtherGameSkinPalette[256]; // [RH] Removed checks for coexistance of rotation 0 with other // rotations and made it look more like BOOM's version. // -static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool flipped) +static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool flipped, spriteframewithrotate *sprtemp, int &maxframe) { unsigned rotation; @@ -119,7 +117,7 @@ static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool // [RH] Seperated out of R_InitSpriteDefs() -static void R_InstallSprite (int num) +static void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxframe) { int frame; int framestart; @@ -267,6 +265,8 @@ void R_InitSpriteDefs () unsigned int i, j, smax, vmax; DWORD intname; + spriteframewithrotate sprtemp[MAX_SPRITE_FRAMES]; + // Create a hash table to speed up the process smax = TexMan.NumTextures(); hashes = new Hasher[smax]; @@ -348,7 +348,7 @@ void R_InitSpriteDefs () sprtemp[j].Voxel = NULL; } - maxframe = -1; + int maxframe = -1; intname = sprites[i].dwName; // scan the lumps, filling in the frames for whatever is found @@ -358,10 +358,10 @@ void R_InitSpriteDefs () FTexture *tex = TexMan[hash]; if (TEX_DWNAME(tex) == intname) { - bool res = R_InstallSpriteLump (FTextureID(hash), tex->Name[4] - 'A', tex->Name[5], false); + bool res = R_InstallSpriteLump (FTextureID(hash), tex->Name[4] - 'A', tex->Name[5], false, sprtemp, maxframe); if (tex->Name[6] && res) - R_InstallSpriteLump (FTextureID(hash), tex->Name[6] - 'A', tex->Name[7], true); + R_InstallSpriteLump (FTextureID(hash), tex->Name[6] - 'A', tex->Name[7], true, sprtemp, maxframe); } hash = hashes[hash].Next; } @@ -398,7 +398,7 @@ void R_InitSpriteDefs () hash = vh->Next; } - R_InstallSprite ((int)i); + R_InstallSprite ((int)i, sprtemp, maxframe); } delete[] hashes; @@ -762,13 +762,14 @@ void R_InitSkins (void) for(int spr = 0; spr<2; spr++) { + spriteframewithrotate sprtemp[MAX_SPRITE_FRAMES]; memset (sprtemp, 0xFFFF, sizeof(sprtemp)); for (k = 0; k < MAX_SPRITE_FRAMES; ++k) { sprtemp[k].Flip = 0; sprtemp[k].Voxel = NULL; } - maxframe = -1; + int maxframe = -1; if (spr == 1) { @@ -792,10 +793,10 @@ void R_InitSkins (void) if (lnameint == intname) { FTextureID picnum = TexMan.CreateTexture(k, FTexture::TEX_SkinSprite); - bool res = R_InstallSpriteLump (picnum, lname[4] - 'A', lname[5], false); + bool res = R_InstallSpriteLump (picnum, lname[4] - 'A', lname[5], false, sprtemp, maxframe); if (lname[6] && res) - R_InstallSpriteLump (picnum, lname[6] - 'A', lname[7], true); + R_InstallSpriteLump (picnum, lname[6] - 'A', lname[7], true, sprtemp, maxframe); } } @@ -811,7 +812,7 @@ void R_InitSkins (void) int sprno = (int)sprites.Push (temp); if (spr==0) skins[i].sprite = sprno; else skins[i].crouchsprite = sprno; - R_InstallSprite (sprno); + R_InstallSprite (sprno, sprtemp, maxframe); } }