mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-11-23 05:12:05 +00:00
Added map type metadata parsing to zone file
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
#include "SequenceZoneDefinitionMetaData.h"
|
#include "SequenceZoneDefinitionMetaData.h"
|
||||||
|
|
||||||
#include "Utils/Logging/Log.h"
|
#include "Utils/Logging/Log.h"
|
||||||
#include "Utils/StringUtils.h"
|
#include "Utils/StringUtils.h"
|
||||||
#include "Zone/Definition/Parsing/Matcher/ZoneDefinitionMatcherFactory.h"
|
#include "Zone/Definition/Parsing/Matcher/ZoneDefinitionMatcherFactory.h"
|
||||||
@@ -10,7 +9,7 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
constexpr auto METADATA_CUSTOM_MAP = "custom_map";
|
constexpr auto METADATA_MAP_TYPE = "map";
|
||||||
|
|
||||||
constexpr auto METADATA_GAME = "game";
|
constexpr auto METADATA_GAME = "game";
|
||||||
constexpr auto METADATA_GDT = "gdt";
|
constexpr auto METADATA_GDT = "gdt";
|
||||||
@@ -136,9 +135,24 @@ void SequenceZoneDefinitionMetaData::ProcessMatch(ZoneDefinitionParserState* sta
|
|||||||
{
|
{
|
||||||
ProcessMetaDataGame(state, valueToken, value);
|
ProcessMetaDataGame(state, valueToken, value);
|
||||||
}
|
}
|
||||||
else if (key == METADATA_CUSTOM_MAP)
|
else if (key == METADATA_MAP_TYPE)
|
||||||
{
|
{
|
||||||
state->SetCustomMap();
|
std::string valueLowerCase = value;
|
||||||
|
std::transform(valueLowerCase.begin(),
|
||||||
|
valueLowerCase.end(),
|
||||||
|
valueLowerCase.begin(),
|
||||||
|
[](unsigned char c)
|
||||||
|
{
|
||||||
|
return std::tolower(c);
|
||||||
|
});
|
||||||
|
if (valueLowerCase.compare("sp") == 0)
|
||||||
|
state->SetMapType(ZoneDefinitionMapType::SP);
|
||||||
|
else if (valueLowerCase.compare("mp") == 0)
|
||||||
|
state->SetMapType(ZoneDefinitionMapType::MP);
|
||||||
|
else if (valueLowerCase.compare("zm") == 0)
|
||||||
|
state->SetMapType(ZoneDefinitionMapType::ZM);
|
||||||
|
else
|
||||||
|
throw ParsingException(valueToken.GetPos(), "map must be SP, MP or ZM");
|
||||||
}
|
}
|
||||||
else if (key == METADATA_GDT)
|
else if (key == METADATA_GDT)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,25 +19,9 @@ void ZoneDefinitionParserState::SetGame(const GameId game)
|
|||||||
m_asset_name_resolver = IAssetNameResolver::GetResolverForGame(game);
|
m_asset_name_resolver = IAssetNameResolver::GetResolverForGame(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDefinitionParserState::SetCustomMap()
|
void ZoneDefinitionParserState::SetMapType(ZoneDefinitionMapType mapType)
|
||||||
{
|
{
|
||||||
if (m_definition->is_custom_map == false)
|
m_definition->m_map_type = mapType;
|
||||||
{
|
|
||||||
m_definition->is_custom_map = true;
|
|
||||||
if (m_definition->m_game != GameId::T6)
|
|
||||||
{
|
|
||||||
printf("ERROR: Custom map linking is only supported on BO2 (T6).\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Processing zone as a custom map zone.\n");
|
|
||||||
const auto gfxWorldAssetType = m_asset_name_resolver->GetAssetTypeByName("gfxworld");
|
|
||||||
_ASSERT(gfxWorldAssetType);
|
|
||||||
|
|
||||||
m_definition->m_assets.emplace_back(*gfxWorldAssetType, "gfxworld", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public:
|
|||||||
|
|
||||||
void SetGame(GameId game);
|
void SetGame(GameId game);
|
||||||
|
|
||||||
void SetCustomMap();
|
void SetMapType(ZoneDefinitionMapType mapType);
|
||||||
|
|
||||||
void StartIPak(std::string ipakName);
|
void StartIPak(std::string ipakName);
|
||||||
void StartIwd(std::string iwdName);
|
void StartIwd(std::string iwdName);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ void ZoneDefinitionProperties::Include(const ZoneDefinitionProperties& otherProp
|
|||||||
}
|
}
|
||||||
|
|
||||||
ZoneDefinition::ZoneDefinition()
|
ZoneDefinition::ZoneDefinition()
|
||||||
: m_game(GameId::COUNT)
|
: m_game(GameId::COUNT),
|
||||||
|
m_map_type(ZoneDefinitionMapType::NONE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ enum class ZoneDefinitionObjContainerType : uint8_t
|
|||||||
IPAK
|
IPAK
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ZoneDefinitionMapType : uint8_t
|
||||||
|
{
|
||||||
|
NONE,
|
||||||
|
SP,
|
||||||
|
MP,
|
||||||
|
ZM
|
||||||
|
};
|
||||||
|
|
||||||
class ZoneDefinitionObjContainer
|
class ZoneDefinitionObjContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -69,6 +77,5 @@ public:
|
|||||||
std::vector<std::string> m_gdts;
|
std::vector<std::string> m_gdts;
|
||||||
std::vector<ZoneDefinitionAsset> m_assets;
|
std::vector<ZoneDefinitionAsset> m_assets;
|
||||||
std::vector<ZoneDefinitionObjContainer> m_obj_containers;
|
std::vector<ZoneDefinitionObjContainer> m_obj_containers;
|
||||||
|
ZoneDefinitionMapType m_map_type;
|
||||||
bool is_custom_map = false;
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user