mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-07-19 13:48:08 +00:00
refactor: remove heap-allocated AABBs
This commit is contained in:
@@ -5,11 +5,9 @@
|
||||
|
||||
NamedAreaRuleDefinition::NamedAreaRuleDefinition() {
|
||||
m_name = L"";
|
||||
m_area = new AABB(0, 0, 0, 0, 0, 0);
|
||||
m_area = AABB(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
NamedAreaRuleDefinition::~NamedAreaRuleDefinition() { delete m_area; }
|
||||
|
||||
void NamedAreaRuleDefinition::writeAttributes(DataOutputStream* dos,
|
||||
unsigned int numAttributes) {
|
||||
GameRuleDefinition::writeAttributes(dos, numAttributes + 7);
|
||||
@@ -18,18 +16,18 @@ void NamedAreaRuleDefinition::writeAttributes(DataOutputStream* dos,
|
||||
dos->writeUTF(m_name);
|
||||
|
||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x0);
|
||||
dos->writeUTF(_toString(m_area->x0));
|
||||
dos->writeUTF(_toString(m_area.x0));
|
||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y0);
|
||||
dos->writeUTF(_toString(m_area->y0));
|
||||
dos->writeUTF(_toString(m_area.y0));
|
||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z0);
|
||||
dos->writeUTF(_toString(m_area->z0));
|
||||
dos->writeUTF(_toString(m_area.z0));
|
||||
|
||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x1);
|
||||
dos->writeUTF(_toString(m_area->x1));
|
||||
dos->writeUTF(_toString(m_area.x1));
|
||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y1);
|
||||
dos->writeUTF(_toString(m_area->y1));
|
||||
dos->writeUTF(_toString(m_area.y1));
|
||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z1);
|
||||
dos->writeUTF(_toString(m_area->z1));
|
||||
dos->writeUTF(_toString(m_area.z1));
|
||||
}
|
||||
|
||||
void NamedAreaRuleDefinition::addAttribute(const std::wstring& attributeName,
|
||||
@@ -41,31 +39,31 @@ void NamedAreaRuleDefinition::addAttribute(const std::wstring& attributeName,
|
||||
m_name.c_str());
|
||||
#endif
|
||||
} else if (attributeName.compare(L"x0") == 0) {
|
||||
m_area->x0 = _fromString<int>(attributeValue);
|
||||
m_area.x0 = _fromString<int>(attributeValue);
|
||||
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter x0=%f\n",
|
||||
m_area->x0);
|
||||
m_area.x0);
|
||||
} else if (attributeName.compare(L"y0") == 0) {
|
||||
m_area->y0 = _fromString<int>(attributeValue);
|
||||
if (m_area->y0 < 0) m_area->y0 = 0;
|
||||
m_area.y0 = _fromString<int>(attributeValue);
|
||||
if (m_area.y0 < 0) m_area.y0 = 0;
|
||||
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter y0=%f\n",
|
||||
m_area->y0);
|
||||
m_area.y0);
|
||||
} else if (attributeName.compare(L"z0") == 0) {
|
||||
m_area->z0 = _fromString<int>(attributeValue);
|
||||
m_area.z0 = _fromString<int>(attributeValue);
|
||||
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter z0=%f\n",
|
||||
m_area->z0);
|
||||
m_area.z0);
|
||||
} else if (attributeName.compare(L"x1") == 0) {
|
||||
m_area->x1 = _fromString<int>(attributeValue);
|
||||
m_area.x1 = _fromString<int>(attributeValue);
|
||||
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter x1=%f\n",
|
||||
m_area->x1);
|
||||
m_area.x1);
|
||||
} else if (attributeName.compare(L"y1") == 0) {
|
||||
m_area->y1 = _fromString<int>(attributeValue);
|
||||
if (m_area->y1 < 0) m_area->y1 = 0;
|
||||
m_area.y1 = _fromString<int>(attributeValue);
|
||||
if (m_area.y1 < 0) m_area.y1 = 0;
|
||||
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter y1=%f\n",
|
||||
m_area->y1);
|
||||
m_area.y1);
|
||||
} else if (attributeName.compare(L"z1") == 0) {
|
||||
m_area->z1 = _fromString<int>(attributeValue);
|
||||
m_area.z1 = _fromString<int>(attributeValue);
|
||||
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter z1=%f\n",
|
||||
m_area->z1);
|
||||
m_area.z1);
|
||||
} else {
|
||||
GameRuleDefinition::addAttribute(attributeName, attributeValue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user