diff --git a/source/common/console/c_enginecmds.cpp b/source/common/console/c_enginecmds.cpp index 0af6f3b56..f4801879a 100644 --- a/source/common/console/c_enginecmds.cpp +++ b/source/common/console/c_enginecmds.cpp @@ -52,6 +52,7 @@ #include "version.h" #include "findfile.h" #include "md5.h" +#include "md4.h" extern FILE* Logfile; @@ -293,8 +294,8 @@ CCMD (md5sum) } for (int i = 1; i < argv.argc(); ++i) { - FileReader fr; - if (!fr.OpenFile(argv[i])) + FileReader fr = fileSystem.OpenFileReader(argv[i]); + if (!fr.isOpen()) { Printf("%s: %s\n", argv[i], strerror(errno)); } @@ -318,6 +319,33 @@ CCMD (md5sum) } } +CCMD(md4sum) +{ + if (argv.argc() < 2) + { + Printf("Usage: md4sum ...\n"); + } + for (int i = 1; i < argv.argc(); ++i) + { + FileReader fr = fileSystem.OpenFileReader(argv[i]); + if (!fr.isOpen()) + { + Printf("%s: %s\n", argv[i], strerror(errno)); + } + else + { + auto data = fr.Read(); + uint8_t digest[16]; + md4once(data.Data(), data.Size(), digest); + for (int j = 0; j < 16; ++j) + { + Printf("%02x", digest[j]); + } + Printf(" //*%s\n", argv[i]); + } + } +} + CCMD(printlocalized) { if (argv.argc() > 1) diff --git a/source/core/maphack.cpp b/source/core/maphack.cpp index 3a62a0821..39b78bbb3 100644 --- a/source/core/maphack.cpp +++ b/source/core/maphack.cpp @@ -37,6 +37,7 @@ #include "printf.h" static TArray usermaphacks; +TArray blockingpairs[MAXWALLS]; void AddUserMapHack(usermaphack_t& mhk) { @@ -45,7 +46,9 @@ void AddUserMapHack(usermaphack_t& mhk) static int32_t LoadMapHack(const char *filename) { - int32_t currentsprite = -1; + int currentsprite = -1; + int currentwall = -1; + int currentsector = -1; FScanner sc; int lump = fileSystem.FindFile(filename); @@ -68,8 +71,30 @@ static int32_t LoadMapHack(const char *filename) return true; }; + auto validateWall = [&]() + { + if (currentwall < 0) + { + sc.ScriptMessage("Using %s without a valid wall", token.GetChars()); + return false; + } + return true; + }; + + auto validateSector = [&]() + { + if (currentsector < 0) + { + sc.ScriptMessage("Using %s without a valid sector", token.GetChars()); + return false; + } + return true; + }; + if (sc.Compare("sprite")) { + currentwall = -1; + currentsector = -1; if (sc.CheckNumber()) { currentsprite = sc.Number; @@ -81,6 +106,127 @@ static int32_t LoadMapHack(const char *filename) } else currentsprite = -1; } + if (sc.Compare("wall")) + { + currentsprite = -1; + currentsector = -1; + if (sc.CheckNumber()) + { + currentwall = sc.Number; + if (currentwall < 0 || currentwall >= MAXWALLS) + { + sc.ScriptMessage("Invalid wall number %d", currentwall); + currentwall = -1; + } + } + else currentwall = -1; + } + if (sc.Compare("sector")) + { + currentsprite = -1; + currentwall = -1; + if (sc.CheckNumber()) + { + currentsector = sc.Number; + if (currentsector < 0 || currentsector >= MAXSECTORS) + { + sc.ScriptMessage("Invalid sector number %d", currentsector); + currentsector = -1; + } + } + else currentsector = -1; + } + else if (sc.Compare("blocks")) + { + if (sc.CheckNumber() && validateWall()) + { + blockingpairs[currentwall].Push(sc.Number); + } + } + else if (sc.Compare("picnum")) + { + if (sc.CheckNumber()) + { + if (currentwall != -1 && validateWall()) + { + wall[currentwall].picnum = sc.Number; + } + else if (currentsprite != -1 && validateSprite()) + { + sprite[currentsprite].picnum = sc.Number; + } + } + } + else if (sc.Compare("overpicnum")) + { + if (sc.CheckNumber() && validateWall()) + { + wall[currentwall].overpicnum = sc.Number; + } + } + else if (sc.Compare("overpicnum")) + { + if (sc.CheckNumber() && validateWall()) + { + wall[currentwall].overpicnum = sc.Number; + } + } + else if (sc.Compare("clearflags")) + { + if (currentsector != -1 && validateSector()) + { + sc.GetString(); + if (sc.Compare("floor") && sc.CheckNumber()) + { + sector[currentsector].floorstat &= ~sc.Number; + } + else if (sc.Compare("ceiling") && sc.CheckNumber()) + { + sector[currentsector].ceilingstat &= ~sc.Number; + } + else sc.ScriptError("Bad token %s", sc.String); + } + else if (sc.CheckNumber()) + { + if (currentwall != -1 && validateWall()) + { + wall[currentwall].cstat &= ~sc.Number; + } + else if (currentsprite != -1 && validateSprite()) + { + sprite[currentsprite].cstat &= ~sc.Number; + } + } + } + else if (sc.Compare("setflags")) + { + if (sc.CheckNumber()) + { + if (currentwall != -1 && validateWall()) + { + wall[currentwall].cstat |= sc.Number; + } + else if (currentsprite != -1 && validateSprite()) + { + sprite[currentsprite].cstat |= sc.Number; + } + } + } + else if (sc.Compare("lotag")) + { + if (sc.CheckNumber()) + { + if (currentwall != -1 && validateWall()) + { + wall[currentwall].lotag = sc.Number; + } + else if (currentsprite != -1 && validateSprite()) + { + sprite[currentsprite].lotag = sc.Number; + } + } + } + else if (sc.Compare("angleoff") || sc.Compare("angoff")) { if (sc.CheckNumber() && validateSprite()) @@ -201,6 +347,13 @@ static int32_t LoadMapHack(const char *filename) void G_LoadMapHack(const char* filename, const unsigned char* md4) { + for (auto& p : blockingpairs) p.Clear(); + FString internal = "engine/compatibility/"; + for (int j = 0; j < 16; ++j) + { + internal.AppendFormat("%02x", md4[j]); + } + LoadMapHack(internal + ".mhk"); FString hack = StripExtension(filename) + ".mhk"; if (LoadMapHack(hack)) diff --git a/source/core/maploader.cpp b/source/core/maploader.cpp index 2eed4b474..0693975d4 100644 --- a/source/core/maploader.cpp +++ b/source/core/maploader.cpp @@ -45,7 +45,6 @@ #include "sectorgeometry.h" #include "render.h" - static void ReadSectorV7(FileReader& fr, sectortype& sect) { sect.wallptr = fr.ReadInt16(); @@ -455,8 +454,6 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang, memcpy(wallbackup, wall, sizeof(wallbackup)); memcpy(sectorbackup, sector, sizeof(sectorbackup)); - - addBlockingPairs(); } diff --git a/source/core/rendering/scene/hw_bunchdrawer.cpp b/source/core/rendering/scene/hw_bunchdrawer.cpp index 0be90bfae..0033157a0 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.cpp +++ b/source/core/rendering/scene/hw_bunchdrawer.cpp @@ -44,27 +44,7 @@ #include "mapinfo.h" #include "gamecontrol.h" -TArray blockingpairs[MAXWALLS]; - -// temporary hack job to make Lunatic Fringe work while searching for a proper solution. -void addBlockingPairs() -{ - for (auto& p : blockingpairs) p.Clear(); - if (!isDuke()) return; - if (wall[682].sector == 151 && wall[683].sector == 151 && wall[684].sector == 151 && - wall[694].sector == 152 && wall[695].sector == 152 && wall[695].sector == 152 && - wall[755].sector == 158 && wall[756].sector == 158 && wall[757].sector == 158 && - wall[739].sector == 158 && wall[740].sector == 158 && wall[741].sector == 158) - { - for (int i = 755; i<=757; i++) blockingpairs[682].Push(i); - blockingpairs[683] = blockingpairs[682]; - blockingpairs[684] = blockingpairs[682]; - - for (int i = 739; i <= 741; i++) blockingpairs[694].Push(i); - blockingpairs[695] = blockingpairs[694]; - blockingpairs[696] = blockingpairs[694]; - } -} +extern TArray blockingpairs[MAXWALLS]; //========================================================================== // diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 0dd52e750..35c6094ef 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -344,21 +344,6 @@ void InitLevel(MapRecord *maprec) engineLoadBoard(maprec->fileName, SW_SHAREWARE ? 1 : 0, &Player[0].pos, &ang, &Player[0].cursectnum); currentLevel = maprec; - if (!maprec->labelName.CompareNoCase("$hidtemp") && !maprec->name.CompareNoCase("$TXTS_T_MAP10")) - { - // flip the inverted card reader in TD's level 10. - if (sprite[179].picnum == 1852 && sprite[179].cstat == 92) sprite[179].cstat &= ~12; - } - if (!maprec->labelName.CompareNoCase("$outpost") && !maprec->name.CompareNoCase("$TXTS_MAP09")) - { - // silence a misplaced and *very* annoying ambient sound. - if (sprite[442].picnum == ST1 && sprite[442].hitag == 1002 && sprite[442].lotag == 31) sprite[442].lotag = -1; - } - if (!maprec->labelName.CompareNoCase("$volcano") && !maprec->name.CompareNoCase("$TXTS_W_MAP10")) - { - // fix badly tagged sector that can glitch out. - if (sector[118].ceilingstat == 37 && sector[118].ceilingpicnum == 317) sector[118].ceilingstat &= ~CSTAT_SECTOR_SKY; - } SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); STAT_NewLevel(currentLevel->fileName); Player[0].angle.ang = buildang(ang); diff --git a/wadsrc/static/engine/compatibility/089c6aaf6ccde94b8dbd295e311df410.mhk b/wadsrc/static/engine/compatibility/089c6aaf6ccde94b8dbd295e311df410.mhk new file mode 100644 index 000000000..ed453bd2b --- /dev/null +++ b/wadsrc/static/engine/compatibility/089c6aaf6ccde94b8dbd295e311df410.mhk @@ -0,0 +1,10 @@ +// Route66's COFFIN.MAP contains one grossly broken mirror that has the mirror tile on all surrounding walls. +wall 657 overpicnum 0 +wall 665 overpicnum 0 +wall 663 overpicnum 0 +wall 680 overpicnum 0 +wall 679 overpicnum 0 +wall 678 overpicnum 0 +wall 1357 overpicnum 0 +wall 1358 overpicnum 0 +wall 1359 overpicnum 0 diff --git a/wadsrc/static/engine/compatibility/2bac4971499306ee6c86462e6a03dae8.mhk b/wadsrc/static/engine/compatibility/2bac4971499306ee6c86462e6a03dae8.mhk new file mode 100644 index 000000000..60e6334da --- /dev/null +++ b/wadsrc/static/engine/compatibility/2bac4971499306ee6c86462e6a03dae8.mhk @@ -0,0 +1,2 @@ +// bad sky setting in WT's $volcano.map (original version) +sector 118 clearflags ceiling 1 diff --git a/wadsrc/static/engine/compatibility/67207fb90130ad561479301c0970c7ba.mhk b/wadsrc/static/engine/compatibility/67207fb90130ad561479301c0970c7ba.mhk new file mode 100644 index 000000000..8242ad80c --- /dev/null +++ b/wadsrc/static/engine/compatibility/67207fb90130ad561479301c0970c7ba.mhk @@ -0,0 +1,2 @@ +// bad sky setting in WT's $volcano.map (fixed version) +sector 118 clearflags ceiling 1 diff --git a/wadsrc/static/engine/compatibility/b4ee363e9d15adc5c9becd01520acd23.mhk b/wadsrc/static/engine/compatibility/b4ee363e9d15adc5c9becd01520acd23.mhk new file mode 100644 index 000000000..8eb89748a --- /dev/null +++ b/wadsrc/static/engine/compatibility/b4ee363e9d15adc5c9becd01520acd23.mhk @@ -0,0 +1,3 @@ +// SW $outpost.map +// silence a misplaced and *very* annoying ambient sound. +sprite 442 lotag -1 diff --git a/wadsrc/static/engine/compatibility/d19081afa18bf00c9f151e51104358ee.mhk b/wadsrc/static/engine/compatibility/d19081afa18bf00c9f151e51104358ee.mhk new file mode 100644 index 000000000..aa907ad4d --- /dev/null +++ b/wadsrc/static/engine/compatibility/d19081afa18bf00c9f151e51104358ee.mhk @@ -0,0 +1,7 @@ +// Lunatic Fringe v1.3 + v1.5 +wall 682 blocks 755 blocks 756 blocks 757 +wall 683 blocks 755 blocks 756 blocks 757 +wall 684 blocks 755 blocks 756 blocks 757 +wall 694 blocks 739 blocks 740 blocks 741 +wall 695 blocks 739 blocks 740 blocks 741 +wall 696 blocks 739 blocks 740 blocks 741 diff --git a/wadsrc/static/engine/compatibility/dea84af1e11afd14e38a619728a5f57b.mhk b/wadsrc/static/engine/compatibility/dea84af1e11afd14e38a619728a5f57b.mhk new file mode 100644 index 000000000..f463fb0c5 --- /dev/null +++ b/wadsrc/static/engine/compatibility/dea84af1e11afd14e38a619728a5f57b.mhk @@ -0,0 +1,7 @@ +// Lunatic Fringe WT +wall 682 blocks 755 blocks 756 blocks 757 +wall 683 blocks 755 blocks 756 blocks 757 +wall 684 blocks 755 blocks 756 blocks 757 +wall 694 blocks 739 blocks 740 blocks 741 +wall 695 blocks 739 blocks 740 blocks 741 +wall 696 blocks 739 blocks 740 blocks 741 diff --git a/wadsrc/static/engine/compatibility/ef6331237eb36c84a4f7b9f5c3cd225d.mhk b/wadsrc/static/engine/compatibility/ef6331237eb36c84a4f7b9f5c3cd225d.mhk new file mode 100644 index 000000000..dd4806a2d --- /dev/null +++ b/wadsrc/static/engine/compatibility/ef6331237eb36c84a4f7b9f5c3cd225d.mhk @@ -0,0 +1,2 @@ +// flip the inverted card reader in TD's level 10. +sprite 179 clearflags 12