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);
|
||||
|
||||
if (developer >= DMSG_NOTIFY)
|
||||
{
|
||||
Printf("MD5 = ");
|
||||
FString hash;
|
||||
|
||||
for (size_t j = 0; j < sizeof(md5.Bytes); ++j)
|
||||
{
|
||||
Printf("%02X", md5.Bytes[j]);
|
||||
hash.AppendFormat("%02X", md5.Bytes[j]);
|
||||
}
|
||||
|
||||
if (developer >= DMSG_NOTIFY)
|
||||
{
|
||||
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,7 +535,9 @@ void CheckCompatibility(MapData *map)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SetCompatibilityParams()
|
||||
void SetCompatibilityParams(FName checksum)
|
||||
{
|
||||
if (checksum != NAME_None)
|
||||
{
|
||||
PClass *const cls = PClass::FindClass("LevelCompatibility");
|
||||
if (cls != nullptr)
|
||||
|
@ -539,7 +545,9 @@ void SetCompatibilityParams()
|
|||
PFunction *const func = dyn_cast<PFunction>(cls->FindSymbol("Apply", true));
|
||||
if (func != nullptr)
|
||||
{
|
||||
VMCall(func->Variants[0].Implementation, nullptr, 0, nullptr, 0);
|
||||
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,12 +1,12 @@
|
|||
|
||||
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)
|
||||
{
|
||||
case 'AB24AE6E2CB13CBDD04600A4D37F9189': // doom2.wad map02
|
||||
case '1EC0AF1E3985650F0C9000319C599D0C': // doom2bfg.wad map02
|
||||
{
|
||||
// Missing textures
|
||||
TextureID stone4 = TexMan.CheckForTexture("STONE4", TexMan.Type_Wall);
|
||||
|
@ -14,11 +14,15 @@ class LevelCompatibility play
|
|||
SetWallTextureID(328, Line.front, Side.bottom, stone4);
|
||||
SetWallTextureID(338, Line.front, Side.bottom, stone4);
|
||||
SetWallTextureID(339, Line.front, Side.bottom, stone4);
|
||||
break;
|
||||
}
|
||||
else if (checksum ~== "66C46385EB1A23D60839D1532522076B") // doom2.wad map08
|
||||
|
||||
case '66C46385EB1A23D60839D1532522076B': // doom2.wad map08
|
||||
{
|
||||
// Missing texture
|
||||
SetWallTexture(101, Line.back, Side.top, "BRICK7");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue