Small change

This commit is contained in:
fed 2022-09-20 19:26:23 +02:00
parent 86e4020b6d
commit 2fdb27e872

View File

@ -380,21 +380,20 @@ namespace mapents
return; return;
} }
static const auto mapname = game::Dvar_FindVar("mapname"); fastfiles::enum_assets(game::ASSET_TYPE_MAP_ENTS, [](game::XAssetHeader header)
const auto name = utils::string::va("maps/%s.d3dbsp", mapname->current.string);
const auto mapents = game::DB_FindXAssetHeader(game::ASSET_TYPE_MAP_ENTS,
name, false).mapents;
if (mapents == nullptr)
{ {
console::info("Failed to dump mapents\n"); if (header.mapents == nullptr)
return; {
} console::info("Failed to dump mapents\n");
return;
}
const auto dest = utils::string::va("dumps/%s.ents", name); const auto dest = utils::string::va("dumps/%s.ents", header.mapents->name);
const auto str = std::string(mapents->entityString, mapents->numEntityChars); const auto str = std::string(header.mapents->entityString, header.mapents->numEntityChars);
const auto data = replace_mapents_keys(str); const auto data = replace_mapents_keys(str);
utils::io::write_file(dest, data, false); utils::io::write_file(dest, data, false);
console::info("Mapents dumped to %s\n", dest); console::info("Mapents dumped to %s\n", dest);
}, true);
}); });
utils::hook::call(0x14058BDD3, db_find_xasset_header_stub); utils::hook::call(0x14058BDD3, db_find_xasset_header_stub);