From f2e373a7933e883cfdcf7a2560e2e5d77743625a Mon Sep 17 00:00:00 2001 From: Michael Maurer II <100047986+maiyuzhe@users.noreply.github.com> Date: Tue, 29 Aug 2023 00:12:56 +0000 Subject: [PATCH 1/4] Update ZoneBuilder.cpp for building CoDOL Maps AssetHandler::ModifyAsset checks the zone version and then applies a patch, this won't work with maps compiled with zonebuilder because the ff version is the same as other iw4 zones. Therefore the sortkey needs to be fixed when the map gets built instead of at runtime. --- src/Components/Modules/ZoneBuilder.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index 3bce1cb6..abee258a 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -259,6 +259,23 @@ namespace Components return false; } + //patch for codol maps dumped with zonetool, the FF version is changed, so the sortKey hack in AssetHandler::ModifyAsset won't work + if (type == Game::XAssetType::ASSET_TYPE_GFXWORLD) + { + if (assetHeader.gfxWorld->sortKeyDistortion == 44) + { + assetHeader.gfxWorld->sortKeyDistortion = 43; + } + } + //likewise if material's sortKey is 44, it needs to be changed to 43. + if (type == Game::XAssetType::ASSET_TYPE_MATERIAL) + { + if (assetHeader.material->info.sortKey == 44) + { + assetHeader.material->info.sortKey = 43; + } + } + Game::XAsset asset; asset.type = type; asset.header = assetHeader; From b0bb9e784384e9d028100636af04e98f06e71f57 Mon Sep 17 00:00:00 2001 From: Michael Maurer II <100047986+maiyuzhe@users.noreply.github.com> Date: Tue, 29 Aug 2023 20:06:11 +0000 Subject: [PATCH 2/4] Update ZoneBuilder.cpp --- src/Components/Modules/ZoneBuilder.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index abee258a..ce8d9e9c 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -266,6 +266,12 @@ namespace Components { assetHeader.gfxWorld->sortKeyDistortion = 43; } + //Absolutely necessary patch for later codol maps. prevents player models from glowing ridiculously + if (assetHeader.gfxWorld->heroOnlyLightCount > 0) + { + Logger::Print("Fixing heroOnlyLightCount...\n"); + assetHeader.gfxWorld->heroOnlyLightCount = 0; + } } //likewise if material's sortKey is 44, it needs to be changed to 43. if (type == Game::XAssetType::ASSET_TYPE_MATERIAL) From 896fd49cf744a046913f41180d07e64f7a21a706 Mon Sep 17 00:00:00 2001 From: Michael Maurer II <100047986+maiyuzhe@users.noreply.github.com> Date: Wed, 30 Aug 2023 03:55:35 +0000 Subject: [PATCH 3/4] Removed code --- src/Components/Modules/ZoneBuilder.cpp | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index ce8d9e9c..3bce1cb6 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -259,29 +259,6 @@ namespace Components return false; } - //patch for codol maps dumped with zonetool, the FF version is changed, so the sortKey hack in AssetHandler::ModifyAsset won't work - if (type == Game::XAssetType::ASSET_TYPE_GFXWORLD) - { - if (assetHeader.gfxWorld->sortKeyDistortion == 44) - { - assetHeader.gfxWorld->sortKeyDistortion = 43; - } - //Absolutely necessary patch for later codol maps. prevents player models from glowing ridiculously - if (assetHeader.gfxWorld->heroOnlyLightCount > 0) - { - Logger::Print("Fixing heroOnlyLightCount...\n"); - assetHeader.gfxWorld->heroOnlyLightCount = 0; - } - } - //likewise if material's sortKey is 44, it needs to be changed to 43. - if (type == Game::XAssetType::ASSET_TYPE_MATERIAL) - { - if (assetHeader.material->info.sortKey == 44) - { - assetHeader.material->info.sortKey = 43; - } - } - Game::XAsset asset; asset.type = type; asset.header = assetHeader; From 585074d03319e9b77800f63401cd85e25d74b34e Mon Sep 17 00:00:00 2001 From: Michael Maurer II <100047986+maiyuzhe@users.noreply.github.com> Date: Wed, 30 Aug 2023 03:59:21 +0000 Subject: [PATCH 4/4] Moved fixes into Zones.cpp Fixes that were previously being done through compiling with zonebuilder are now done when the map dumps. No longer dealing with the heroOnlyLights, only mp_abandon_sh_mk seems to have that problem and that map is done. --- src/Components/Modules/Zones.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index 89bb812a..f06153ed 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -1929,9 +1929,12 @@ namespace Components AssetHandler::Relocate(buffer + 0x20, buffer + 0x18, 0x30); AssetHandler::Relocate(buffer + 0x51, buffer + 0x48, 5); AssetHandler::Relocate(buffer + 0x58, buffer + 0x50, 0x10); - + + Game::Material* material = reinterpret_cast(buffer); // fix statebit - reinterpret_cast(buffer)->stateBitsEntry[47] = codol_material[0x50]; + material->stateBitsEntry[47] = codol_material[0x50]; + //check to fix distortion + if (material->info.sortKey == 44) material->info.sortKey = 43; } else if (Zones::ZoneVersion >= 359) { @@ -1975,6 +1978,9 @@ namespace Components // yes it was lol memcpy(&material->info.drawSurf.packed, material359.drawSurfBegin, 8); + //adding this here, situation as with later ff versions + if (material->info.sortKey == 44) material->info.sortKey = 43; + memcpy(&material->info.surfaceTypeBits, &material359.drawSurf[0], 6); // copies both surfaceTypeBits and hashIndex //material->drawSurf[8] = material359.drawSurf[0]; //material->drawSurf[9] = material359.drawSurf[1]; @@ -2025,6 +2031,9 @@ namespace Components int sunDiff = 8; // Stuff that is part of the sunflare we would overwrite std::memmove(buffer + 348 + sunDiff, buffer + 1316 + sunDiff, 280 - sunDiff); AssetHandler::Relocate(buffer + 1316, buffer + 348, 280); + + //all codol zones are like this pretty certain + reinterpret_cast(buffer)->sortKeyDistortion = 43; } return result;