diff --git a/src/compatibility.cpp b/src/compatibility.cpp index 7be7b4237c..52eb3aac40 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -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(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(cls->FindSymbol("Apply", true)); + if (func != nullptr) + { + VMValue param = { (int)checksum }; + VMCall(func->Variants[0].Implementation, ¶m, 1, nullptr, 0); + } } } diff --git a/src/compatibility.h b/src/compatibility.h index 125f83f34c..e219f5d0a0 100644 --- a/src/compatibility.h +++ b/src/compatibility.h @@ -36,7 +36,7 @@ struct FMD5HashTraits extern TMap BCompatMap; void ParseCompatibility(); -void CheckCompatibility(MapData *map); -void SetCompatibilityParams(); +FName CheckCompatibility(MapData *map); +void SetCompatibilityParams(FName); #endif diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 648502542a..6f84da6d96 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -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); diff --git a/wadsrc/static/zscript/level_compatibility.txt b/wadsrc/static/zscript/level_compatibility.txt index 17bddba134..7b446370a9 100644 --- a/wadsrc/static/zscript/level_compatibility.txt +++ b/wadsrc/static/zscript/level_compatibility.txt @@ -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; + } } }