Merge pull request #125 from Rackover/fix_wrong_assets_on_ported_maps

Allow loading assets from disk even if they're already in memory
This commit is contained in:
Louve 2021-09-16 10:32:17 +02:00 committed by GitHub
commit 1f148986fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 6 deletions

View File

@ -41,13 +41,12 @@ namespace Assets
{"wc_unlit_falloff_add", "wc_unlit_falloff_add_lin_ua"}, {"wc_unlit_falloff_add", "wc_unlit_falloff_add_lin_ua"},
{"wc_unlit", "wc_unlit_replace_lin"}, {"wc_unlit", "wc_unlit_replace_lin"},
{"wc_unlit_alphatest", "wc_unlit_blend_lin"}, {"wc_unlit_alphatest", "wc_unlit_blend_lin"},
{"wc_unlit_multiply_lin", "wc_unlit_multiply_lin"},
{"wc_unlit_blend", "wc_unlit_blend_lin_ua"}, {"wc_unlit_blend", "wc_unlit_blend_lin_ua"},
{"wc_unlit_replace", "wc_unlit_replace_lin"}, {"wc_unlit_replace", "wc_unlit_replace_lin"},
{"mc_unlit_replace", "mc_unlit_replace_lin"}, {"mc_unlit_replace", "mc_unlit_replace_lin"},
{"mc_unlit_nofog", "mc_unlit_blend_nofog_ua"}, {"mc_unlit_nofog", "mc_unlit_blend_nofog_ua"},
{"mc_unlit", "mc_unlit_blend_lin"}, {"mc_unlit", "mc_unlit_replace_lin_nocast"},
{"mc_unlit_alphatest", "mc_unlit_blend_lin"} {"mc_unlit_alphatest", "mc_unlit_blend_lin"}
/*, /*,
{"", ""}, {"", ""},
@ -196,7 +195,7 @@ namespace Assets
std::memcpy(asset->stateBitsEntry, header.material->stateBitsEntry, 48); std::memcpy(asset->stateBitsEntry, header.material->stateBitsEntry, 48);
asset->constantCount = header.material->constantCount; asset->constantCount = header.material->constantCount;
asset->constantTable = header.material->constantTable; asset->constantTable = header.material->constantTable;
Components::Logger::Print("For %s, copied constants & statebits from %s\n", asset->info.name, header.material->info.name);
replacementFound = true; replacementFound = true;
} }
} }

View File

@ -84,13 +84,14 @@ namespace Assets
void IXModel::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) void IXModel::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{ {
if (!builder->isPrimaryAsset()) Components::FileSystem::File modelFile(Utils::String::VA("xmodel/%s.iw4xModel", name.data()));
if (!builder->isPrimaryAsset() && (!Components::ZoneBuilder::PreferDiskAssetsDvar.get<bool>() || !modelFile.exists()))
{ {
header->model = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).model; header->model = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).model;
if (header->model) return; if (header->model) return;
} }
Components::FileSystem::File modelFile(Utils::String::VA("xmodel/%s.iw4xModel", name.data()));
if (modelFile.exists()) if (modelFile.exists())
{ {

View File

@ -771,7 +771,7 @@ namespace Components
Maps::AddDlc({ 6, "Freighter", {"mp_cargoship_sh"} }); Maps::AddDlc({ 6, "Freighter", {"mp_cargoship_sh"} });
Maps::AddDlc({ 7, "Resurrection Pack", {"mp_shipment_long", "mp_rust_long", "mp_firingrange"} }); Maps::AddDlc({ 7, "Resurrection Pack", {"mp_shipment_long", "mp_rust_long", "mp_firingrange"} });
Maps::AddDlc({ 8, "Recycled Pack", {"mp_bloc_sh", "mp_crash_tropical", "mp_estate_tropical", "mp_fav_tropical", "mp_storm_spring"} }); Maps::AddDlc({ 8, "Recycled Pack", {"mp_bloc_sh", "mp_crash_tropical", "mp_estate_tropical", "mp_fav_tropical", "mp_storm_spring"} });
Maps::AddDlc({ 9, "Classics Pack #3", {"mp_farm", "mp_backlot", "mp_pipeline", "mp_countdown", "mp_crash_snow"} }); Maps::AddDlc({ 9, "Classics Pack #3", {"mp_farm", "mp_backlot", "mp_pipeline", "mp_countdown", "mp_crash_snow", "mp_carentan"}});
Maps::UpdateDlcStatus(); Maps::UpdateDlcStatus();

View File

@ -10,6 +10,8 @@ namespace Components
bool ZoneBuilder::Terminate; bool ZoneBuilder::Terminate;
std::thread ZoneBuilder::CommandThread; std::thread ZoneBuilder::CommandThread;
Dvar::Var ZoneBuilder::PreferDiskAssetsDvar;
ZoneBuilder::Zone::Zone(const std::string& name) : indexStart(0), externalSize(0), ZoneBuilder::Zone::Zone(const std::string& name) : indexStart(0), externalSize(0),
// Reserve 100MB by default. // Reserve 100MB by default.
@ -1522,6 +1524,8 @@ namespace Components
Logger::Print("%s\n", json11::Json(images).dump().data()); Logger::Print("%s\n", json11::Json(images).dump().data());
Logger::Print("------------------- END IWI DUMP -------------------\n"); Logger::Print("------------------- END IWI DUMP -------------------\n");
}); });
ZoneBuilder::PreferDiskAssetsDvar = Dvar::Register<bool>("zb_prefer_disk_assets", false, Game::DVAR_FLAG_NONE, "Should zonebuilder prefer in-memory assets (requirements) or disk assets, when both are present?");
} }
} }

View File

@ -130,6 +130,7 @@ namespace Components
static std::vector<std::pair<Game::XAssetType, std::string>> EndAssetTrace(); static std::vector<std::pair<Game::XAssetType, std::string>> EndAssetTrace();
static Game::XAssetHeader GetEmptyAssetIfCommon(Game::XAssetType type, const std::string& name, Zone* builder); static Game::XAssetHeader GetEmptyAssetIfCommon(Game::XAssetType type, const std::string& name, Zone* builder);
static Dvar::Var PreferDiskAssetsDvar;
private: private:
static int StoreTexture(Game::GfxImageLoadDef **loadDef, Game::GfxImage *image); static int StoreTexture(Game::GfxImageLoadDef **loadDef, Game::GfxImage *image);