mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- offloaded map patches to data files.
This is a lot easier to manage than having them in the code. For now it piggybacks on the map hack feature, later this should use the same scripted approach as GZDoom.
This commit is contained in:
parent
a7046eaee4
commit
ad28630df6
12 changed files with 218 additions and 42 deletions
|
@ -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 <file> ...\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)
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "printf.h"
|
||||
|
||||
static TArray<usermaphack_t> usermaphacks;
|
||||
TArray<int> 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))
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,27 +44,7 @@
|
|||
#include "mapinfo.h"
|
||||
#include "gamecontrol.h"
|
||||
|
||||
TArray<int> 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<int> blockingpairs[MAXWALLS];
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
|
@ -0,0 +1,2 @@
|
|||
// bad sky setting in WT's $volcano.map (original version)
|
||||
sector 118 clearflags ceiling 1
|
|
@ -0,0 +1,2 @@
|
|||
// bad sky setting in WT's $volcano.map (fixed version)
|
||||
sector 118 clearflags ceiling 1
|
|
@ -0,0 +1,3 @@
|
|||
// SW $outpost.map
|
||||
// silence a misplaced and *very* annoying ambient sound.
|
||||
sprite 442 lotag -1
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,2 @@
|
|||
// flip the inverted card reader in TD's level 10.
|
||||
sprite 179 clearflags 12
|
Loading…
Reference in a new issue