Files
MinecraftConsoles/Minecraft.Client/Common/GameRules/LevelRuleset.cpp
Loki Rautio 087b7e7abf Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.

This reverts commit a9be52c41a.
2026-03-07 21:12:22 -06:00

72 lines
1.3 KiB
C++

#include "stdafx.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\StringTable.h"
#include "ConsoleGameRules.h"
#include "LevelRuleset.h"
LevelRuleset::LevelRuleset()
{
m_stringTable = NULL;
}
LevelRuleset::~LevelRuleset()
{
for (auto it = m_areas.begin(); it != m_areas.end(); ++it)
{
delete *it;
}
}
void LevelRuleset::getChildren(vector<GameRuleDefinition *> *children)
{
CompoundGameRuleDefinition::getChildren(children);
for (const auto& area : m_areas)
children->push_back(area);
}
GameRuleDefinition *LevelRuleset::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
GameRuleDefinition *rule = NULL;
if(ruleType == ConsoleGameRules::eGameRuleType_NamedArea)
{
rule = new NamedAreaRuleDefinition();
m_areas.push_back((NamedAreaRuleDefinition *)rule);
}
else
{
rule = CompoundGameRuleDefinition::addChild(ruleType);
}
return rule;
}
void LevelRuleset::loadStringTable(StringTable *table)
{
m_stringTable = table;
}
LPCWSTR LevelRuleset::getString(const wstring &key)
{
if(m_stringTable == NULL)
{
return L"";
}
else
{
return m_stringTable->getString(key);
}
}
AABB *LevelRuleset::getNamedArea(const wstring &areaName)
{
AABB *area = nullptr;
for(auto& it : m_areas)
{
if( it->getName().compare(areaName) == 0 )
{
area = it->getArea();
break;
}
}
return area;
}