* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides
72 lines
1.3 KiB
C++
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 = nullptr;
|
|
}
|
|
|
|
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 = nullptr;
|
|
if(ruleType == ConsoleGameRules::eGameRuleType_NamedArea)
|
|
{
|
|
rule = new NamedAreaRuleDefinition();
|
|
m_areas.push_back(static_cast<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 == nullptr)
|
|
{
|
|
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;
|
|
}
|