2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-07 17:27:26 +00:00

Save scriptstrings per zone and not per asset since that solves all problems with multiple assets of the same zone referencing the same struct in memory that has scriptstring indices

This commit is contained in:
Jan
2020-10-23 15:54:27 +02:00
parent f8e7a10789
commit eed7164b5b
36 changed files with 387 additions and 447 deletions

View File

@@ -97,12 +97,12 @@ const std::string GameAssetPoolIW4::ASSET_TYPE_NAMES[]
ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts, m_addon_map_ents
*/
GameAssetPoolIW4::GameAssetPoolIW4(const int priority)
GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const int priority)
: ZoneAssetPools(zone),
m_priority(priority)
{
assert(_countof(ASSET_TYPE_NAMES) == ASSET_TYPE_COUNT);
m_priority = priority;
m_phys_preset = nullptr;
m_phys_collmap = nullptr;
m_xanim_parts = nullptr;
@@ -258,9 +258,7 @@ void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type)
#undef CASE_INIT_POOL_STATIC
}
XAssetInfoGeneric* GameAssetPoolIW4::AddAsset(asset_type_t type, std::string name, void* asset,
std::vector<std::string>& scriptStrings,
std::vector<XAssetInfoGeneric*>& dependencies)
XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*>& dependencies)
{
XAsset xAsset{};
@@ -271,7 +269,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::AddAsset(asset_type_t type, std::string nam
case assetType: \
{ \
assert((poolName) != nullptr); \
auto* assetInfo = (poolName)->AddAsset(std::move(name), xAsset.header.headerName, scriptStrings, dependencies); \
auto* assetInfo = (poolName)->AddAsset(std::move(name), xAsset.header.headerName, m_zone, dependencies); \
if(assetInfo) \
{ \
m_assets_in_order.push_back(assetInfo); \
@@ -394,13 +392,3 @@ const std::string& GameAssetPoolIW4::GetAssetTypeName(const asset_type_t assetTy
return ASSET_TYPE_INVALID;
}
IZoneAssetPools::iterator GameAssetPoolIW4::begin() const
{
return m_assets_in_order.begin();
}
IZoneAssetPools::iterator GameAssetPoolIW4::end() const
{
return m_assets_in_order.end();
}

View File

@@ -2,18 +2,20 @@
#include <memory>
#include "Pool/IZoneAssetPools.h"
#include "Pool/ZoneAssetPools.h"
#include "Pool/AssetPool.h"
#include "IW4.h"
class GameAssetPoolIW4 final : public IZoneAssetPools
class GameAssetPoolIW4 final : public ZoneAssetPools
{
int m_priority;
std::vector<XAssetInfoGeneric*> m_assets_in_order;
static const std::string ASSET_TYPE_INVALID;
static const std::string ASSET_TYPE_NAMES[];
protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*>& dependencies) override;
public:
std::unique_ptr<AssetPool<IW4::PhysPreset>> m_phys_preset;
std::unique_ptr<AssetPool<IW4::PhysCollmap>> m_phys_collmap;
@@ -51,18 +53,12 @@ public:
std::unique_ptr<AssetPool<IW4::VehicleDef>> m_vehicle;
std::unique_ptr<AssetPool<IW4::AddonMapEnts>> m_addon_map_ents;
explicit GameAssetPoolIW4(int priority);
GameAssetPoolIW4(Zone* zone, int priority);
~GameAssetPoolIW4() override = default;
void InitPoolStatic(asset_type_t type, size_t capacity) override;
void InitPoolDynamic(asset_type_t type) override;
XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset,
std::vector<std::string>& scriptStrings,
std::vector<XAssetInfoGeneric*>& dependencies) override;
XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override;
const std::string& GetAssetTypeName(asset_type_t assetType) const override;
iterator begin() const override;
iterator end() const override;
};