From 62880f113be972a97255af4c1e9b2af484278567 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 31 Aug 2014 23:01:53 +0200 Subject: [PATCH 1/5] - fix a render glitch with Back to Saturn X MAP06: Do not flood missing upper and lower textures with the backsector's flat if that backsector is malformed (i.e. has no area.) --- src/gl/data/gl_setup.cpp | 3 ++- src/gl/scene/gl_walls.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 9603cc858..dae203774 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -234,6 +234,7 @@ static void SpreadHackedFlag(subsector_t * sub) if (!(sub2->hacked&1) && sub2->render_sector == sub->render_sector) { sub2->hacked|=1; + sub->hacked &= ~4; SpreadHackedFlag (sub2); } } @@ -286,7 +287,7 @@ static void PrepareSectorData() subsectors[i].render_sector != seg[j].PartnerSeg->Subsector->render_sector) { DPrintf("Found hack: (%d,%d) (%d,%d)\n", seg[j].v1->x>>16, seg[j].v1->y>>16, seg[j].v2->x>>16, seg[j].v2->y>>16); - subsectors[i].hacked|=1; + subsectors[i].hacked|=5; SpreadHackedFlag(&subsectors[i]); } if (seg[j].PartnerSeg==NULL) subsectors[i].hacked|=2; // used for quick termination checks diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 84e7e5636..24c850112 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1441,7 +1441,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) sector_t * realback; #ifdef _DEBUG - if (seg->linedef-lines==636) + if (seg->linedef-lines==1276) { int a = 0; } @@ -1657,7 +1657,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) } else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) { - gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); + // skip processing if the back is a malformed subsector + if (!(seg->PartnerSeg->Subsector->hacked & 4)) + { + gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); + } } } } @@ -1726,7 +1730,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) else if (backsector->GetTexture(sector_t::floor)!=skyflatnum && !(seg->sidedef->Flags & WALLF_POLYOBJ)) { - gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); + // skip processing if the back is a malformed subsector + if (!(seg->PartnerSeg->Subsector->hacked & 4)) + { + gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); + } } } } From 25951362fc3522cf1d9224215a56b81587763a6e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 11 Sep 2014 13:02:39 +0200 Subject: [PATCH 2/5] - fixed: When applying Boom's Transfer_Heights effect to a sector, gl_FakeFlat needs to remove all portals from the original sector planes that are being replaced in the sector copy. --- src/gl/scene/gl_fakeflat.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp index d46449ddb..86408272a 100644 --- a/src/gl/scene/gl_fakeflat.cpp +++ b/src/gl/scene/gl_fakeflat.cpp @@ -311,6 +311,9 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakefloor]; dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::floor]; + + dest->portals[sector_t::ceiling] = NULL; + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) { dest->lightlevel = s->lightlevel; @@ -347,12 +350,12 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac } } } - else if (in_area==area_above) + else if (in_area == area_above) { - dest->ColorMap=s->ColorMap; + dest->ColorMap = s->ColorMap; dest->SetPlaneTexZ(sector_t::ceiling, sec->GetPlaneTexZ(sector_t::ceiling)); dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::ceiling)); - dest->ceilingplane= sec->ceilingplane; + dest->ceilingplane = sec->ceilingplane; dest->floorplane = s->ceilingplane; dest->floorplane.FlipVert(); @@ -362,6 +365,8 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::ceiling]; dest->vboheight[sector_t::ceiling] = sec->vboheight[sector_t::ceiling]; + dest->portals[sector_t::floor] = NULL; + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) { dest->lightlevel = s->lightlevel; From 0223b7f4601e0018c8479394108ee0f86dae8244 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Fri, 12 Sep 2014 00:39:36 -0400 Subject: [PATCH 3/5] - Fixed: InInventory didn't work quite right with multiple items. --- src/g_shared/sbarinfo_commands.cpp | 43 ++++++------------------------ 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index c9011e851..26dfa0d96 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -3383,43 +3383,16 @@ class CommandInInventory : public SBarInfoCommandFlowControl AInventory *invItem[2] = { statusBar->CPlayer->mo->FindInventory(item[0]), statusBar->CPlayer->mo->FindInventory(item[1]) }; if (invItem[0] != NULL && amount[0] > 0 && invItem[0]->Amount < amount[0]) invItem[0] = NULL; if (invItem[1] != NULL && amount[1] > 0 && invItem[1]->Amount < amount[1]) invItem[1] = NULL; - if(invItem[1] != NULL && conditionAnd) + + if (item[1]) { - if((invItem[0] != NULL && invItem[1] != NULL) && !negate) - { - SetTruth(true, block, statusBar); - return; - } - else if((invItem[0] == NULL || invItem[1] == NULL) && negate) - { - SetTruth(true, block, statusBar); - return; - } + if (conditionAnd) + SetTruth((invItem[0] && invItem[1]) != negate, block, statusBar); + else + SetTruth((invItem[0] || invItem[1]) != negate, block, statusBar); } - else if(invItem[1] != NULL && !conditionAnd) - { - if((invItem[0] != NULL || invItem[1] != NULL) && !negate) - { - SetTruth(true, block, statusBar); - return; - } - else if((invItem[0] == NULL && invItem[1] == NULL) && negate) - { - SetTruth(true, block, statusBar); - return; - } - } - else if((invItem[0] != NULL) && !negate) - { - SetTruth(true, block, statusBar); - return; - } - else if((invItem[0] == NULL) && negate) - { - SetTruth(true, block, statusBar); - return; - } - SetTruth(false, block, statusBar); + else + SetTruth((invItem[0] != NULL) != negate, block, statusBar); } protected: bool conditionAnd; From 27ebfa783e99559ce855a6c1feeb83ff9446d5ac Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Fri, 12 Sep 2014 00:49:09 -0400 Subject: [PATCH 4/5] - Added IfHealth based on Blue Shadow's patch. --- src/g_shared/sbarinfo_commands.cpp | 45 ++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index 26dfa0d96..ce94b2bc2 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -3431,6 +3431,46 @@ class CommandAlpha : public SBarInfoMainBlock //////////////////////////////////////////////////////////////////////////////// +class CommandIfHealth : public SBarInfoCommandFlowControl +{ + public: + CommandIfHealth(SBarInfo *script) : SBarInfoCommandFlowControl(script), + negate(false), percentage(false) + { + } + + void Parse(FScanner &sc, bool fullScreenOffsets) + { + if (sc.CheckToken(TK_Identifier)) + { + if (sc.Compare("not")) + negate = true; + else + sc.ScriptError("Expected 'not', but got '%s' instead.", sc.String); + } + + sc.MustGetToken(TK_IntConst); + percentage = sc.CheckToken('%'); + hpamount = sc.Number; + + SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets); + } + void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) + { + SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); + + int phealth = percentage ? statusBar->CPlayer->mo->health * 100 / statusBar->CPlayer->mo->GetMaxHealth() : statusBar->CPlayer->mo->health; + + SetTruth((phealth >= hpamount) ^ negate, block, statusBar); + } + protected: + bool negate; + bool percentage; + int hpamount; +}; + +//////////////////////////////////////////////////////////////////////////////// + static const char *SBarInfoCommandNames[] = { "drawimage", "drawnumber", "drawswitchableimage", @@ -3440,7 +3480,7 @@ static const char *SBarInfoCommandNames[] = "gamemode", "playerclass", "playertype", "aspectratio", "isselected", "usesammo", "usessecondaryammo", "hasweaponpiece", "inventorybarnotvisible", - "weaponammo", "ininventory", "alpha", + "weaponammo", "ininventory", "alpha", "ifhealth", NULL }; @@ -3453,7 +3493,7 @@ enum SBarInfoCommands SBARINFO_GAMEMODE, SBARINFO_PLAYERCLASS, SBARINFO_PLAYERTYPE, SBARINFO_ASPECTRATIO, SBARINFO_ISSELECTED, SBARINFO_USESAMMO, SBARINFO_USESSECONDARYAMMO, SBARINFO_HASWEAPONPIECE, SBARINFO_INVENTORYBARNOTVISIBLE, - SBARINFO_WEAPONAMMO, SBARINFO_ININVENTORY, SBARINFO_ALPHA, + SBARINFO_WEAPONAMMO, SBARINFO_ININVENTORY, SBARINFO_ALPHA, SBARINFO_IFHEALTH, }; SBarInfoCommand *SBarInfoCommandFlowControl::NextCommand(FScanner &sc) @@ -3486,6 +3526,7 @@ SBarInfoCommand *SBarInfoCommandFlowControl::NextCommand(FScanner &sc) case SBARINFO_WEAPONAMMO: return new CommandWeaponAmmo(script); case SBARINFO_ININVENTORY: return new CommandInInventory(script); case SBARINFO_ALPHA: return new CommandAlpha(script); + case SBARINFO_IFHEALTH: return new CommandIfHealth(script); } sc.ScriptError("Unknown command '%s'.\n", sc.String); From a2c81f1ca9f067c3ac557b5fab079e62f07f3fb0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 12 Sep 2014 20:59:23 +0200 Subject: [PATCH 5/5] -fixed the file validity checks in MapData::GetChecksum. They need to be done per lump, because MapData::Seek can alter the FileReader being used for a specific lump. Even worse, the FileReader will be NULL when the function as it was is called for a map inside a Zip-file. --- src/p_setup.cpp | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index a6dbca868..6b5d9403f 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -537,34 +537,31 @@ void MapData::GetChecksum(BYTE cksum[16]) { MD5Context md5; - if (file != NULL) + if (isText) { - if (isText) + Seek(ML_TEXTMAP); + if (file != NULL) md5.Update(file, Size(ML_TEXTMAP)); + } + else + { + if (Size(ML_LABEL) != 0) { - Seek(ML_TEXTMAP); - md5.Update(file, Size(ML_TEXTMAP)); - } - else - { - if (Size(ML_LABEL) != 0) - { - Seek(ML_LABEL); - md5.Update(file, Size(ML_LABEL)); - } - Seek(ML_THINGS); - md5.Update(file, Size(ML_THINGS)); - Seek(ML_LINEDEFS); - md5.Update(file, Size(ML_LINEDEFS)); - Seek(ML_SIDEDEFS); - md5.Update(file, Size(ML_SIDEDEFS)); - Seek(ML_SECTORS); - md5.Update(file, Size(ML_SECTORS)); - } - if (HasBehavior) - { - Seek(ML_BEHAVIOR); - md5.Update(file, Size(ML_BEHAVIOR)); + Seek(ML_LABEL); + if (file != NULL) md5.Update(file, Size(ML_LABEL)); } + Seek(ML_THINGS); + if (file != NULL) md5.Update(file, Size(ML_THINGS)); + Seek(ML_LINEDEFS); + if (file != NULL) md5.Update(file, Size(ML_LINEDEFS)); + Seek(ML_SIDEDEFS); + if (file != NULL) md5.Update(file, Size(ML_SIDEDEFS)); + Seek(ML_SECTORS); + if (file != NULL) md5.Update(file, Size(ML_SECTORS)); + } + if (HasBehavior) + { + Seek(ML_BEHAVIOR); + if (file != NULL) md5.Update(file, Size(ML_BEHAVIOR)); } md5.Final(cksum); }