mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-05 02:31:55 +00:00
refactor: refactor ZoneDefWriter
This commit is contained in:
@ -1,22 +1,16 @@
|
||||
#include "ZoneDefWriterIW3.h"
|
||||
|
||||
#include "Game/IW3/GameAssetPoolIW3.h"
|
||||
#include "Game/IW3/GameIW3.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
bool ZoneDefWriter::CanHandleZone(Zone* zone) const
|
||||
{
|
||||
return zone->m_game == &g_GameIW3;
|
||||
}
|
||||
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const {}
|
||||
|
||||
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const {}
|
||||
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const
|
||||
{
|
||||
const auto* pools = dynamic_cast<GameAssetPoolIW3*>(zone->m_pools.get());
|
||||
const auto* pools = dynamic_cast<GameAssetPoolIW3*>(zone.m_pools.get());
|
||||
|
||||
assert(pools);
|
||||
if (!pools)
|
||||
@ -24,9 +18,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Unlin
|
||||
|
||||
// Localized strings are all collected in one string file. So only add this to the zone file.
|
||||
if (!pools->m_localize->m_asset_lookup.empty())
|
||||
{
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone->m_name);
|
||||
}
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
|
||||
for (const auto& asset : *pools)
|
||||
{
|
||||
|
@ -7,10 +7,7 @@ namespace IW3
|
||||
class ZoneDefWriter final : public AbstractZoneDefWriter
|
||||
{
|
||||
protected:
|
||||
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override;
|
||||
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override;
|
||||
|
||||
public:
|
||||
bool CanHandleZone(Zone* zone) const override;
|
||||
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
|
||||
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
|
||||
};
|
||||
} // namespace IW3
|
||||
|
@ -1,22 +1,16 @@
|
||||
#include "ZoneDefWriterIW4.h"
|
||||
|
||||
#include "Game/IW4/GameAssetPoolIW4.h"
|
||||
#include "Game/IW4/GameIW4.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
bool ZoneDefWriter::CanHandleZone(Zone* zone) const
|
||||
{
|
||||
return zone->m_game == &g_GameIW4;
|
||||
}
|
||||
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const {}
|
||||
|
||||
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const {}
|
||||
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const
|
||||
{
|
||||
const auto* pools = dynamic_cast<GameAssetPoolIW4*>(zone->m_pools.get());
|
||||
const auto* pools = dynamic_cast<GameAssetPoolIW4*>(zone.m_pools.get());
|
||||
|
||||
assert(pools);
|
||||
if (!pools)
|
||||
@ -24,9 +18,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Unlin
|
||||
|
||||
// Localized strings are all collected in one string file. So only add this to the zone file.
|
||||
if (!pools->m_localize->m_asset_lookup.empty())
|
||||
{
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone->m_name);
|
||||
}
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
|
||||
for (const auto& asset : *pools)
|
||||
{
|
||||
|
@ -7,10 +7,7 @@ namespace IW4
|
||||
class ZoneDefWriter final : public AbstractZoneDefWriter
|
||||
{
|
||||
protected:
|
||||
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override;
|
||||
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override;
|
||||
|
||||
public:
|
||||
bool CanHandleZone(Zone* zone) const override;
|
||||
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
|
||||
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
|
||||
};
|
||||
} // namespace IW4
|
||||
|
@ -1,22 +1,16 @@
|
||||
#include "ZoneDefWriterIW5.h"
|
||||
|
||||
#include "Game/IW5/GameAssetPoolIW5.h"
|
||||
#include "Game/IW5/GameIW5.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
bool ZoneDefWriter::CanHandleZone(Zone* zone) const
|
||||
{
|
||||
return zone->m_game == &g_GameIW5;
|
||||
}
|
||||
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const {}
|
||||
|
||||
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const {}
|
||||
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const
|
||||
{
|
||||
const auto* pools = dynamic_cast<GameAssetPoolIW5*>(zone->m_pools.get());
|
||||
const auto* pools = dynamic_cast<GameAssetPoolIW5*>(zone.m_pools.get());
|
||||
|
||||
assert(pools);
|
||||
if (!pools)
|
||||
@ -24,9 +18,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Unlin
|
||||
|
||||
// Localized strings are all collected in one string file. So only add this to the zone file.
|
||||
if (!pools->m_localize->m_asset_lookup.empty())
|
||||
{
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone->m_name);
|
||||
}
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
|
||||
for (const auto& asset : *pools)
|
||||
{
|
||||
|
@ -7,10 +7,7 @@ namespace IW5
|
||||
class ZoneDefWriter final : public AbstractZoneDefWriter
|
||||
{
|
||||
protected:
|
||||
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override;
|
||||
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override;
|
||||
|
||||
public:
|
||||
bool CanHandleZone(Zone* zone) const override;
|
||||
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
|
||||
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
|
||||
};
|
||||
} // namespace IW5
|
||||
|
@ -1,22 +1,16 @@
|
||||
#include "ZoneDefWriterT5.h"
|
||||
|
||||
#include "Game/T5/GameAssetPoolT5.h"
|
||||
#include "Game/T5/GameT5.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace T5;
|
||||
|
||||
bool ZoneDefWriter::CanHandleZone(Zone* zone) const
|
||||
{
|
||||
return zone->m_game == &g_GameT5;
|
||||
}
|
||||
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const {}
|
||||
|
||||
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const {}
|
||||
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const
|
||||
{
|
||||
const auto* pools = dynamic_cast<GameAssetPoolT5*>(zone->m_pools.get());
|
||||
const auto* pools = dynamic_cast<GameAssetPoolT5*>(zone.m_pools.get());
|
||||
|
||||
assert(pools);
|
||||
if (!pools)
|
||||
@ -24,9 +18,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Unlin
|
||||
|
||||
// Localized strings are all collected in one string file. So only add this to the zone file.
|
||||
if (!pools->m_localize->m_asset_lookup.empty())
|
||||
{
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone->m_name);
|
||||
}
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
|
||||
for (const auto& asset : *pools)
|
||||
{
|
||||
|
@ -7,10 +7,7 @@ namespace T5
|
||||
class ZoneDefWriter final : public AbstractZoneDefWriter
|
||||
{
|
||||
protected:
|
||||
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override;
|
||||
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override;
|
||||
|
||||
public:
|
||||
bool CanHandleZone(Zone* zone) const override;
|
||||
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
|
||||
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
|
||||
};
|
||||
} // namespace T5
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/GameAssetPoolT6.h"
|
||||
#include "Game/T6/GameT6.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <iomanip>
|
||||
@ -10,7 +9,7 @@
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace T6
|
||||
namespace
|
||||
{
|
||||
class KeyValuePairKnownKey
|
||||
{
|
||||
@ -31,50 +30,43 @@ namespace T6
|
||||
KeyValuePairKnownKey("initial_xmodels"),
|
||||
KeyValuePairKnownKey("initial_materials"),
|
||||
};
|
||||
} // namespace T6
|
||||
|
||||
bool ZoneDefWriter::CanHandleZone(Zone* zone) const
|
||||
{
|
||||
return zone->m_game == &g_GameT6;
|
||||
}
|
||||
|
||||
void ZoneDefWriter::WriteKeyValuePair(ZoneDefinitionOutputStream& stream, KeyValuePair* kvp)
|
||||
{
|
||||
for (const auto& knownKey : KEY_VALUE_PAIR_KNOWN_KEYS)
|
||||
void WriteKeyValuePair(ZoneDefinitionOutputStream& stream, const KeyValuePair& kvp)
|
||||
{
|
||||
if (knownKey.m_hash == kvp->keyHash)
|
||||
for (const auto& knownKey : KEY_VALUE_PAIR_KNOWN_KEYS)
|
||||
{
|
||||
stream.WriteMetaData("level." + knownKey.m_key, kvp->value);
|
||||
return;
|
||||
if (knownKey.m_hash == kvp.keyHash)
|
||||
{
|
||||
stream.WriteMetaData("level." + knownKey.m_key, kvp.value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream str;
|
||||
str << "level.@" << std::setfill('0') << std::setw(sizeof(int) * 2) << std::hex << kvp.keyHash;
|
||||
stream.WriteMetaData(str.str(), kvp.value);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::ostringstream str;
|
||||
str << "level.@" << std::setfill('0') << std::setw(sizeof(int) * 2) << std::hex << kvp->keyHash;
|
||||
stream.WriteMetaData(str.str(), kvp->value);
|
||||
}
|
||||
|
||||
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const
|
||||
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const
|
||||
{
|
||||
auto* assetPoolT6 = dynamic_cast<GameAssetPoolT6*>(zone->m_pools.get());
|
||||
const auto* assetPoolT6 = dynamic_cast<GameAssetPoolT6*>(zone.m_pools.get());
|
||||
if (assetPoolT6 && !assetPoolT6->m_key_value_pairs->m_asset_lookup.empty())
|
||||
{
|
||||
for (const auto* kvpAsset : *assetPoolT6->m_key_value_pairs)
|
||||
{
|
||||
const auto* keyValuePairs = kvpAsset->Asset();
|
||||
for (auto varIndex = 0; varIndex < keyValuePairs->numVariables; varIndex++)
|
||||
{
|
||||
WriteKeyValuePair(stream, &keyValuePairs->keyValuePairs[varIndex]);
|
||||
}
|
||||
WriteKeyValuePair(stream, keyValuePairs->keyValuePairs[varIndex]);
|
||||
}
|
||||
|
||||
stream.EmptyLine();
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const
|
||||
{
|
||||
const auto* pools = dynamic_cast<GameAssetPoolT6*>(zone->m_pools.get());
|
||||
const auto* pools = dynamic_cast<GameAssetPoolT6*>(zone.m_pools.get());
|
||||
|
||||
assert(pools);
|
||||
if (!pools)
|
||||
@ -82,9 +74,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Unlin
|
||||
|
||||
// Localized strings are all collected in one string file. So only add this to the zone file.
|
||||
if (!pools->m_localize->m_asset_lookup.empty())
|
||||
{
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone->m_name);
|
||||
}
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
|
||||
for (const auto& asset : *pools)
|
||||
{
|
||||
|
@ -1,19 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "ContentLister/ZoneDefWriter.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class ZoneDefWriter final : public AbstractZoneDefWriter
|
||||
{
|
||||
static void WriteKeyValuePair(ZoneDefinitionOutputStream& stream, KeyValuePair* kvp);
|
||||
|
||||
protected:
|
||||
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override;
|
||||
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override;
|
||||
|
||||
public:
|
||||
bool CanHandleZone(Zone* zone) const override;
|
||||
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
|
||||
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
|
||||
};
|
||||
} // namespace T6
|
||||
|
Reference in New Issue
Block a user