refactor: use std::endian directly, enum class EDefaultSkins, rename reserved-prefix helpers

This commit is contained in:
MatthewBeshay
2026-04-03 19:05:19 +11:00
parent 3f33bf4817
commit 5105f89648
93 changed files with 407 additions and 411 deletions
@@ -377,7 +377,7 @@ void ColourTable::setColour(const std::wstring& colourName, int value) {
void ColourTable::setColour(const std::wstring& colourName,
const std::wstring& value) {
setColour(colourName, _fromHEXString<int>(value));
setColour(colourName, fromHexWString<int>(value));
}
unsigned int ColourTable::getColour(eMinecraftColour id) {
+1 -1
View File
@@ -145,7 +145,7 @@ bool DLCPack::getParameterAsUInt(DLCManager::EDLCParameterType type,
ss >> param;
} break;
default:
param = _fromString<unsigned int>(it->second);
param = fromWString<unsigned int>(it->second);
}
return true;
}
@@ -41,25 +41,25 @@ void ApplySchematicRuleDefinition::writeAttributes(DataOutputStream* dos,
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_filename);
dos->writeUTF(m_schematicName);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x);
dos->writeUTF(_toString(m_location.x));
dos->writeUTF(toWString(m_location.x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y);
dos->writeUTF(_toString(m_location.y));
dos->writeUTF(toWString(m_location.y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z);
dos->writeUTF(_toString(m_location.z));
dos->writeUTF(toWString(m_location.z));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_rot);
switch (m_rotation) {
case ConsoleSchematicFile::eSchematicRot_0:
dos->writeUTF(_toString(0));
dos->writeUTF(toWString(0));
break;
case ConsoleSchematicFile::eSchematicRot_90:
dos->writeUTF(_toString(90));
dos->writeUTF(toWString(90));
break;
case ConsoleSchematicFile::eSchematicRot_180:
dos->writeUTF(_toString(180));
dos->writeUTF(toWString(180));
break;
case ConsoleSchematicFile::eSchematicRot_270:
dos->writeUTF(_toString(270));
dos->writeUTF(toWString(270));
break;
}
}
@@ -81,23 +81,23 @@ void ApplySchematicRuleDefinition::addAttribute(
m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
}
} else if (attributeName.compare(L"x") == 0) {
m_location.x = _fromString<int>(attributeValue);
m_location.x = fromWString<int>(attributeValue);
if (((int)std::abs(m_location.x)) % 2 != 0) m_location.x -= 1;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// x=%f\n",m_location->x);
} else if (attributeName.compare(L"y") == 0) {
m_location.y = _fromString<int>(attributeValue);
m_location.y = fromWString<int>(attributeValue);
if (((int)std::abs(m_location.y)) % 2 != 0) m_location.y -= 1;
if (m_location.y < 0) m_location.y = 0;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// y=%f\n",m_location->y);
} else if (attributeName.compare(L"z") == 0) {
m_location.z = _fromString<int>(attributeValue);
m_location.z = fromWString<int>(attributeValue);
if (((int)std::abs(m_location.z)) % 2 != 0) m_location.z -= 1;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// z=%f\n",m_location->z);
} else if (attributeName.compare(L"rot") == 0) {
int degrees = _fromString<int>(attributeValue);
int degrees = fromWString<int>(attributeValue);
while (degrees < 0) degrees += 360;
while (degrees >= 360) degrees -= 360;
@@ -123,7 +123,7 @@ void ApplySchematicRuleDefinition::addAttribute(
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// rot=%d\n",m_rotation);
} else if (attributeName.compare(L"dim") == 0) {
m_dimension = _fromString<int>(attributeValue);
m_dimension = fromWString<int>(attributeValue);
if (m_dimension > 1 || m_dimension < -1) m_dimension = 0;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// dimension=%d\n",m_dimension);
@@ -17,26 +17,26 @@ void BiomeOverride::writeAttributes(DataOutputStream* dos,
GameRuleDefinition::writeAttributes(dos, numAttrs + 3);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_biomeId);
dos->writeUTF(_toString(m_biomeId));
dos->writeUTF(toWString(m_biomeId));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_tileId);
dos->writeUTF(_toString(m_tile));
dos->writeUTF(toWString(m_tile));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_topTileId);
dos->writeUTF(_toString(m_topTile));
dos->writeUTF(toWString(m_topTile));
}
void BiomeOverride::addAttribute(const std::wstring& attributeName,
const std::wstring& attributeValue) {
if (attributeName.compare(L"tileId") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_tile = value;
app.DebugPrintf("BiomeOverride: Adding parameter tileId=%d\n", m_tile);
} else if (attributeName.compare(L"topTileId") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_topTile = value;
app.DebugPrintf("BiomeOverride: Adding parameter topTileId=%d\n",
m_topTile);
} else if (attributeName.compare(L"biomeId") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_biomeId = value;
app.DebugPrintf("BiomeOverride: Adding parameter biomeId=%d\n",
m_biomeId);
@@ -65,43 +65,43 @@ void ConsoleGenerateStructure::writeAttributes(DataOutputStream* dos,
GameRuleDefinition::writeAttributes(dos, numAttrs + 5);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x);
dos->writeUTF(_toString(m_x));
dos->writeUTF(toWString(m_x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y);
dos->writeUTF(_toString(m_y));
dos->writeUTF(toWString(m_y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z);
dos->writeUTF(_toString(m_z));
dos->writeUTF(toWString(m_z));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_orientation);
dos->writeUTF(_toString(orientation));
dos->writeUTF(toWString(orientation));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_dimension);
dos->writeUTF(_toString(m_dimension));
dos->writeUTF(toWString(m_dimension));
}
void ConsoleGenerateStructure::addAttribute(
const std::wstring& attributeName, const std::wstring& attributeValue) {
if (attributeName.compare(L"x") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_x = value;
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter x=%d\n",
m_x);
} else if (attributeName.compare(L"y") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_y = value;
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter y=%d\n",
m_y);
} else if (attributeName.compare(L"z") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_z = value;
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter z=%d\n",
m_z);
} else if (attributeName.compare(L"orientation") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
orientation = value;
app.DebugPrintf(
"ConsoleGenerateStructure: Adding parameter orientation=%d\n",
orientation);
} else if (attributeName.compare(L"dim") == 0) {
m_dimension = _fromString<int>(attributeValue);
m_dimension = fromWString<int>(attributeValue);
if (m_dimension > 1 || m_dimension < -1) m_dimension = 0;
app.DebugPrintf(
"ApplySchematicRuleDefinition: Adding parameter dimension=%d\n",
@@ -131,16 +131,16 @@ void LevelGenerationOptions::writeAttributes(DataOutputStream* dos,
GameRuleDefinition::writeAttributes(dos, numAttrs + 5);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnX);
dos->writeUTF(_toString(m_spawnPos->x));
dos->writeUTF(toWString(m_spawnPos->x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnY);
dos->writeUTF(_toString(m_spawnPos->y));
dos->writeUTF(toWString(m_spawnPos->y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnZ);
dos->writeUTF(_toString(m_spawnPos->z));
dos->writeUTF(toWString(m_spawnPos->z));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_seed);
dos->writeUTF(_toString(m_seed));
dos->writeUTF(toWString(m_seed));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_flatworld);
dos->writeUTF(_toString(m_useFlatWorld));
dos->writeUTF(toWString(m_useFlatWorld));
}
void LevelGenerationOptions::getChildren(
@@ -190,24 +190,24 @@ GameRuleDefinition* LevelGenerationOptions::addChild(
void LevelGenerationOptions::addAttribute(const std::wstring& attributeName,
const std::wstring& attributeValue) {
if (attributeName.compare(L"seed") == 0) {
m_seed = _fromString<int64_t>(attributeValue);
m_seed = fromWString<int64_t>(attributeValue);
app.DebugPrintf(
"LevelGenerationOptions: Adding parameter m_seed=%I64d\n", m_seed);
} else if (attributeName.compare(L"spawnX") == 0) {
if (m_spawnPos == nullptr) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_spawnPos->x = value;
app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnX=%d\n",
value);
} else if (attributeName.compare(L"spawnY") == 0) {
if (m_spawnPos == nullptr) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_spawnPos->y = value;
app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnY=%d\n",
value);
} else if (attributeName.compare(L"spawnZ") == 0) {
if (m_spawnPos == nullptr) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_spawnPos->z = value;
app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnZ=%d\n",
value);
@@ -244,7 +244,7 @@ void LevelGenerationOptions::addAttribute(const std::wstring& attributeName,
"LevelGenerationOptions: Adding parameter displayName=%ls\n",
getDisplayName());
} else if (attributeName.compare(L"texturePackId") == 0) {
setRequiredTexturePackId(_fromString<unsigned int>(attributeValue));
setRequiredTexturePackId(fromWString<unsigned int>(attributeValue));
setRequiresTexturePack(true);
app.DebugPrintf(
"LevelGenerationOptions: Adding parameter texturePackId=%0x\n",
@@ -260,7 +260,7 @@ void LevelGenerationOptions::addAttribute(const std::wstring& attributeName,
"LevelGenerationOptions: Adding parameter baseSaveName=%ls\n",
getBaseSavePath().c_str());
} else if (attributeName.compare(L"hasBeenInCreative") == 0) {
bool value = _fromString<bool>(attributeValue);
bool value = fromWString<bool>(attributeValue);
m_bHasBeenInCreative = value;
app.DebugPrintf(
"LevelGenerationOptions: Adding parameter gameMode=%d\n",
@@ -18,32 +18,32 @@ void StartFeature::writeAttributes(DataOutputStream* dos,
GameRuleDefinition::writeAttributes(dos, numAttrs + 4);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_chunkX);
dos->writeUTF(_toString(m_chunkX));
dos->writeUTF(toWString(m_chunkX));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_chunkZ);
dos->writeUTF(_toString(m_chunkZ));
dos->writeUTF(toWString(m_chunkZ));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_feature);
dos->writeUTF(_toString((int)m_feature));
dos->writeUTF(toWString((int)m_feature));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_orientation);
dos->writeUTF(_toString(m_orientation));
dos->writeUTF(toWString(m_orientation));
}
void StartFeature::addAttribute(const std::wstring& attributeName,
const std::wstring& attributeValue) {
if (attributeName.compare(L"chunkX") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_chunkX = value;
app.DebugPrintf("StartFeature: Adding parameter chunkX=%d\n", m_chunkX);
} else if (attributeName.compare(L"chunkZ") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_chunkZ = value;
app.DebugPrintf("StartFeature: Adding parameter chunkZ=%d\n", m_chunkZ);
} else if (attributeName.compare(L"orientation") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_orientation = value;
app.DebugPrintf("StartFeature: Adding parameter orientation=%d\n",
m_orientation);
} else if (attributeName.compare(L"feature") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_feature = (StructureFeature::EFeatureTypes)value;
app.DebugPrintf("StartFeature: Adding parameter feature=%d\n",
m_feature);
@@ -18,67 +18,67 @@ void XboxStructureActionGenerateBox::writeAttributes(DataOutputStream* dos,
ConsoleGenerateStructureAction::writeAttributes(dos, numAttrs + 9);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x0);
dos->writeUTF(_toString(m_x0));
dos->writeUTF(toWString(m_x0));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y0);
dos->writeUTF(_toString(m_y0));
dos->writeUTF(toWString(m_y0));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z0);
dos->writeUTF(_toString(m_z0));
dos->writeUTF(toWString(m_z0));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x1);
dos->writeUTF(_toString(m_x1));
dos->writeUTF(toWString(m_x1));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y1);
dos->writeUTF(_toString(m_y1));
dos->writeUTF(toWString(m_y1));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z1);
dos->writeUTF(_toString(m_z1));
dos->writeUTF(toWString(m_z1));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_edgeTile);
dos->writeUTF(_toString(m_edgeTile));
dos->writeUTF(toWString(m_edgeTile));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_fillTile);
dos->writeUTF(_toString(m_fillTile));
dos->writeUTF(toWString(m_fillTile));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_skipAir);
dos->writeUTF(_toString(m_skipAir));
dos->writeUTF(toWString(m_skipAir));
}
void XboxStructureActionGenerateBox::addAttribute(
const std::wstring& attributeName, const std::wstring& attributeValue) {
if (attributeName.compare(L"x0") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_x0 = value;
app.DebugPrintf(
"XboxStructureActionGenerateBox: Adding parameter x0=%d\n", m_x0);
} else if (attributeName.compare(L"y0") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_y0 = value;
app.DebugPrintf(
"XboxStructureActionGenerateBox: Adding parameter y0=%d\n", m_y0);
} else if (attributeName.compare(L"z0") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_z0 = value;
app.DebugPrintf(
"XboxStructureActionGenerateBox: Adding parameter z0=%d\n", m_z0);
} else if (attributeName.compare(L"x1") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_x1 = value;
app.DebugPrintf(
"XboxStructureActionGenerateBox: Adding parameter x1=%d\n", m_x1);
} else if (attributeName.compare(L"y1") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_y1 = value;
app.DebugPrintf(
"XboxStructureActionGenerateBox: Adding parameter y1=%d\n", m_y1);
} else if (attributeName.compare(L"z1") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_z1 = value;
app.DebugPrintf(
"XboxStructureActionGenerateBox: Adding parameter z1=%d\n", m_z1);
} else if (attributeName.compare(L"edgeTile") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_edgeTile = value;
app.DebugPrintf(
"XboxStructureActionGenerateBox: Adding parameter edgeTile=%d\n",
m_edgeTile);
} else if (attributeName.compare(L"fillTile") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_fillTile = value;
app.DebugPrintf(
"XboxStructureActionGenerateBox: Adding parameter fillTile=%d\n",
@@ -17,43 +17,43 @@ void XboxStructureActionPlaceBlock::writeAttributes(DataOutputStream* dos,
ConsoleGenerateStructureAction::writeAttributes(dos, numAttrs + 5);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x);
dos->writeUTF(_toString(m_x));
dos->writeUTF(toWString(m_x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y);
dos->writeUTF(_toString(m_y));
dos->writeUTF(toWString(m_y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z);
dos->writeUTF(_toString(m_z));
dos->writeUTF(toWString(m_z));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_data);
dos->writeUTF(_toString(m_data));
dos->writeUTF(toWString(m_data));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_block);
dos->writeUTF(_toString(m_tile));
dos->writeUTF(toWString(m_tile));
}
void XboxStructureActionPlaceBlock::addAttribute(
const std::wstring& attributeName, const std::wstring& attributeValue) {
if (attributeName.compare(L"x") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_x = value;
app.DebugPrintf(
"XboxStructureActionPlaceBlock: Adding parameter x=%d\n", m_x);
} else if (attributeName.compare(L"y") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_y = value;
app.DebugPrintf(
"XboxStructureActionPlaceBlock: Adding parameter y=%d\n", m_y);
} else if (attributeName.compare(L"z") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_z = value;
app.DebugPrintf(
"XboxStructureActionPlaceBlock: Adding parameter z=%d\n", m_z);
} else if (attributeName.compare(L"block") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_tile = value;
app.DebugPrintf(
"XboxStructureActionPlaceBlock: Adding parameter block=%d\n",
m_tile);
} else if (attributeName.compare(L"data") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_data = value;
app.DebugPrintf(
"XboxStructureActionPlaceBlock: Adding parameter data=%d\n",
@@ -57,7 +57,7 @@ GameRuleDefinition* XboxStructureActionPlaceContainer::addChild(
void XboxStructureActionPlaceContainer::addAttribute(
const std::wstring& attributeName, const std::wstring& attributeValue) {
if (attributeName.compare(L"facing") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_data = value;
app.DebugPrintf(
"XboxStructureActionPlaceContainer: Adding parameter facing=%d\n",
@@ -24,17 +24,17 @@ void AddEnchantmentRuleDefinition::writeAttributes(DataOutputStream* dos,
GameRuleDefinition::writeAttributes(dos, numAttributes + 2);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_enchantmentId);
dos->writeUTF(_toString(m_enchantmentId));
dos->writeUTF(toWString(m_enchantmentId));
ConsoleGameRules::write(dos,
ConsoleGameRules::eGameRuleAttr_enchantmentLevel);
dos->writeUTF(_toString(m_enchantmentLevel));
dos->writeUTF(toWString(m_enchantmentLevel));
}
void AddEnchantmentRuleDefinition::addAttribute(
const std::wstring& attributeName, const std::wstring& attributeValue) {
if (attributeName.compare(L"enchantmentId") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
if (value < 0) value = 0;
if (value >= 256) value = 255;
m_enchantmentId = value;
@@ -42,7 +42,7 @@ void AddEnchantmentRuleDefinition::addAttribute(
"AddEnchantmentRuleDefinition: Adding parameter enchantmentId=%d\n",
m_enchantmentId);
} else if (attributeName.compare(L"enchantmentLevel") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
if (value < 0) value = 0;
m_enchantmentLevel = value;
app.DebugPrintf(
@@ -22,19 +22,19 @@ void AddItemRuleDefinition::writeAttributes(DataOutputStream* dos,
GameRuleDefinition::writeAttributes(dos, numAttrs + 5);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_itemId);
dos->writeUTF(_toString(m_itemId));
dos->writeUTF(toWString(m_itemId));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_quantity);
dos->writeUTF(_toString(m_quantity));
dos->writeUTF(toWString(m_quantity));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_auxValue);
dos->writeUTF(_toString(m_auxValue));
dos->writeUTF(toWString(m_auxValue));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_dataTag);
dos->writeUTF(_toString(m_dataTag));
dos->writeUTF(toWString(m_dataTag));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_slot);
dos->writeUTF(_toString(m_slot));
dos->writeUTF(toWString(m_slot));
}
void AddItemRuleDefinition::getChildren(
@@ -58,27 +58,27 @@ GameRuleDefinition* AddItemRuleDefinition::addChild(
void AddItemRuleDefinition::addAttribute(const std::wstring& attributeName,
const std::wstring& attributeValue) {
if (attributeName.compare(L"itemId") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_itemId = value;
// app.DebugPrintf(2,"AddItemRuleDefinition: Adding parameter
// itemId=%d\n",m_itemId);
} else if (attributeName.compare(L"quantity") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_quantity = value;
// app.DebugPrintf(2,"AddItemRuleDefinition: Adding parameter
// quantity=%d\n",m_quantity);
} else if (attributeName.compare(L"auxValue") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_auxValue = value;
// app.DebugPrintf(2,"AddItemRuleDefinition: Adding parameter
// auxValue=%d\n",m_auxValue);
} else if (attributeName.compare(L"dataTag") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_dataTag = value;
// app.DebugPrintf(2,"AddItemRuleDefinition: Adding parameter
// dataTag=%d\n",m_dataTag);
} else if (attributeName.compare(L"slot") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_slot = value;
// app.DebugPrintf(2,"AddItemRuleDefinition: Adding parameter
// slot=%d\n",m_slot);
@@ -24,27 +24,27 @@ void CollectItemRuleDefinition::writeAttributes(DataOutputStream* dos,
GameRuleDefinition::writeAttributes(dos, numAttributes + 3);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_itemId);
dos->writeUTF(_toString(m_itemId));
dos->writeUTF(toWString(m_itemId));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_auxValue);
dos->writeUTF(_toString(m_auxValue));
dos->writeUTF(toWString(m_auxValue));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_quantity);
dos->writeUTF(_toString(m_quantity));
dos->writeUTF(toWString(m_quantity));
}
void CollectItemRuleDefinition::addAttribute(
const std::wstring& attributeName, const std::wstring& attributeValue) {
if (attributeName.compare(L"itemId") == 0) {
m_itemId = _fromString<int>(attributeValue);
m_itemId = fromWString<int>(attributeValue);
app.DebugPrintf("CollectItemRule: Adding parameter itemId=%d\n",
m_itemId);
} else if (attributeName.compare(L"auxValue") == 0) {
m_auxValue = _fromString<int>(attributeValue);
m_auxValue = fromWString<int>(attributeValue);
app.DebugPrintf("CollectItemRule: Adding parameter m_auxValue=%d\n",
m_auxValue);
} else if (attributeName.compare(L"quantity") == 0) {
m_quantity = _fromString<int>(attributeValue);
m_quantity = fromWString<int>(attributeValue);
app.DebugPrintf("CollectItemRule: Adding parameter m_quantity=%d\n",
m_quantity);
} else {
@@ -107,14 +107,14 @@ std::wstring CollectItemRuleDefinition::generateXml(
// 4J Stu - This should be kept in sync with the GameRulesDefinition.xsd
std::wstring xml = L"";
if (item != nullptr) {
xml = L"<CollectItemRule itemId=\"" + _toString<int>(item->id) +
xml = L"<CollectItemRule itemId=\"" + toWString<int>(item->id) +
L"\" quantity=\"SET\" descriptionName=\"OPTIONAL\" "
L"promptName=\"OPTIONAL\"";
if (item->getAuxValue() != 0)
xml +=
L" auxValue=\"" + _toString<int>(item->getAuxValue()) + L"\"";
L" auxValue=\"" + toWString<int>(item->getAuxValue()) + L"\"";
if (item->get4JData() != 0)
xml += L" dataTag=\"" + _toString<int>(item->get4JData()) + L"\"";
xml += L" dataTag=\"" + toWString<int>(item->get4JData()) + L"\"";
xml += L"/>\n";
}
return xml;
@@ -71,7 +71,7 @@ std::wstring CompleteAllRuleDefinition::generateDescriptionString(
PacketData* values = (PacketData*)data;
std::wstring newDesc = description;
newDesc =
replaceAll(newDesc, L"{*progress*}", _toString<int>(values->progress));
newDesc = replaceAll(newDesc, L"{*goal*}", _toString<int>(values->goal));
replaceAll(newDesc, L"{*progress*}", toWString<int>(values->progress));
newDesc = replaceAll(newDesc, L"{*goal*}", toWString<int>(values->goal));
return newDesc;
}
@@ -70,7 +70,7 @@ void CompoundGameRuleDefinition::populateGameRule(
value.isPointer = true;
// Somehow add the newRule to the current rule
rule->setParameter(L"rule" + _toString<int>(i), value);
rule->setParameter(L"rule" + toWString<int>(i), value);
++i;
}
GameRuleDefinition::populateGameRule(type, rule);
@@ -56,7 +56,7 @@ void GameRuleDefinition::writeAttributes(DataOutputStream* dos,
dos->writeUTF(m_promptId);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_dataTag);
dos->writeUTF(_toString(m_4JDataValue));
dos->writeUTF(toWString(m_4JDataValue));
}
void GameRuleDefinition::getChildren(
@@ -86,7 +86,7 @@ void GameRuleDefinition::addAttribute(const std::wstring& attributeName,
m_promptId.c_str());
#endif
} else if (attributeName.compare(L"dataTag") == 0) {
m_4JDataValue = _fromString<int>(attributeValue);
m_4JDataValue = fromWString<int>(attributeValue);
app.DebugPrintf(
"GameRuleDefinition: Adding parameter m_4JDataValue=%d\n",
m_4JDataValue);
@@ -21,18 +21,18 @@ void NamedAreaRuleDefinition::writeAttributes(DataOutputStream* dos,
dos->writeUTF(m_name);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x0);
dos->writeUTF(_toString(m_area.x0));
dos->writeUTF(toWString(m_area.x0));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y0);
dos->writeUTF(_toString(m_area.y0));
dos->writeUTF(toWString(m_area.y0));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z0);
dos->writeUTF(_toString(m_area.z0));
dos->writeUTF(toWString(m_area.z0));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x1);
dos->writeUTF(_toString(m_area.x1));
dos->writeUTF(toWString(m_area.x1));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y1);
dos->writeUTF(_toString(m_area.y1));
dos->writeUTF(toWString(m_area.y1));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z1);
dos->writeUTF(_toString(m_area.z1));
dos->writeUTF(toWString(m_area.z1));
}
void NamedAreaRuleDefinition::addAttribute(const std::wstring& attributeName,
@@ -44,29 +44,29 @@ 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 = fromWString<int>(attributeValue);
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter x0=%f\n",
m_area.x0);
} else if (attributeName.compare(L"y0") == 0) {
m_area.y0 = _fromString<int>(attributeValue);
m_area.y0 = fromWString<int>(attributeValue);
if (m_area.y0 < 0) m_area.y0 = 0;
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter y0=%f\n",
m_area.y0);
} else if (attributeName.compare(L"z0") == 0) {
m_area.z0 = _fromString<int>(attributeValue);
m_area.z0 = fromWString<int>(attributeValue);
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter z0=%f\n",
m_area.z0);
} else if (attributeName.compare(L"x1") == 0) {
m_area.x1 = _fromString<int>(attributeValue);
m_area.x1 = fromWString<int>(attributeValue);
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter x1=%f\n",
m_area.x1);
} else if (attributeName.compare(L"y1") == 0) {
m_area.y1 = _fromString<int>(attributeValue);
m_area.y1 = fromWString<int>(attributeValue);
if (m_area.y1 < 0) m_area.y1 = 0;
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter y1=%f\n",
m_area.y1);
} else if (attributeName.compare(L"z1") == 0) {
m_area.z1 = _fromString<int>(attributeValue);
m_area.z1 = fromWString<int>(attributeValue);
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter z1=%f\n",
m_area.z1);
} else {
@@ -39,23 +39,23 @@ void UpdatePlayerRuleDefinition::writeAttributes(DataOutputStream* dos,
GameRuleDefinition::writeAttributes(dos, numAttributes + attrCount);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnX);
dos->writeUTF(_toString(m_spawnPos->x));
dos->writeUTF(toWString(m_spawnPos->x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnY);
dos->writeUTF(_toString(m_spawnPos->y));
dos->writeUTF(toWString(m_spawnPos->y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnZ);
dos->writeUTF(_toString(m_spawnPos->z));
dos->writeUTF(toWString(m_spawnPos->z));
if (m_bUpdateYRot) {
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_yRot);
dos->writeUTF(_toString(m_yRot));
dos->writeUTF(toWString(m_yRot));
}
if (m_bUpdateHealth) {
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_food);
dos->writeUTF(_toString(m_health));
dos->writeUTF(toWString(m_health));
}
if (m_bUpdateFood) {
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_health);
dos->writeUTF(_toString(m_food));
dos->writeUTF(toWString(m_food));
}
}
@@ -87,36 +87,36 @@ void UpdatePlayerRuleDefinition::addAttribute(
const std::wstring& attributeName, const std::wstring& attributeValue) {
if (attributeName.compare(L"spawnX") == 0) {
if (m_spawnPos == nullptr) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_spawnPos->x = value;
app.DebugPrintf(
"UpdatePlayerRuleDefinition: Adding parameter spawnX=%d\n", value);
} else if (attributeName.compare(L"spawnY") == 0) {
if (m_spawnPos == nullptr) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_spawnPos->y = value;
app.DebugPrintf(
"UpdatePlayerRuleDefinition: Adding parameter spawnY=%d\n", value);
} else if (attributeName.compare(L"spawnZ") == 0) {
if (m_spawnPos == nullptr) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_spawnPos->z = value;
app.DebugPrintf(
"UpdatePlayerRuleDefinition: Adding parameter spawnZ=%d\n", value);
} else if (attributeName.compare(L"health") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_health = value;
m_bUpdateHealth = true;
app.DebugPrintf(
"UpdatePlayerRuleDefinition: Adding parameter health=%d\n", value);
} else if (attributeName.compare(L"food") == 0) {
int value = _fromString<int>(attributeValue);
int value = fromWString<int>(attributeValue);
m_food = value;
m_bUpdateFood = true;
app.DebugPrintf(
"UpdatePlayerRuleDefinition: Adding parameter health=%d\n", value);
} else if (attributeName.compare(L"yRot") == 0) {
float value = _fromString<float>(attributeValue);
float value = fromWString<float>(attributeValue);
m_yRot = value;
m_bUpdateYRot = true;
app.DebugPrintf(
@@ -16,40 +16,40 @@ void UseTileRuleDefinition::writeAttributes(DataOutputStream* dos,
GameRuleDefinition::writeAttributes(dos, numAttributes + 5);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_tileId);
dos->writeUTF(_toString(m_tileId));
dos->writeUTF(toWString(m_tileId));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_useCoords);
dos->writeUTF(_toString(m_useCoords));
dos->writeUTF(toWString(m_useCoords));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x);
dos->writeUTF(_toString(m_coordinates.x));
dos->writeUTF(toWString(m_coordinates.x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y);
dos->writeUTF(_toString(m_coordinates.y));
dos->writeUTF(toWString(m_coordinates.y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z);
dos->writeUTF(_toString(m_coordinates.z));
dos->writeUTF(toWString(m_coordinates.z));
}
void UseTileRuleDefinition::addAttribute(const std::wstring& attributeName,
const std::wstring& attributeValue) {
if (attributeName.compare(L"tileId") == 0) {
m_tileId = _fromString<int>(attributeValue);
m_tileId = fromWString<int>(attributeValue);
app.DebugPrintf("UseTileRule: Adding parameter tileId=%d\n", m_tileId);
} else if (attributeName.compare(L"useCoords") == 0) {
m_useCoords = _fromString<bool>(attributeValue);
m_useCoords = fromWString<bool>(attributeValue);
app.DebugPrintf("UseTileRule: Adding parameter useCoords=%s\n",
m_useCoords ? "true" : "false");
} else if (attributeName.compare(L"x") == 0) {
m_coordinates.x = _fromString<int>(attributeValue);
m_coordinates.x = fromWString<int>(attributeValue);
app.DebugPrintf("UseTileRule: Adding parameter x=%d\n",
m_coordinates.x);
} else if (attributeName.compare(L"y") == 0) {
m_coordinates.y = _fromString<int>(attributeValue);
m_coordinates.y = fromWString<int>(attributeValue);
app.DebugPrintf("UseTileRule: Adding parameter y=%d\n",
m_coordinates.y);
} else if (attributeName.compare(L"z") == 0) {
m_coordinates.z = _fromString<int>(attributeValue);
m_coordinates.z = fromWString<int>(attributeValue);
app.DebugPrintf("UseTileRule: Adding parameter z=%d\n",
m_coordinates.z);
} else {
@@ -274,10 +274,10 @@ std::wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal,
std::vector<std::wstring> idAndAux = stringSplit(id, L':');
int iconId = _fromString<int>(idAndAux[0]);
int iconId = fromWString<int>(idAndAux[0]);
if (idAndAux.size() > 1) {
iAuxVal = _fromString<int>(idAndAux[1]);
iAuxVal = fromWString<int>(idAndAux[1]);
} else {
iAuxVal = 0;
}
@@ -110,7 +110,7 @@ void UIControl_EnchantmentButton::render(IggyCustomDrawCallbackRegion* region) {
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.1f);
Minecraft* pMinecraft = Minecraft::GetInstance();
std::wstring line = _toString<int>(cost);
std::wstring line = toWString<int>(cost);
Font* font = pMinecraft->altFont;
// int col = 0x685E4A;
unsigned int col = m_textColour;
@@ -169,7 +169,7 @@ void UIControl_EnchantmentButton::updateState() {
}
if (cost != m_lastCost) {
setLabel(_toString<int>(cost));
setLabel(toWString<int>(cost));
m_lastCost = cost;
m_enchantmentString = EnchantmentNames::instance.getRandomName();
}
@@ -162,7 +162,7 @@ int UIScene_DebugCreateSchematic::KeyboardCompleteCallback(void* lpParam,
if (text[0] != '\0') {
std::wstring value = convStringToWstring(text);
int iVal = 0;
if (!value.empty()) iVal = _fromString<int>(value);
if (!value.empty()) iVal = fromWString<int>(value);
switch (pClass->m_keyboardCallbackControl) {
case eControl_Name:
pClass->m_textInputName.setLabel(value);
@@ -93,7 +93,7 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void* initData,
std::pair<int, int>(ench->id, level));
m_buttonListEnchantments.addItem(
app.GetString(ench->getDescriptionId()) +
_toString<int>(level));
toWString<int>(level));
}
}
@@ -142,7 +142,7 @@ int UIScene_DebugSetCamera::KeyboardCompleteCallback(void* lpParam, bool bRes) {
if (text[0] != '\0') {
std::wstring value = convStringToWstring(text);
double val = 0;
if (!value.empty()) val = _fromString<double>(value);
if (!value.empty()) val = fromWString<double>(value);
switch (pClass->m_keyboardCallbackControl) {
case eControl_CamX:
pClass->m_textInputX.setLabel(value);
@@ -741,7 +741,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass,
}
// If the input string is a numerical value, convert it to a number
if (isNumber) value = _fromString<int64_t>(wSeed);
if (isNumber) value = fromWString<int64_t>(wSeed);
// If the value is not 0 use it, otherwise use the algorithm from the
// java String.hashCode() function to hash it
@@ -590,7 +590,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() {
case SKIN_SELECT_PACK_DEFAULT:
backupTexture = getTextureId(m_skinIndex);
if (m_skinIndex == eDefaultSkins_ServerSelected) {
if (m_skinIndex == std::to_underlying(EDefaultSkins::ServerSelected)) {
skinName = app.GetString(IDS_DEFAULT_SKINS);
} else {
skinName = wchDefaultNamesA[m_skinIndex];
@@ -860,30 +860,30 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() {
TEXTURE_NAME UIScene_SkinSelectMenu::getTextureId(int skinIndex) {
TEXTURE_NAME texture = TN_MOB_CHAR;
switch (skinIndex) {
case eDefaultSkins_ServerSelected:
case eDefaultSkins_Skin0:
switch (static_cast<EDefaultSkins>(skinIndex)) {
case EDefaultSkins::ServerSelected:
case EDefaultSkins::Skin0:
texture = TN_MOB_CHAR;
break;
case eDefaultSkins_Skin1:
case EDefaultSkins::Skin1:
texture = TN_MOB_CHAR1;
break;
case eDefaultSkins_Skin2:
case EDefaultSkins::Skin2:
texture = TN_MOB_CHAR2;
break;
case eDefaultSkins_Skin3:
case EDefaultSkins::Skin3:
texture = TN_MOB_CHAR3;
break;
case eDefaultSkins_Skin4:
case EDefaultSkins::Skin4:
texture = TN_MOB_CHAR4;
break;
case eDefaultSkins_Skin5:
case EDefaultSkins::Skin5:
texture = TN_MOB_CHAR5;
break;
case eDefaultSkins_Skin6:
case EDefaultSkins::Skin6:
texture = TN_MOB_CHAR6;
break;
case eDefaultSkins_Skin7:
case EDefaultSkins::Skin7:
texture = TN_MOB_CHAR7;
break;
};
@@ -907,8 +907,8 @@ int UIScene_SkinSelectMenu::getNextSkinIndex(int sourceIndex) {
++nextSkin;
if (m_packIndex == SKIN_SELECT_PACK_DEFAULT &&
nextSkin >= eDefaultSkins_Count) {
nextSkin = eDefaultSkins_ServerSelected;
nextSkin >= std::to_underlying(EDefaultSkins::Count)) {
nextSkin = std::to_underlying(EDefaultSkins::ServerSelected);
} else if (m_currentPack != nullptr &&
nextSkin >= m_currentPack->getSkinCount()) {
nextSkin = 0;
@@ -932,7 +932,7 @@ int UIScene_SkinSelectMenu::getPreviousSkinIndex(int sourceIndex) {
default:
if (previousSkin == 0) {
if (m_packIndex == SKIN_SELECT_PACK_DEFAULT) {
previousSkin = eDefaultSkins_Count - 1;
previousSkin = std::to_underlying(EDefaultSkins::Count) - 1;
} else if (m_currentPack != nullptr) {
previousSkin = m_currentPack->getSkinCount() - 1;
}
@@ -967,7 +967,7 @@ void UIScene_SkinSelectMenu::handlePackIndexChanged() {
std::uint32_t defaultSkinIndex =
GET_DEFAULT_SKIN_ID_FROM_BITMASK(m_originalSkinId);
if (ugcSkinIndex == 0) {
m_skinIndex = (EDefaultSkins)defaultSkinIndex;
m_skinIndex = static_cast<int>(defaultSkinIndex);
}
}
break;
@@ -24,7 +24,7 @@ class UILayer;
class UIScene_SkinSelectMenu : public UIScene {
private:
static const wchar_t* wchDefaultNamesA[eDefaultSkins_Count];
static const wchar_t* wchDefaultNamesA[std::to_underlying(EDefaultSkins::Count)];
// 4J Stu - How many to show on each side of the main control
static const int sidePreviewControls = 4;
+2
View File
@@ -4,6 +4,8 @@
// #include <system_service.h>
#include <csignal>
#include "util/StringHelpers.h"
#if defined(__linux__) && defined(__GLIBC__)
#include <execinfo.h>
#include <unistd.h>
+2 -2
View File
@@ -65,7 +65,7 @@ BufferedImage::BufferedImage(const std::wstring& File,
for (int l = 0; l < 10; l++) {
std::wstring mipSuffix =
(l != 0) ? L"MipMapLevel" + _toString<int>(l + 1) : L"";
(l != 0) ? L"MipMapLevel" + toWString<int>(l + 1) : L"";
std::wstring fileName = baseName + mipSuffix + L".png";
std::wstring finalPath;
bool foundOnDisk = false;
@@ -133,7 +133,7 @@ BufferedImage::BufferedImage(DLCPack* dlcPack, const std::wstring& File,
for (int l = 0; l < 10; l++) {
std::wstring name;
std::wstring mipMapPath =
(l != 0) ? L"MipMapLevel" + _toString<int>(l + 1) : L"";
(l != 0) ? L"MipMapLevel" + toWString<int>(l + 1) : L"";
name = L"res" + (filenameHasExtension
? filePath
: filePath.substr(0, filePath.length() - 4) +