mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- some improvements to compatibility scripts:
* use names, not strings, to allow use of switch/case. * avoid creating the checksum a second time per level. * do an early-out check for maps that do not have scripted compatibility.
This commit is contained in:
parent
640948703f
commit
9daad477c3
4 changed files with 44 additions and 32 deletions
|
@ -466,7 +466,7 @@ void ParseCompatibility()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void CheckCompatibility(MapData *map)
|
||||
FName CheckCompatibility(MapData *map)
|
||||
{
|
||||
FMD5Holder md5;
|
||||
FCompatValues *flags;
|
||||
|
@ -489,13 +489,16 @@ void CheckCompatibility(MapData *map)
|
|||
|
||||
flags = BCompatMap.CheckKey(md5);
|
||||
|
||||
FString hash;
|
||||
|
||||
for (size_t j = 0; j < sizeof(md5.Bytes); ++j)
|
||||
{
|
||||
hash.AppendFormat("%02X", md5.Bytes[j]);
|
||||
}
|
||||
|
||||
if (developer >= DMSG_NOTIFY)
|
||||
{
|
||||
Printf("MD5 = ");
|
||||
for (size_t j = 0; j < sizeof(md5.Bytes); ++j)
|
||||
{
|
||||
Printf("%02X", md5.Bytes[j]);
|
||||
}
|
||||
Printf("MD5 = %s", hash.GetChars());
|
||||
if (flags != NULL)
|
||||
{
|
||||
Printf(", cflags = %08x, cflags2 = %08x, bflags = %08x\n",
|
||||
|
@ -523,6 +526,7 @@ void CheckCompatibility(MapData *map)
|
|||
{
|
||||
ib_compatflags |= BCOMPATF_FLOATBOB;
|
||||
}
|
||||
return FName(hash, true); // if this returns NAME_None it means there is no scripted compatibility handler.
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -531,15 +535,19 @@ void CheckCompatibility(MapData *map)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SetCompatibilityParams()
|
||||
void SetCompatibilityParams(FName checksum)
|
||||
{
|
||||
PClass *const cls = PClass::FindClass("LevelCompatibility");
|
||||
if (cls != nullptr)
|
||||
if (checksum != NAME_None)
|
||||
{
|
||||
PFunction *const func = dyn_cast<PFunction>(cls->FindSymbol("Apply", true));
|
||||
if (func != nullptr)
|
||||
PClass *const cls = PClass::FindClass("LevelCompatibility");
|
||||
if (cls != nullptr)
|
||||
{
|
||||
VMCall(func->Variants[0].Implementation, nullptr, 0, nullptr, 0);
|
||||
PFunction *const func = dyn_cast<PFunction>(cls->FindSymbol("Apply", true));
|
||||
if (func != nullptr)
|
||||
{
|
||||
VMValue param = { (int)checksum };
|
||||
VMCall(func->Variants[0].Implementation, ¶m, 1, nullptr, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ struct FMD5HashTraits
|
|||
extern TMap<FMD5Holder, FCompatValues, FMD5HashTraits> BCompatMap;
|
||||
|
||||
void ParseCompatibility();
|
||||
void CheckCompatibility(MapData *map);
|
||||
void SetCompatibilityParams();
|
||||
FName CheckCompatibility(MapData *map);
|
||||
void SetCompatibilityParams(FName);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3756,7 +3756,7 @@ void P_SetupLevel (const char *lumpname, int position)
|
|||
{
|
||||
level.maptype = MAPTYPE_UDMF;
|
||||
}
|
||||
CheckCompatibility(map);
|
||||
FName checksum = CheckCompatibility(map);
|
||||
if (ib_compatflags & BCOMPATF_REBUILDNODES)
|
||||
{
|
||||
ForceNodeBuild = true;
|
||||
|
@ -3834,7 +3834,7 @@ void P_SetupLevel (const char *lumpname, int position)
|
|||
times[0].Unclock();
|
||||
}
|
||||
|
||||
SetCompatibilityParams();
|
||||
SetCompatibilityParams(checksum);
|
||||
|
||||
times[6].Clock();
|
||||
P_LoopSidedefs (true);
|
||||
|
|
|
@ -1,24 +1,28 @@
|
|||
|
||||
class LevelCompatibility play
|
||||
{
|
||||
private static void Apply()
|
||||
private static void Apply(Name checksum)
|
||||
{
|
||||
string checksum = level.GetChecksum();
|
||||
|
||||
if ( checksum ~== "AB24AE6E2CB13CBDD04600A4D37F9189" // doom2.wad map02
|
||||
|| checksum ~== "1EC0AF1E3985650F0C9000319C599D0C") // doom2bfg.wad map02
|
||||
switch (checksum)
|
||||
{
|
||||
// Missing textures
|
||||
TextureID stone4 = TexMan.CheckForTexture("STONE4", TexMan.Type_Wall);
|
||||
SetWallTextureID(327, Line.front, Side.bottom, stone4);
|
||||
SetWallTextureID(328, Line.front, Side.bottom, stone4);
|
||||
SetWallTextureID(338, Line.front, Side.bottom, stone4);
|
||||
SetWallTextureID(339, Line.front, Side.bottom, stone4);
|
||||
}
|
||||
else if (checksum ~== "66C46385EB1A23D60839D1532522076B") // doom2.wad map08
|
||||
{
|
||||
// Missing texture
|
||||
SetWallTexture(101, Line.back, Side.top, "BRICK7");
|
||||
case 'AB24AE6E2CB13CBDD04600A4D37F9189': // doom2.wad map02
|
||||
case '1EC0AF1E3985650F0C9000319C599D0C': // doom2bfg.wad map02
|
||||
{
|
||||
// Missing textures
|
||||
TextureID stone4 = TexMan.CheckForTexture("STONE4", TexMan.Type_Wall);
|
||||
SetWallTextureID(327, Line.front, Side.bottom, stone4);
|
||||
SetWallTextureID(328, Line.front, Side.bottom, stone4);
|
||||
SetWallTextureID(338, Line.front, Side.bottom, stone4);
|
||||
SetWallTextureID(339, Line.front, Side.bottom, stone4);
|
||||
break;
|
||||
}
|
||||
|
||||
case '66C46385EB1A23D60839D1532522076B': // doom2.wad map08
|
||||
{
|
||||
// Missing texture
|
||||
SetWallTexture(101, Line.back, Side.top, "BRICK7");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue