Fixes + add a gsc func

This commit is contained in:
fed 2023-06-24 04:41:54 +02:00
parent 3c4c239cfe
commit aa8e030ed2
2 changed files with 29 additions and 1 deletions

View File

@ -146,7 +146,10 @@ namespace fastfiles
{ {
if (priority == mods::zone_priority::post_common) if (priority == mods::zone_priority::post_common)
{ {
try_add_zone(zones, allocator, "mod", true); if (mods::get_mod().has_value())
{
try_add_zone(zones, allocator, "mod", true);
}
} }
const auto mod_zones = mods::get_mod_zones(); const auto mod_zones = mods::get_mod_zones();

View File

@ -484,6 +484,31 @@ namespace gsc
table.clear(); table.clear();
}); });
}); });
add_function("assetexists", []()
{
const std::string type = game::Scr_GetString(0);
const auto name = game::Scr_GetString(1);
game::XAssetType type_index = game::ASSET_TYPE_COUNT;
for (auto i = 0; i < ::game::XAssetType::ASSET_TYPE_COUNT; i++)
{
if (type == ::game::g_assetNames[i])
{
type_index = static_cast<game::XAssetType>(i);
}
}
if (type_index == game::ASSET_TYPE_COUNT)
{
return scr_error(true, "invalid asset type %s", type.data());
}
const auto result = game::DB_XAssetExists(type_index, name) &&
!game::DB_IsXAssetDefault(type_index, name);
game::Scr_AddInt(result);
});
} }
}; };
} }