mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-09-23 10:12:26 +00:00
refactor: use std::endian directly, enum class EDefaultSkins, rename reserved-prefix helpers
This commit is contained in:
@@ -47,7 +47,7 @@ void MemoryTracker::release() {
|
||||
}
|
||||
|
||||
ByteBuffer* MemoryTracker::createByteBuffer(int size) {
|
||||
// 4J - was ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder())
|
||||
// 4J - was ByteBuffer.allocateDirect(size).order(std::endian.nativeOrder())
|
||||
ByteBuffer* bb = ByteBuffer::allocate(size);
|
||||
return bb;
|
||||
}
|
||||
|
||||
@@ -1772,8 +1772,8 @@ void Minecraft::run_middle() {
|
||||
|
||||
#if !defined(_CONTENT_PACKAGE)
|
||||
while (System::nanoTime() >= lastTime + 1000000000) {
|
||||
fpsString = _toString<int>(frames) + L" fps, " +
|
||||
_toString<int>(Chunk::updates) +
|
||||
fpsString = toWString<int>(frames) + L" fps, " +
|
||||
toWString<int>(Chunk::updates) +
|
||||
L" chunk updates";
|
||||
Chunk::updates = 0;
|
||||
lastTime += 1000000000;
|
||||
@@ -3959,7 +3959,7 @@ void Minecraft::fileDownloaded(const std::wstring& name, File* file) {
|
||||
std::wstring Minecraft::gatherStats1() {
|
||||
// return levelRenderer->gatherStats1();
|
||||
return L"Time to autosave: " +
|
||||
_toString<int64_t>(app.SecondsToAutosave()) + L"s";
|
||||
toWString<int64_t>(app.SecondsToAutosave()) + L"s";
|
||||
}
|
||||
|
||||
std::wstring Minecraft::gatherStats2() {
|
||||
@@ -4135,7 +4135,7 @@ void Minecraft::startAndConnectTo(const std::wstring& name,
|
||||
minecraft->user = new User(userName, sid);
|
||||
} else {
|
||||
minecraft->user = new User(
|
||||
L"Player" + _toString<int>(System::currentTimeMillis() % 1000),
|
||||
L"Player" + toWString<int>(System::currentTimeMillis() % 1000),
|
||||
L"");
|
||||
}
|
||||
}
|
||||
@@ -4206,7 +4206,7 @@ void Minecraft::main() {
|
||||
// 4J-PB - Can't call this for the first 5 seconds of a game - MS rule
|
||||
{
|
||||
name =
|
||||
L"Player" + _toString<int64_t>(System::currentTimeMillis() % 1000);
|
||||
L"Player" + toWString<int64_t>(System::currentTimeMillis() % 1000);
|
||||
sessionId = L"-";
|
||||
/* 4J - TODO - get a session ID from somewhere?
|
||||
if (args.size() > 0) name = args[0];
|
||||
|
||||
@@ -312,7 +312,7 @@ std::wstring Options::getMessage(const Options::Option* item) {
|
||||
return caption +
|
||||
language->getElement(L"options.sensitivity.max");
|
||||
}
|
||||
return caption + _toString<int>((int)(progressValue * 200)) + L"%";
|
||||
return caption + toWString<int>((int)(progressValue * 200)) + L"%";
|
||||
} else if (item == Option::FOV) {
|
||||
if (progressValue == 0) {
|
||||
return caption + language->getElement(L"options.fov.min");
|
||||
@@ -320,7 +320,7 @@ std::wstring Options::getMessage(const Options::Option* item) {
|
||||
if (progressValue == 1) {
|
||||
return caption + language->getElement(L"options.fov.max");
|
||||
}
|
||||
return caption + _toString<int>((int)(70 + progressValue * 40));
|
||||
return caption + toWString<int>((int)(70 + progressValue * 40));
|
||||
} else if (item == Option::GAMMA) {
|
||||
if (progressValue == 0) {
|
||||
return caption + language->getElement(L"options.gamma.min");
|
||||
@@ -328,13 +328,13 @@ std::wstring Options::getMessage(const Options::Option* item) {
|
||||
if (progressValue == 1) {
|
||||
return caption + language->getElement(L"options.gamma.max");
|
||||
}
|
||||
return caption + L"+" + _toString<int>((int)(progressValue * 100)) +
|
||||
return caption + L"+" + toWString<int>((int)(progressValue * 100)) +
|
||||
L"%";
|
||||
} else {
|
||||
if (progressValue == 0) {
|
||||
return caption + language->getElement(L"options.off");
|
||||
}
|
||||
return caption + _toString<int>((int)(progressValue * 100)) + L"%";
|
||||
return caption + toWString<int>((int)(progressValue * 100)) + L"%";
|
||||
}
|
||||
} else if (item->isBoolean()) {
|
||||
bool booleanValue = getBooleanValue(item);
|
||||
@@ -395,14 +395,14 @@ void Options::load() {
|
||||
if (cmds[0] == L"gamma") gamma = readFloat(cmds[1]);
|
||||
if (cmds[0] == L"invertYMouse") invertYMouse = cmds[1] == L"true";
|
||||
if (cmds[0] == L"viewDistance")
|
||||
viewDistance = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"guiScale") guiScale = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"particles") particles = _fromString<int>(cmds[1]);
|
||||
viewDistance = fromWString<int>(cmds[1]);
|
||||
if (cmds[0] == L"guiScale") guiScale = fromWString<int>(cmds[1]);
|
||||
if (cmds[0] == L"particles") particles = fromWString<int>(cmds[1]);
|
||||
if (cmds[0] == L"bobView") bobView = cmds[1] == L"true";
|
||||
if (cmds[0] == L"anaglyph3d") anaglyph3d = cmds[1] == L"true";
|
||||
if (cmds[0] == L"advancedOpengl") advancedOpengl = cmds[1] == L"true";
|
||||
if (cmds[0] == L"fpsLimit") framerateLimit = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"difficulty") difficulty = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"fpsLimit") framerateLimit = fromWString<int>(cmds[1]);
|
||||
if (cmds[0] == L"difficulty") difficulty = fromWString<int>(cmds[1]);
|
||||
if (cmds[0] == L"fancyGraphics") fancyGraphics = cmds[1] == L"true";
|
||||
if (cmds[0] == L"ao") ambientOcclusion = cmds[1] == L"true";
|
||||
if (cmds[0] == L"clouds") renderClouds = cmds[1] == L"true";
|
||||
@@ -411,7 +411,7 @@ void Options::load() {
|
||||
|
||||
for (int i = 0; i < keyMappings_length; i++) {
|
||||
if (cmds[0] == (L"key_" + keyMappings[i]->name)) {
|
||||
keyMappings[i]->key = _fromString<int>(cmds[1]);
|
||||
keyMappings[i]->key = fromWString<int>(cmds[1]);
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
@@ -429,7 +429,7 @@ void Options::load() {
|
||||
float Options::readFloat(std::wstring string) {
|
||||
if (string == L"true") return 1;
|
||||
if (string == L"false") return 0;
|
||||
return _fromString<float>(string);
|
||||
return fromWString<float>(string);
|
||||
}
|
||||
|
||||
void Options::save() {
|
||||
@@ -442,34 +442,34 @@ void Options::save() {
|
||||
DataOutputStream dos = DataOutputStream(&fos);
|
||||
// PrintWriter pw = new PrintWriter(new FileWriter(optionsFile));
|
||||
|
||||
dos.writeChars(L"music:" + _toString<float>(music) + L"\n");
|
||||
dos.writeChars(L"sound:" + _toString<float>(sound) + L"\n");
|
||||
dos.writeChars(L"music:" + toWString<float>(music) + L"\n");
|
||||
dos.writeChars(L"sound:" + toWString<float>(sound) + L"\n");
|
||||
dos.writeChars(L"invertYMouse:" +
|
||||
std::wstring(invertYMouse ? L"true" : L"false") + L"\n");
|
||||
dos.writeChars(L"mouseSensitivity:" + _toString<float>(sensitivity));
|
||||
dos.writeChars(L"fov:" + _toString<float>(fov));
|
||||
dos.writeChars(L"gamma:" + _toString<float>(gamma));
|
||||
dos.writeChars(L"viewDistance:" + _toString<int>(viewDistance));
|
||||
dos.writeChars(L"guiScale:" + _toString<int>(guiScale));
|
||||
dos.writeChars(L"particles:" + _toString<int>(particles));
|
||||
dos.writeChars(L"mouseSensitivity:" + toWString<float>(sensitivity));
|
||||
dos.writeChars(L"fov:" + toWString<float>(fov));
|
||||
dos.writeChars(L"gamma:" + toWString<float>(gamma));
|
||||
dos.writeChars(L"viewDistance:" + toWString<int>(viewDistance));
|
||||
dos.writeChars(L"guiScale:" + toWString<int>(guiScale));
|
||||
dos.writeChars(L"particles:" + toWString<int>(particles));
|
||||
dos.writeChars(L"bobView:" + std::wstring(bobView ? L"true" : L"false"));
|
||||
dos.writeChars(L"anaglyph3d:" +
|
||||
std::wstring(anaglyph3d ? L"true" : L"false"));
|
||||
dos.writeChars(L"advancedOpengl:" +
|
||||
std::wstring(advancedOpengl ? L"true" : L"false"));
|
||||
dos.writeChars(L"fpsLimit:" + _toString<int>(framerateLimit));
|
||||
dos.writeChars(L"difficulty:" + _toString<int>(difficulty));
|
||||
dos.writeChars(L"fpsLimit:" + toWString<int>(framerateLimit));
|
||||
dos.writeChars(L"difficulty:" + toWString<int>(difficulty));
|
||||
dos.writeChars(L"fancyGraphics:" +
|
||||
std::wstring(fancyGraphics ? L"true" : L"false"));
|
||||
dos.writeChars(L"ao:" +
|
||||
std::wstring(ambientOcclusion ? L"true" : L"false"));
|
||||
dos.writeChars(L"clouds:" + _toString<bool>(renderClouds));
|
||||
dos.writeChars(L"clouds:" + toWString<bool>(renderClouds));
|
||||
dos.writeChars(L"skin:" + skin);
|
||||
dos.writeChars(L"lastServer:" + lastMpIp);
|
||||
|
||||
for (int i = 0; i < keyMappings_length; i++) {
|
||||
dos.writeChars(L"key_" + keyMappings[i]->name + L":" +
|
||||
_toString<int>(keyMappings[i]->key));
|
||||
toWString<int>(keyMappings[i]->key));
|
||||
}
|
||||
|
||||
dos.close();
|
||||
|
||||
@@ -215,7 +215,7 @@ void CreateWorldScreen::buttonClicked(Button* button) {
|
||||
if (seedString.length() != 0) {
|
||||
// try to convert it to a long first
|
||||
// try { // 4J - removed try/catch
|
||||
int64_t value = _fromString<int64_t>(seedString);
|
||||
int64_t value = fromWString<int64_t>(seedString);
|
||||
|
||||
bool isNumber = true;
|
||||
for (unsigned int i = 0; i < seedString.length(); ++i) {
|
||||
@@ -227,7 +227,7 @@ void CreateWorldScreen::buttonClicked(Button* button) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isNumber) value = _fromString<int64_t>(seedString);
|
||||
if (isNumber) value = fromWString<int64_t>(seedString);
|
||||
|
||||
if (value != 0) {
|
||||
seedValue = value;
|
||||
|
||||
@@ -53,7 +53,7 @@ void DeathScreen::render(int xm, int ym, float a) {
|
||||
drawCenteredString(font, L"Game over!", width / 2 / 2, 60 / 2, 0xffffff);
|
||||
glPopMatrix();
|
||||
drawCenteredString(font,
|
||||
L"Score: &e" + _toString(minecraft->player->getScore()),
|
||||
L"Score: &e" + toWString(minecraft->player->getScore()),
|
||||
width / 2, 100, 0xffffff);
|
||||
|
||||
Screen::render(xm, ym, a);
|
||||
|
||||
@@ -505,7 +505,7 @@ void Font::loadUnicodePage(int page)
|
||||
//try
|
||||
//{
|
||||
// image =
|
||||
ImageIO.read(Textures.class.getResourceAsStream(fileName.toString()));
|
||||
ImageIO.read(Textures.class.getResourceAsStream(fileName.toWString()));
|
||||
//}
|
||||
//catch (IOException e)
|
||||
//{
|
||||
|
||||
@@ -955,7 +955,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
iSafezoneXHalf + 2, 20, 0xffffff);
|
||||
font->drawShadow(
|
||||
L"Seed: " +
|
||||
_toString<int64_t>(minecraft->level->getLevelData()->getSeed()),
|
||||
toWString<int64_t>(minecraft->level->getLevelData()->getSeed()),
|
||||
iSafezoneXHalf + 2, 32 + 00, 0xffffff);
|
||||
font->drawShadow(minecraft->gatherStats1(), iSafezoneXHalf + 2, 32 + 10,
|
||||
0xffffff);
|
||||
@@ -981,8 +981,8 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
FEATURE_DATA* pFeatureData = app.m_vTerrainFeatures[i];
|
||||
|
||||
std::wstring itemInfo =
|
||||
L"[" + _toString<int>(pFeatureData->x * 16) + L", " +
|
||||
_toString<int>(pFeatureData->z * 16) + L"] ";
|
||||
L"[" + toWString<int>(pFeatureData->x * 16) + L", " +
|
||||
toWString<int>(pFeatureData->z * 16) + L"] ";
|
||||
wfeature[pFeatureData->eTerrainFeature] += itemInfo;
|
||||
}
|
||||
|
||||
@@ -1014,28 +1014,28 @@ max) + "% (" + (total / 1024 / 1024) + "MB)"; drawString(font, msg, screenWidth
|
||||
double yBlockPos = floor(minecraft->player->y);
|
||||
double zBlockPos = floor(minecraft->player->z);
|
||||
drawString(font,
|
||||
L"x: " + _toString<double>(minecraft->player->x) +
|
||||
L"/ Head: " + _toString<double>(xBlockPos) +
|
||||
L"x: " + toWString<double>(minecraft->player->x) +
|
||||
L"/ Head: " + toWString<double>(xBlockPos) +
|
||||
L"/ Chunk: " +
|
||||
_toString<double>(minecraft->player->xChunk),
|
||||
toWString<double>(minecraft->player->xChunk),
|
||||
iSafezoneXHalf + 2, iYPos + 8 * 0, 0xe0e0e0);
|
||||
drawString(font,
|
||||
L"y: " + _toString<double>(minecraft->player->y) +
|
||||
L"/ Head: " + _toString<double>(yBlockPos),
|
||||
L"y: " + toWString<double>(minecraft->player->y) +
|
||||
L"/ Head: " + toWString<double>(yBlockPos),
|
||||
iSafezoneXHalf + 2, iYPos + 8 * 1, 0xe0e0e0);
|
||||
drawString(font,
|
||||
L"z: " + _toString<double>(minecraft->player->z) +
|
||||
L"/ Head: " + _toString<double>(zBlockPos) +
|
||||
L"z: " + toWString<double>(minecraft->player->z) +
|
||||
L"/ Head: " + toWString<double>(zBlockPos) +
|
||||
L"/ Chunk: " +
|
||||
_toString<double>(minecraft->player->zChunk),
|
||||
toWString<double>(minecraft->player->zChunk),
|
||||
iSafezoneXHalf + 2, iYPos + 8 * 2, 0xe0e0e0);
|
||||
drawString(
|
||||
font,
|
||||
L"f: " +
|
||||
_toString<double>(
|
||||
toWString<double>(
|
||||
Mth::floor(minecraft->player->yRot * 4.0f / 360.0f + 0.5) &
|
||||
0x3) +
|
||||
L"/ yRot: " + _toString<double>(minecraft->player->yRot),
|
||||
L"/ yRot: " + toWString<double>(minecraft->player->yRot),
|
||||
iSafezoneXHalf + 2, iYPos + 8 * 3, 0xe0e0e0);
|
||||
iYPos += 8 * 4;
|
||||
|
||||
@@ -1049,7 +1049,7 @@ max) + "% (" + (total / 1024 / 1024) + "MB)"; drawString(font, msg, screenWidth
|
||||
px & 15, pz & 15, minecraft->level->getBiomeSource());
|
||||
drawString(font,
|
||||
L"b: " + biome->m_name + L" (" +
|
||||
_toString<int>(biome->id) + L")",
|
||||
toWString<int>(biome->id) + L")",
|
||||
iSafezoneXHalf + 2, iYPos, 0xe0e0e0);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ void JoinMultiplayerScreen::buttonClicked(Button* button) {
|
||||
}
|
||||
|
||||
int JoinMultiplayerScreen::parseInt(const std::wstring& str, int def) {
|
||||
return _fromString<int>(str);
|
||||
return fromWString<int>(str);
|
||||
}
|
||||
|
||||
void JoinMultiplayerScreen::keyPressed(wchar_t ch, int eventKey) {
|
||||
|
||||
@@ -65,7 +65,7 @@ std::wstring SelectWorldScreen::getWorldName(int id) {
|
||||
if (levelName.length() == 0) {
|
||||
Language* language = Language::getInstance();
|
||||
levelName = language->getElement(L"selectWorld.world") + L" " +
|
||||
_toString<int>(id + 1);
|
||||
toWString<int>(id + 1);
|
||||
}
|
||||
|
||||
return levelName;
|
||||
@@ -142,7 +142,7 @@ void SelectWorldScreen::worldSelected(int id) {
|
||||
std::wstring worldFolderName = getWorldId(id);
|
||||
if (worldFolderName == L"") // 4J - was nullptr comparison
|
||||
{
|
||||
worldFolderName = L"World" + _toString<int>(id);
|
||||
worldFolderName = L"World" + toWString<int>(id);
|
||||
}
|
||||
// 4J Stu - Not used, so commenting to stop the build failing
|
||||
}
|
||||
@@ -253,7 +253,7 @@ void SelectWorldScreen::WorldSelectionList::renderItem(int i, int x, int y,
|
||||
|
||||
std::wstring name = levelSummary->getLevelName();
|
||||
if (name.length() == 0) {
|
||||
name = parent->worldLang + L" " + _toString<int>(i + 1);
|
||||
name = parent->worldLang + L" " + toWString<int>(i + 1);
|
||||
}
|
||||
|
||||
std::wstring id = levelSummary->getLevelId();
|
||||
@@ -276,7 +276,7 @@ void SelectWorldScreen::WorldSelectionList::renderItem(int i, int x, int y,
|
||||
id = id + L" (" + buffer;
|
||||
|
||||
int64_t size = levelSummary->getSizeOnDisk();
|
||||
id = id + L", " + _toString<float>(size / 1024 * 100 / 1024 / 100.0f) +
|
||||
id = id + L", " + toWString<float>(size / 1024 * 100 / 1024 / 100.0f) +
|
||||
L" MB)";
|
||||
std::wstring info;
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ std::wstring MultiPlayerChunkCache::gatherStats() {
|
||||
std::lock_guard<std::mutex> lock(m_csLoadCreate);
|
||||
size = (int)loadedChunkList.size();
|
||||
}
|
||||
return L"MultiplayerChunkCache: " + _toString<int>(size);
|
||||
return L"MultiplayerChunkCache: " + toWString<int>(size);
|
||||
}
|
||||
|
||||
void MultiPlayerChunkCache::dataReceived(int x, int z) {
|
||||
|
||||
@@ -288,5 +288,5 @@ std::wstring ParticleEngine::countParticles() {
|
||||
total += particles[l][tt][list].size();
|
||||
}
|
||||
}
|
||||
return _toString<int>(total);
|
||||
return toWString<int>(total);
|
||||
}
|
||||
|
||||
@@ -674,18 +674,18 @@ void LevelRenderer::renderEntities(Vec3* cam, Culler* culler, float a) {
|
||||
}
|
||||
|
||||
std::wstring LevelRenderer::gatherStats1() {
|
||||
return L"C: " + _toString<int>(renderedChunks) + L"/" +
|
||||
_toString<int>(totalChunks) + L". F: " +
|
||||
_toString<int>(offscreenChunks) + L", O: " +
|
||||
_toString<int>(occludedChunks) + L", E: " +
|
||||
_toString<int>(emptyChunks);
|
||||
return L"C: " + toWString<int>(renderedChunks) + L"/" +
|
||||
toWString<int>(totalChunks) + L". F: " +
|
||||
toWString<int>(offscreenChunks) + L", O: " +
|
||||
toWString<int>(occludedChunks) + L", E: " +
|
||||
toWString<int>(emptyChunks);
|
||||
}
|
||||
|
||||
std::wstring LevelRenderer::gatherStats2() {
|
||||
return L"E: " + _toString<int>(renderedEntities) + L"/" +
|
||||
_toString<int>(totalEntities) + L". B: " +
|
||||
_toString<int>(culledEntities) + L", I: " +
|
||||
_toString<int>((totalEntities - culledEntities) - renderedEntities);
|
||||
return L"E: " + toWString<int>(renderedEntities) + L"/" +
|
||||
toWString<int>(totalEntities) + L". B: " +
|
||||
toWString<int>(culledEntities) + L", I: " +
|
||||
toWString<int>((totalEntities - culledEntities) - renderedEntities);
|
||||
}
|
||||
|
||||
void LevelRenderer::resortChunks(int xc, int yc, int zc) {
|
||||
@@ -3618,7 +3618,7 @@ void LevelRenderer::registerTextures(IconRegister* iconRegister) {
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
breakingTextures[i] =
|
||||
iconRegister->registerIcon(L"destroy_" + _toString(i));
|
||||
iconRegister->registerIcon(L"destroy_" + toWString(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ ResourceLocation* HumanoidMobRenderer::getArmorLocation(ArmorItem* armorItem,
|
||||
std::wstring path =
|
||||
std::wstring(L"armor/" + MATERIAL_NAMES[armorItem->modelIndex])
|
||||
.append(L"_")
|
||||
.append(_toString<int>(layer == 2 ? 2 : 1))
|
||||
.append(toWString<int>(layer == 2 ? 2 : 1))
|
||||
.append((overlay ? L"_b" : L""))
|
||||
.append(L".png");
|
||||
|
||||
|
||||
@@ -597,9 +597,9 @@ void ItemRenderer::renderGuiItemDecorations(Font* font, Textures* textures,
|
||||
if (amount.empty()) {
|
||||
int count = item->count;
|
||||
if (count > 64) {
|
||||
amount = _toString<int>(64) + L"+";
|
||||
amount = toWString<int>(64) + L"+";
|
||||
} else {
|
||||
amount = _toString<int>(item->count);
|
||||
amount = toWString<int>(item->count);
|
||||
}
|
||||
}
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
@@ -137,8 +137,8 @@ void StitchSlot::collectAssignments(std::vector<StitchSlot*>* result) {
|
||||
|
||||
//@Override
|
||||
std::wstring StitchSlot::toString() {
|
||||
return L"Slot{originX=" + _toString(originX) + L", originY=" +
|
||||
_toString(originY) + L", width=" + _toString(width) + L", height=" +
|
||||
_toString(height) + L", texture=" + _toString(textureHolder) +
|
||||
L", subSlots=" + _toString(subSlots) + L'}';
|
||||
return L"Slot{originX=" + toWString(originX) + L", originY=" +
|
||||
toWString(originY) + L", width=" + toWString(width) + L", height=" +
|
||||
toWString(height) + L", texture=" + toWString(textureHolder) +
|
||||
L", subSlots=" + toWString(subSlots) + L'}';
|
||||
}
|
||||
@@ -226,11 +226,11 @@ void StitchedTexture::loadAnimationFrames(BufferedReader* bufferedReader) {
|
||||
std::wstring token = *it;
|
||||
int multiPos = token.find_first_of('*');
|
||||
if (multiPos > 0) {
|
||||
int frame = _fromString<int>(token.substr(0, multiPos));
|
||||
int count = _fromString<int>(token.substr(multiPos + 1));
|
||||
int frame = fromWString<int>(token.substr(0, multiPos));
|
||||
int count = fromWString<int>(token.substr(multiPos + 1));
|
||||
results->push_back(intPairVector::value_type(frame, count));
|
||||
} else {
|
||||
int tokenVal = _fromString<int>(token);
|
||||
int tokenVal = fromWString<int>(token);
|
||||
results->push_back(intPairVector::value_type(tokenVal, 1));
|
||||
}
|
||||
}
|
||||
@@ -266,11 +266,11 @@ void StitchedTexture::loadAnimationFrames(const std::wstring& string) {
|
||||
std::wstring token = trimString(*it);
|
||||
int multiPos = token.find_first_of('*');
|
||||
if (multiPos > 0) {
|
||||
int frame = _fromString<int>(token.substr(0, multiPos));
|
||||
int count = _fromString<int>(token.substr(multiPos + 1));
|
||||
int frame = fromWString<int>(token.substr(0, multiPos));
|
||||
int count = fromWString<int>(token.substr(multiPos + 1));
|
||||
results->push_back(intPairVector::value_type(frame, count));
|
||||
} else if (!token.empty()) {
|
||||
int tokenVal = _fromString<int>(token);
|
||||
int tokenVal = fromWString<int>(token);
|
||||
results->push_back(intPairVector::value_type(tokenVal, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ void TextureHolder::setForcedScale(int targetSize) {
|
||||
|
||||
//@Override
|
||||
std::wstring TextureHolder::toString() {
|
||||
return L"TextureHolder{width=" + _toString(width) + L", height=" +
|
||||
_toString(height) + L'}';
|
||||
return L"TextureHolder{width=" + toWString(width) + L", height=" +
|
||||
toWString(height) + L'}';
|
||||
}
|
||||
|
||||
int TextureHolder::compareTo(const TextureHolder* other) const {
|
||||
|
||||
@@ -362,7 +362,7 @@ bool Connection::readTick() {
|
||||
void handleException(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
close("disconnect.genericReason", "Internal exception: " + e.toString());
|
||||
close("disconnect.genericReason", "Internal exception: " + e.toWString());
|
||||
}*/
|
||||
|
||||
void Connection::close(DisconnectPacket::eDisconnectReason reason) {
|
||||
|
||||
@@ -519,13 +519,13 @@ std::shared_ptr<Packet> Packet::readPacket(
|
||||
__debugbreak();
|
||||
assert(false);
|
||||
// throw new IOException(wstring(L"Bad packet id ") +
|
||||
// _toString<int>(id));
|
||||
// toWString<int>(id));
|
||||
}
|
||||
|
||||
packet = getPacket(id);
|
||||
if (packet == nullptr)
|
||||
assert(false); // throw new IOException(wstring(L"Bad packet id ") +
|
||||
// _toString<int>(id));
|
||||
// toWString<int>(id));
|
||||
|
||||
// app.DebugPrintf("%s reading packet %d\n", isServer ? "Server" : "Client",
|
||||
// packet->getId());
|
||||
|
||||
@@ -20,22 +20,22 @@ std::wstring Settings::getString(const std::wstring& key,
|
||||
|
||||
int Settings::getInt(const std::wstring& key, int defaultValue) {
|
||||
if (properties.find(key) == properties.end()) {
|
||||
properties[key] = _toString<int>(defaultValue);
|
||||
properties[key] = toWString<int>(defaultValue);
|
||||
saveProperties();
|
||||
}
|
||||
return _fromString<int>(properties[key]);
|
||||
return fromWString<int>(properties[key]);
|
||||
}
|
||||
|
||||
bool Settings::getBoolean(const std::wstring& key, bool defaultValue) {
|
||||
if (properties.find(key) == properties.end()) {
|
||||
properties[key] = _toString<bool>(defaultValue);
|
||||
properties[key] = toWString<bool>(defaultValue);
|
||||
saveProperties();
|
||||
}
|
||||
bool retval = _fromString<bool>(properties[key]);
|
||||
bool retval = fromWString<bool>(properties[key]);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void Settings::setBooleanAndSave(const std::wstring& key, bool value) {
|
||||
properties[key] = _toString<bool>(value);
|
||||
properties[key] = toWString<bool>(value);
|
||||
saveProperties();
|
||||
}
|
||||
@@ -26,7 +26,7 @@ void DemoMode::tick() {
|
||||
if (day <= (DEMO_DAYS + 1))
|
||||
{
|
||||
minecraft->gui->displayClientMessage(L"demo.day." +
|
||||
_toString<int64_t>(day));
|
||||
toWString<int64_t>(day));
|
||||
}
|
||||
}
|
||||
else if (day == 1)
|
||||
|
||||
@@ -821,8 +821,8 @@ bool ServerChunkCache::tick() {
|
||||
bool ServerChunkCache::shouldSave() { return !level->noSave; }
|
||||
|
||||
std::wstring ServerChunkCache::gatherStats() {
|
||||
return L"ServerChunkCache: "; // + _toString<int>(loadedChunks.size()) + L"
|
||||
// Drop: " + _toString<int>(toDrop.size());
|
||||
return L"ServerChunkCache: "; // + toWString<int>(loadedChunks.size()) + L"
|
||||
// Drop: " + toWString<int>(toDrop.size());
|
||||
}
|
||||
|
||||
std::vector<Biome::MobSpawnerData*>* ServerChunkCache::getMobsAt(
|
||||
|
||||
@@ -28,7 +28,7 @@ void ServerConnection::NewIncomingSocket(Socket* socket) {
|
||||
std::shared_ptr<PendingConnection> unconnectedClient =
|
||||
std::make_shared<PendingConnection>(
|
||||
server, socket,
|
||||
L"Connection #" + _toString<int>(connectionCounter++));
|
||||
L"Connection #" + toWString<int>(connectionCounter++));
|
||||
handleConnection(unconnectedClient);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ std::wstring Stat::TimeFormatter::format(int value) {
|
||||
return decimalFormat->format(minutes) + L" m";
|
||||
}
|
||||
|
||||
return _toString<double>(seconds) + L" s";
|
||||
return toWString<double>(seconds) + L" s";
|
||||
}
|
||||
|
||||
std::wstring Stat::DefaultFormat::format(int value) {
|
||||
@@ -90,5 +90,5 @@ std::wstring Stat::DistanceFormatter::format(int cm) {
|
||||
} else if (meters > 0.5) {
|
||||
return decimalFormat->format(meters) + L" m";
|
||||
}
|
||||
return _toString<int>(cm) + L" cm";
|
||||
return toWString<int>(cm) + L" cm";
|
||||
}
|
||||
|
||||
@@ -624,7 +624,7 @@ void Stats::buildAdditionalStats() {
|
||||
rainbowCollection = std::vector<Stat*>(16);
|
||||
for (unsigned int i = 0; i < 16; i++) {
|
||||
generalStat = new GeneralStat(
|
||||
offset++, L"rainbowCollection." + _toString<unsigned int>(i));
|
||||
offset++, L"rainbowCollection." + toWString<unsigned int>(i));
|
||||
generalStats->push_back(generalStat);
|
||||
rainbowCollection[i] = generalStat;
|
||||
generalStat->postConstruct();
|
||||
@@ -633,7 +633,7 @@ void Stats::buildAdditionalStats() {
|
||||
biomesVisisted = std::vector<Stat*>(23);
|
||||
for (unsigned int i = 0; i < 23; i++) {
|
||||
generalStat = new GeneralStat(
|
||||
offset++, L"biomesVisited." + _toString<unsigned int>(i));
|
||||
offset++, L"biomesVisited." + toWString<unsigned int>(i));
|
||||
generalStats->push_back(generalStat);
|
||||
biomesVisisted[i] = generalStat;
|
||||
generalStat->postConstruct();
|
||||
|
||||
@@ -22,7 +22,7 @@ std::wstring Hasher::getHash(std::wstring& name) {
|
||||
// return new BigInteger(1, m.digest()).toString(16);
|
||||
|
||||
// TODO 4J Stu - Will this hash us with the same distribution as the MD5?
|
||||
return _toString(hash_value(s));
|
||||
return toString(hash_value(s));
|
||||
//}
|
||||
// catch (NoSuchAlgorithmException e)
|
||||
//{
|
||||
|
||||
@@ -1737,7 +1737,7 @@ std::wstring Entity::getAName() {
|
||||
#ifdef _DEBUG
|
||||
std::wstring id = EntityIO::getEncodeId(shared_from_this());
|
||||
if (id.empty()) id = L"generic";
|
||||
return L"entity." + id + _toString(entityId);
|
||||
return L"entity." + id + toWString(entityId);
|
||||
#else
|
||||
return L"";
|
||||
#endif
|
||||
|
||||
@@ -244,7 +244,7 @@ void Mob::addAdditonalSaveData(CompoundTag* entityTag) {
|
||||
|
||||
ListTag<FloatTag>* dropChanceList = new ListTag<FloatTag>();
|
||||
for (int i = 0; i < dropChances.size(); i++) {
|
||||
dropChanceList->add(new FloatTag(_toString(i), dropChances[i]));
|
||||
dropChanceList->add(new FloatTag(toWString(i), dropChances[i]));
|
||||
}
|
||||
entityTag->put(L"DropChances", dropChanceList);
|
||||
entityTag->putString(L"CustomName", getCustomName());
|
||||
|
||||
@@ -650,7 +650,7 @@ void EntityHorse::rebuildLayeredTextureInfo() {
|
||||
}
|
||||
} else {
|
||||
layerTextureLayers[0] = -1;
|
||||
layerTextureHashName += L"_" + _toString<int>(type) + L"_";
|
||||
layerTextureHashName += L"_" + toWString<int>(type) + L"_";
|
||||
armorIndex = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ Player::Player(Level* level, const std::wstring& name) : LivingEntity(level) {
|
||||
rotOffs = 180;
|
||||
flameTime = 20;
|
||||
|
||||
m_skinIndex = eDefaultSkins_Skin0;
|
||||
m_skinIndex = EDefaultSkins::Skin0;
|
||||
m_playerIndex = 0;
|
||||
m_dwSkinId = 0;
|
||||
m_dwCapeId = 0;
|
||||
@@ -533,7 +533,7 @@ void Player::ride(std::shared_ptr<Entity> e) {
|
||||
|
||||
void Player::setPlayerDefaultSkin(EDefaultSkins skin) {
|
||||
#if !defined(_CONTENT_PACKAGE)
|
||||
wprintf(L"Setting default skin to %d for player %ls\n", skin, name.c_str());
|
||||
wprintf(L"Setting default skin to %d for player %ls\n", std::to_underlying(skin), name.c_str());
|
||||
#endif
|
||||
m_skinIndex = skin;
|
||||
}
|
||||
@@ -543,7 +543,7 @@ void Player::setCustomSkin(std::uint32_t skinId) {
|
||||
wprintf(L"Attempting to set skin to %08X for player %ls\n", skinId,
|
||||
name.c_str());
|
||||
#endif
|
||||
EDefaultSkins playerSkin = eDefaultSkins_ServerSelected;
|
||||
EDefaultSkins playerSkin = EDefaultSkins::ServerSelected;
|
||||
|
||||
// reset the idle
|
||||
setIsIdle(false);
|
||||
@@ -556,12 +556,12 @@ void Player::setCustomSkin(std::uint32_t skinId) {
|
||||
std::uint32_t defaultSkinIndex =
|
||||
GET_DEFAULT_SKIN_ID_FROM_BITMASK(skinId);
|
||||
if (ugcSkinIndex == 0 && defaultSkinIndex > 0) {
|
||||
playerSkin = (EDefaultSkins)defaultSkinIndex;
|
||||
playerSkin = static_cast<EDefaultSkins>(defaultSkinIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (playerSkin == eDefaultSkins_ServerSelected) {
|
||||
playerSkin = (EDefaultSkins)(m_playerIndex + 1);
|
||||
if (playerSkin == EDefaultSkins::ServerSelected) {
|
||||
playerSkin = static_cast<EDefaultSkins>(m_playerIndex + 1);
|
||||
}
|
||||
|
||||
// We always set a default skin, since we may be waiting for the player's
|
||||
@@ -2266,21 +2266,21 @@ float Player::getAbsorptionAmount() {
|
||||
|
||||
int Player::getTexture() {
|
||||
switch (m_skinIndex) {
|
||||
case eDefaultSkins_Skin0:
|
||||
case EDefaultSkins::Skin0:
|
||||
return TN_MOB_CHAR; // 4J - was L"/mob/char.png";
|
||||
case eDefaultSkins_Skin1:
|
||||
case EDefaultSkins::Skin1:
|
||||
return TN_MOB_CHAR1; // 4J - was L"/mob/char1.png";
|
||||
case eDefaultSkins_Skin2:
|
||||
case EDefaultSkins::Skin2:
|
||||
return TN_MOB_CHAR2; // 4J - was L"/mob/char2.png";
|
||||
case eDefaultSkins_Skin3:
|
||||
case EDefaultSkins::Skin3:
|
||||
return TN_MOB_CHAR3; // 4J - was L"/mob/char3.png";
|
||||
case eDefaultSkins_Skin4:
|
||||
case EDefaultSkins::Skin4:
|
||||
return TN_MOB_CHAR4; // 4J - was L"/mob/char4.png";
|
||||
case eDefaultSkins_Skin5:
|
||||
case EDefaultSkins::Skin5:
|
||||
return TN_MOB_CHAR5; // 4J - was L"/mob/char5.png";
|
||||
case eDefaultSkins_Skin6:
|
||||
case EDefaultSkins::Skin6:
|
||||
return TN_MOB_CHAR6; // 4J - was L"/mob/char6.png";
|
||||
case eDefaultSkins_Skin7:
|
||||
case EDefaultSkins::Skin7:
|
||||
return TN_MOB_CHAR7; // 4J - was L"/mob/char7.png";
|
||||
|
||||
default:
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
enum EDefaultSkins {
|
||||
eDefaultSkins_ServerSelected,
|
||||
eDefaultSkins_Skin0,
|
||||
eDefaultSkins_Skin1,
|
||||
eDefaultSkins_Skin2,
|
||||
eDefaultSkins_Skin3,
|
||||
eDefaultSkins_Skin4,
|
||||
eDefaultSkins_Skin5,
|
||||
eDefaultSkins_Skin6,
|
||||
eDefaultSkins_Skin7,
|
||||
#include <cstdint>
|
||||
|
||||
eDefaultSkins_Count,
|
||||
enum class EDefaultSkins : std::uint8_t {
|
||||
ServerSelected,
|
||||
Skin0,
|
||||
Skin1,
|
||||
Skin2,
|
||||
Skin3,
|
||||
Skin4,
|
||||
Skin5,
|
||||
Skin6,
|
||||
Skin7,
|
||||
|
||||
Count,
|
||||
};
|
||||
|
||||
@@ -66,7 +66,7 @@ void FireworksItem::appendHoverText(std::shared_ptr<ItemInstance> itemInstance,
|
||||
if (fireTag->contains(TAG_FLIGHT)) {
|
||||
lines->push_back(
|
||||
std::wstring(app.GetString(IDS_ITEM_FIREWORKS_FLIGHT)) + L" " +
|
||||
_toString<int>((fireTag->getByte(TAG_FLIGHT))));
|
||||
toWString<int>((fireTag->getByte(TAG_FLIGHT))));
|
||||
}
|
||||
|
||||
ListTag<CompoundTag>* explosions =
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
typedef Item::Tier _Tier;
|
||||
|
||||
// const UUID Item::BASE_ATTACK_DAMAGE_UUID =
|
||||
// UUID::fromString(L"CB3F55D3-645C-4F38-A497-9C13A33DB5CF");
|
||||
// UUID::fromWString(L"CB3F55D3-645C-4F38-A497-9C13A33DB5CF");
|
||||
|
||||
std::wstring Item::ICON_DESCRIPTION_PREFIX = L"item.";
|
||||
|
||||
|
||||
@@ -514,7 +514,7 @@ std::vector<std::wstring>* ItemInstance::getHoverText(
|
||||
//{
|
||||
// if (id == Item::map_Id)
|
||||
// {
|
||||
// title += L" #" + _toString(auxValue);
|
||||
// title += L" #" + toWString(auxValue);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -579,7 +579,7 @@ std::vector<HtmlString>* ItemInstance::getHoverText(
|
||||
|
||||
/*if (!hasCustomHoverName() && id == Item::map_Id)
|
||||
{
|
||||
title.text += L" #" + _toString(auxValue);
|
||||
title.text += L" #" + toWString(auxValue);
|
||||
}*/
|
||||
|
||||
lines->push_back(title);
|
||||
@@ -661,8 +661,8 @@ std::vector<HtmlString>* ItemInstance::getHoverText(
|
||||
if (isDamaged()) {
|
||||
std::wstring damageStr =
|
||||
L"Durability: LOCALISE " +
|
||||
_toString<int>((getMaxDamage()) - getDamageValue()) + L" / " +
|
||||
_toString<int>(getMaxDamage());
|
||||
toWString<int>((getMaxDamage()) - getDamageValue()) + L" / " +
|
||||
toWString<int>(getMaxDamage());
|
||||
lines->push_back(HtmlString(damageStr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ MapItem::MapItem(int id) : ComplexItem(id) { setStackedByData(true); }
|
||||
|
||||
std::shared_ptr<MapItemSavedData> MapItem::getSavedData(short idNum,
|
||||
Level* level) {
|
||||
std::wstring id = std::wstring(L"map_") + _toString(idNum);
|
||||
std::wstring id = std::wstring(L"map_") + toWString(idNum);
|
||||
std::shared_ptr<MapItemSavedData> mapItemSavedData =
|
||||
std::dynamic_pointer_cast<MapItemSavedData>(
|
||||
level->getSavedData(typeid(MapItemSavedData), id));
|
||||
@@ -45,7 +45,7 @@ std::shared_ptr<MapItemSavedData> MapItem::getSavedData(short idNum,
|
||||
// int aux = level->getFreeAuxValueFor(L"map");
|
||||
int aux = idNum;
|
||||
|
||||
id = std::wstring(L"map_") + _toString(aux);
|
||||
id = std::wstring(L"map_") + toWString(aux);
|
||||
mapItemSavedData = std::make_shared<MapItemSavedData>(id);
|
||||
|
||||
level->setSavedData(id, (std::shared_ptr<SavedData>)mapItemSavedData);
|
||||
@@ -57,7 +57,7 @@ std::shared_ptr<MapItemSavedData> MapItem::getSavedData(short idNum,
|
||||
std::shared_ptr<MapItemSavedData> MapItem::getSavedData(
|
||||
std::shared_ptr<ItemInstance> itemInstance, Level* level) {
|
||||
std::wstring id =
|
||||
std::wstring(L"map_") + _toString(itemInstance->getAuxValue());
|
||||
std::wstring(L"map_") + toWString(itemInstance->getAuxValue());
|
||||
std::shared_ptr<MapItemSavedData> mapItemSavedData =
|
||||
std::dynamic_pointer_cast<MapItemSavedData>(
|
||||
level->getSavedData(typeid(MapItemSavedData), id));
|
||||
@@ -69,7 +69,7 @@ std::shared_ptr<MapItemSavedData> MapItem::getSavedData(
|
||||
// map setup
|
||||
// itemInstance->setAuxValue(level->getFreeAuxValueFor(L"map"));
|
||||
|
||||
id = std::wstring(L"map_") + _toString(itemInstance->getAuxValue());
|
||||
id = std::wstring(L"map_") + toWString(itemInstance->getAuxValue());
|
||||
mapItemSavedData = std::make_shared<MapItemSavedData>(id);
|
||||
|
||||
newData = true;
|
||||
|
||||
@@ -52,7 +52,7 @@ TilePos ChunkPos::getMiddleBlockPosition(int y) {
|
||||
}
|
||||
|
||||
std::wstring ChunkPos::toString() {
|
||||
return L"[" + _toString<int>(x) + L", " + _toString<int>(z) + L"]";
|
||||
return L"[" + toWString<int>(x) + L", " + toWString<int>(z) + L"]";
|
||||
}
|
||||
|
||||
int64_t ChunkPos::hash_fnct(const ChunkPos& k) { return k.hashCode(k.x, k.z); }
|
||||
|
||||
@@ -167,9 +167,9 @@ GameRules::GameRule::GameRule(const std::wstring &startValue)
|
||||
void GameRules::GameRule::set(const std::wstring &newValue)
|
||||
{
|
||||
value = newValue;
|
||||
booleanValue = _fromString<bool>(newValue);
|
||||
intValue = _fromString<int>(newValue);
|
||||
doubleValue = _fromString<double>(newValue);
|
||||
booleanValue = fromWString<bool>(newValue);
|
||||
intValue = fromWString<int>(newValue);
|
||||
doubleValue = fromWString<double>(newValue);
|
||||
}
|
||||
|
||||
std::wstring GameRules::GameRule::get()
|
||||
|
||||
@@ -1200,7 +1200,7 @@ int CompressedTileStorage::getHighestNonEmptyY() {
|
||||
void CompressedTileStorage::write(DataOutputStream* dos) {
|
||||
dos->writeInt(allocatedSize);
|
||||
if (indicesAndData) {
|
||||
if (LOCALSYSTEM_ENDIAN == BIGENDIAN) {
|
||||
if (std::endian::native == std::endian::big) {
|
||||
// The first 1024 bytes are an array of shorts, so we need to
|
||||
// reverse the endianness
|
||||
std::vector<uint8_t> indicesCopy(1024);
|
||||
@@ -1236,7 +1236,7 @@ void CompressedTileStorage::read(DataInputStream* dis) {
|
||||
std::vector<uint8_t> wrapper(allocatedSize);
|
||||
dis->readFully(wrapper);
|
||||
memcpy(indicesAndData, wrapper.data(), allocatedSize);
|
||||
if (LOCALSYSTEM_ENDIAN == BIGENDIAN) {
|
||||
if (std::endian::native == std::endian::big) {
|
||||
reverseIndices(indicesAndData);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,15 +33,15 @@ RegionFile* RegionFileCache::_getRegionFile(
|
||||
|
||||
// File regionDir(basePath, L"region");
|
||||
|
||||
// File file(regionDir, wstring(L"r.") + _toString(chunkX>>5) + L"." +
|
||||
// _toString(chunkZ>>5) + L".mcr" );
|
||||
// File file(regionDir, wstring(L"r.") + toWString(chunkX>>5) + L"." +
|
||||
// toWString(chunkZ>>5) + L".mcr" );
|
||||
File file;
|
||||
if (useSplitSaves(saveFile->getSavePlatform())) {
|
||||
file = File(prefix + std::wstring(L"r.") + _toString(chunkX >> 4) +
|
||||
L"." + _toString(chunkZ >> 4) + L".mcr");
|
||||
file = File(prefix + std::wstring(L"r.") + toWString(chunkX >> 4) +
|
||||
L"." + toWString(chunkZ >> 4) + L".mcr");
|
||||
} else {
|
||||
file = File(prefix + std::wstring(L"r.") + _toString(chunkX >> 5) +
|
||||
L"." + _toString(chunkZ >> 5) + L".mcr");
|
||||
file = File(prefix + std::wstring(L"r.") + toWString(chunkX >> 5) +
|
||||
L"." + toWString(chunkZ >> 5) + L".mcr");
|
||||
}
|
||||
|
||||
RegionFile* ref = nullptr;
|
||||
|
||||
@@ -31,7 +31,7 @@ const int ZonedChunkStorage::CHUNK_SIZE_BYTES =
|
||||
ZonedChunkStorage::CHUNK_SIZE * ZonedChunkStorage::CHUNK_LAYERS +
|
||||
ZonedChunkStorage::CHUNK_HEADER_SIZE;
|
||||
|
||||
const ByteOrder ZonedChunkStorage::BYTEORDER = BIGENDIAN;
|
||||
const std::endian ZonedChunkStorage::BYTEORDER = std::endian::big;
|
||||
|
||||
ZonedChunkStorage::ZonedChunkStorage(File dir) {
|
||||
tickCount = 0;
|
||||
@@ -62,8 +62,8 @@ ZoneFile* ZonedChunkStorage::getZoneFile(int x, int z, bool create) {
|
||||
wchar_t zRadix36[64];
|
||||
_itow(x, xRadix36, 36);
|
||||
_itow(z, zRadix36, 36);
|
||||
File file = File(dir, std::wstring(L"zone_") + _toString(xRadix36) +
|
||||
L"_" + _toString(zRadix36) + L".dat");
|
||||
File file = File(dir, std::wstring(L"zone_") + toString(xRadix36) +
|
||||
L"_" + toString(zRadix36) + L".dat");
|
||||
|
||||
if (!file.exists()) {
|
||||
if (!create) return nullptr;
|
||||
@@ -74,8 +74,8 @@ ZoneFile* ZonedChunkStorage::getZoneFile(int x, int z, bool create) {
|
||||
}
|
||||
|
||||
File entityFile =
|
||||
File(dir, std::wstring(L"entities_") + _toString(xRadix36) + L"_" +
|
||||
_toString(zRadix36) + L".dat");
|
||||
File(dir, std::wstring(L"entities_") + toString(xRadix36) + L"_" +
|
||||
toString(zRadix36) + L".dat");
|
||||
|
||||
zoneFiles[key] = new ZoneFile(key, file, entityFile);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
static const int CHUNK_LAYERS;
|
||||
static const int CHUNK_SIZE_BYTES;
|
||||
|
||||
static const ByteOrder BYTEORDER;
|
||||
static const std::endian BYTEORDER;
|
||||
|
||||
File dir;
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@ int FlatLayerInfo::getStart() { return start; }
|
||||
void FlatLayerInfo::setStart(int start) { this->start = start; }
|
||||
|
||||
std::wstring FlatLayerInfo::toString() {
|
||||
std::wstring result = _toString<int>(id);
|
||||
std::wstring result = toWString<int>(id);
|
||||
|
||||
if (height > 1) {
|
||||
result = _toString<int>(height) + L"x" + result;
|
||||
result = toWString<int>(height) + L"x" + result;
|
||||
}
|
||||
if (data > 0) {
|
||||
result += L":" + _toString<int>(data);
|
||||
result += L":" + toWString<int>(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -167,9 +167,9 @@ int BoundingBox::getYCenter() { return y0 + (y1 - y0 + 1) / 2; }
|
||||
int BoundingBox::getZCenter() { return z0 + (z1 - z0 + 1) / 2; }
|
||||
|
||||
std::wstring BoundingBox::toString() {
|
||||
return L"(" + _toString<int>(x0) + L", " + _toString<int>(y0) + L", " +
|
||||
_toString<int>(z0) + L"; " + _toString<int>(x1) + L", " +
|
||||
_toString<int>(y1) + L", " + _toString<int>(z1) + L")";
|
||||
return L"(" + toWString<int>(x0) + L", " + toWString<int>(y0) + L", " +
|
||||
toWString<int>(z0) + L"; " + toWString<int>(x1) + L", " +
|
||||
toWString<int>(y1) + L", " + toWString<int>(z1) + L")";
|
||||
}
|
||||
|
||||
IntArrayTag* BoundingBox::createTag(const std::wstring& name) {
|
||||
|
||||
@@ -283,12 +283,12 @@ StrongholdPieces::StrongholdPiece::StrongholdPiece(int genDepth)
|
||||
}
|
||||
|
||||
void StrongholdPieces::StrongholdPiece::addAdditonalSaveData(CompoundTag* tag) {
|
||||
tag->putString(L"EntryDoor", _toString<int>(entryDoor));
|
||||
tag->putString(L"EntryDoor", toWString<int>(entryDoor));
|
||||
}
|
||||
|
||||
void StrongholdPieces::StrongholdPiece::readAdditonalSaveData(
|
||||
CompoundTag* tag) {
|
||||
entryDoor = (SmallDoorType)_fromString<int>(tag->getString(L"EntryDoor"));
|
||||
entryDoor = (SmallDoorType)fromWString<int>(tag->getString(L"EntryDoor"));
|
||||
}
|
||||
|
||||
void StrongholdPieces::StrongholdPiece::generateSmallDoor(
|
||||
|
||||
@@ -36,7 +36,7 @@ void StructureFeatureSavedData::putFeatureTag(CompoundTag* tag, int chunkX,
|
||||
|
||||
std::wstring StructureFeatureSavedData::createFeatureTagId(int chunkX,
|
||||
int chunkZ) {
|
||||
return L"[" + _toString<int>(chunkX) + L"," + _toString<int>(chunkZ) + L"]";
|
||||
return L"[" + toWString<int>(chunkX) + L"," + toWString<int>(chunkZ) + L"]";
|
||||
}
|
||||
|
||||
CompoundTag* StructureFeatureSavedData::getFullTag() { return pieceTags; }
|
||||
@@ -64,6 +64,6 @@ int Node::hashCode() { return hash; }
|
||||
bool Node::inOpenSet() { return heapIdx >= 0; }
|
||||
|
||||
std::wstring Node::toString() {
|
||||
return _toString<int>(x) + L", " + _toString<int>(y) + L", " +
|
||||
_toString<int>(z);
|
||||
return toWString<int>(x) + L", " + toWString<int>(y) + L", " +
|
||||
toWString<int>(z);
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ public:
|
||||
virtual bool isSaveEndianDifferent() = 0;
|
||||
virtual void setLocalPlatform() = 0;
|
||||
virtual void setPlatform(ESavePlatform plat) = 0;
|
||||
virtual ByteOrder getSaveEndian() = 0;
|
||||
virtual ByteOrder getLocalEndian() = 0;
|
||||
virtual void setEndian(ByteOrder endian) = 0;
|
||||
virtual std::endian getSaveEndian() = 0;
|
||||
virtual std::endian getLocalEndian() = 0;
|
||||
virtual void setEndian(std::endian endian) = 0;
|
||||
|
||||
virtual void ConvertRegionFile(File sourceFile) = 0;
|
||||
virtual void ConvertToLocalPlatform() = 0;
|
||||
|
||||
@@ -802,15 +802,15 @@ void ConsoleSaveFileOriginal::setPlatform(ESavePlatform plat) {
|
||||
header.setPlatform(plat);
|
||||
}
|
||||
|
||||
ByteOrder ConsoleSaveFileOriginal::getSaveEndian() {
|
||||
std::endian ConsoleSaveFileOriginal::getSaveEndian() {
|
||||
return header.getSaveEndian();
|
||||
}
|
||||
|
||||
ByteOrder ConsoleSaveFileOriginal::getLocalEndian() {
|
||||
std::endian ConsoleSaveFileOriginal::getLocalEndian() {
|
||||
return header.getLocalEndian();
|
||||
}
|
||||
|
||||
void ConsoleSaveFileOriginal::setEndian(ByteOrder endian) {
|
||||
void ConsoleSaveFileOriginal::setEndian(std::endian endian) {
|
||||
header.setEndian(endian);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,9 @@ public:
|
||||
virtual bool isSaveEndianDifferent();
|
||||
virtual void setLocalPlatform();
|
||||
virtual void setPlatform(ESavePlatform plat);
|
||||
virtual ByteOrder getSaveEndian();
|
||||
virtual ByteOrder getLocalEndian();
|
||||
virtual void setEndian(ByteOrder endian);
|
||||
virtual std::endian getSaveEndian();
|
||||
virtual std::endian getLocalEndian();
|
||||
virtual void setEndian(std::endian endian);
|
||||
virtual bool isLocalEndianDifferent(ESavePlatform plat);
|
||||
|
||||
virtual void ConvertRegionFile(File sourceFile);
|
||||
|
||||
@@ -1227,8 +1227,8 @@ std::wstring ConsoleSaveFileSplit::GetNameFromNumericIdentifier(
|
||||
}
|
||||
signed char regionX = (idIn >> 8) & 255;
|
||||
signed char regionZ = idIn & 255;
|
||||
std::wstring region = (prefix + std::wstring(L"r.") + _toString(regionX) +
|
||||
L"." + _toString(regionZ) + L".mcr");
|
||||
std::wstring region = (prefix + std::wstring(L"r.") + toWString(regionX) +
|
||||
L"." + toWString(regionZ) + L".mcr");
|
||||
|
||||
return region;
|
||||
}
|
||||
@@ -1528,15 +1528,15 @@ void ConsoleSaveFileSplit::setPlatform(ESavePlatform plat) {
|
||||
header.setPlatform(plat);
|
||||
}
|
||||
|
||||
ByteOrder ConsoleSaveFileSplit::getSaveEndian() {
|
||||
std::endian ConsoleSaveFileSplit::getSaveEndian() {
|
||||
return header.getSaveEndian();
|
||||
}
|
||||
|
||||
ByteOrder ConsoleSaveFileSplit::getLocalEndian() {
|
||||
std::endian ConsoleSaveFileSplit::getLocalEndian() {
|
||||
return header.getLocalEndian();
|
||||
}
|
||||
|
||||
void ConsoleSaveFileSplit::setEndian(ByteOrder endian) {
|
||||
void ConsoleSaveFileSplit::setEndian(std::endian endian) {
|
||||
header.setEndian(endian);
|
||||
}
|
||||
|
||||
|
||||
@@ -163,9 +163,9 @@ public:
|
||||
virtual bool isSaveEndianDifferent();
|
||||
virtual void setLocalPlatform();
|
||||
virtual void setPlatform(ESavePlatform plat);
|
||||
virtual ByteOrder getSaveEndian();
|
||||
virtual ByteOrder getLocalEndian();
|
||||
virtual void setEndian(ByteOrder endian);
|
||||
virtual std::endian getSaveEndian();
|
||||
virtual std::endian getLocalEndian();
|
||||
virtual void setEndian(std::endian endian);
|
||||
|
||||
virtual void ConvertRegionFile(File sourceFile);
|
||||
virtual void ConvertToLocalPlatform();
|
||||
|
||||
@@ -141,13 +141,13 @@ void FileHeader::ReadHeader(
|
||||
switch (m_savePlatform) {
|
||||
case SAVE_FILE_PLATFORM_X360:
|
||||
case SAVE_FILE_PLATFORM_PS3:
|
||||
m_saveEndian = BIGENDIAN;
|
||||
m_saveEndian = std::endian::big;
|
||||
break;
|
||||
case SAVE_FILE_PLATFORM_XBONE:
|
||||
case SAVE_FILE_PLATFORM_WIN64:
|
||||
case SAVE_FILE_PLATFORM_PS4:
|
||||
case SAVE_FILE_PLATFORM_PSVITA:
|
||||
m_saveEndian = LITTLEENDIAN;
|
||||
m_saveEndian = std::endian::little;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
@@ -354,12 +354,12 @@ std::vector<FileEntry*>* FileHeader::getFilesWithPrefix(
|
||||
return files;
|
||||
}
|
||||
|
||||
ByteOrder FileHeader::getEndian(ESavePlatform plat) {
|
||||
ByteOrder platEndian;
|
||||
std::endian FileHeader::getEndian(ESavePlatform plat) {
|
||||
std::endian platEndian;
|
||||
switch (plat) {
|
||||
case SAVE_FILE_PLATFORM_X360:
|
||||
case SAVE_FILE_PLATFORM_PS3:
|
||||
return BIGENDIAN;
|
||||
return std::endian::big;
|
||||
break;
|
||||
|
||||
case SAVE_FILE_PLATFORM_NONE:
|
||||
@@ -367,11 +367,11 @@ ByteOrder FileHeader::getEndian(ESavePlatform plat) {
|
||||
case SAVE_FILE_PLATFORM_PS4:
|
||||
case SAVE_FILE_PLATFORM_PSVITA:
|
||||
case SAVE_FILE_PLATFORM_WIN64:
|
||||
return LITTLEENDIAN;
|
||||
return std::endian::little;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
return LITTLEENDIAN;
|
||||
return std::endian::little;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "util/Definitions.h"
|
||||
#include <bit>
|
||||
|
||||
#define MAKE_FOURCC(ch0, ch1, ch2, ch3) \
|
||||
(static_cast<std::uint32_t>(static_cast<std::uint8_t>(ch0)) | \
|
||||
@@ -164,8 +164,8 @@ class FileHeader {
|
||||
private:
|
||||
std::vector<FileEntry*> fileTable;
|
||||
ESavePlatform m_savePlatform;
|
||||
ByteOrder m_saveEndian;
|
||||
static const ByteOrder m_localEndian = LITTLEENDIAN;
|
||||
std::endian m_saveEndian;
|
||||
static const std::endian m_localEndian = std::endian::little;
|
||||
|
||||
short m_saveVersion;
|
||||
short m_originalSaveVersion;
|
||||
@@ -210,10 +210,10 @@ protected:
|
||||
m_savePlatform = SAVE_FILE_PLATFORM_LOCAL;
|
||||
m_saveEndian = m_localEndian;
|
||||
}
|
||||
ByteOrder getSaveEndian() { return m_saveEndian; }
|
||||
static ByteOrder getLocalEndian() { return m_localEndian; }
|
||||
void setEndian(ByteOrder endian) { m_saveEndian = endian; }
|
||||
static ByteOrder getEndian(ESavePlatform plat);
|
||||
std::endian getSaveEndian() { return m_saveEndian; }
|
||||
static std::endian getLocalEndian() { return m_localEndian; }
|
||||
void setEndian(std::endian endian) { m_saveEndian = endian; }
|
||||
static std::endian getEndian(ESavePlatform plat);
|
||||
bool isLocalEndianDifferent(ESavePlatform plat) {
|
||||
return m_localEndian != getEndian(plat);
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ LevelData* DirectoryLevelStorage::prepareLevel() {
|
||||
#if defined(__linux__)
|
||||
app.DebugPrintf(" -- %d\n", playerUid);
|
||||
#else
|
||||
app.DebugPrintf(" -- %ls\n", playerUid.toString().c_str());
|
||||
app.DebugPrintf(" -- %ls\n", playerUid.toWString().c_str());
|
||||
#endif
|
||||
#endif
|
||||
m_playerMappings[playerUid].readMappings(&dis);
|
||||
@@ -390,7 +390,7 @@ void DirectoryLevelStorage::save(std::shared_ptr<Player> player) {
|
||||
CompoundTag* tag = new CompoundTag();
|
||||
player->saveWithoutId(tag);
|
||||
ConsoleSavePath realFile = ConsoleSavePath(
|
||||
playerDir.getName() + _toString(player->getXuid()) + L".dat");
|
||||
playerDir.getName() + toWString(player->getXuid()) + L".dat");
|
||||
// If saves are disabled (e.g. because we are writing the save buffer to
|
||||
// disk) then cache this player data
|
||||
if (PlatformStorage.GetSaveDisabled()) {
|
||||
@@ -429,7 +429,7 @@ CompoundTag* DirectoryLevelStorage::load(std::shared_ptr<Player> player) {
|
||||
CompoundTag* DirectoryLevelStorage::loadPlayerDataTag(PlayerUID xuid) {
|
||||
// 4J Jev, removed try/catch.
|
||||
ConsoleSavePath realFile =
|
||||
ConsoleSavePath(playerDir.getName() + _toString(xuid) + L".dat");
|
||||
ConsoleSavePath(playerDir.getName() + toWString(xuid) + L".dat");
|
||||
auto it = m_cachedSaveData.find(realFile.getName());
|
||||
if (it != m_cachedSaveData.end()) {
|
||||
ByteArrayOutputStream* bos = it->second;
|
||||
@@ -464,7 +464,7 @@ void DirectoryLevelStorage::clearOldPlayerFiles() {
|
||||
std::wstring xuidStr = replaceAll(
|
||||
replaceAll(file->data.filename, playerDir.getName(), L""),
|
||||
L".dat", L"");
|
||||
PlayerUID xuid = _fromString<PlayerUID>(xuidStr);
|
||||
PlayerUID xuid = fromWString<PlayerUID>(xuidStr);
|
||||
deleteMapFilesForPlayer(xuid);
|
||||
m_saveFile->deleteFile(playerFiles->at(i));
|
||||
}
|
||||
@@ -480,7 +480,7 @@ void DirectoryLevelStorage::clearOldPlayerFiles() {
|
||||
std::wstring xuidStr = replaceAll(
|
||||
replaceAll(file->data.filename, playerDir.getName(), L""),
|
||||
L".dat", L"");
|
||||
PlayerUID xuid = _fromString<PlayerUID>(xuidStr);
|
||||
PlayerUID xuid = fromWString<PlayerUID>(xuidStr);
|
||||
deleteMapFilesForPlayer(xuid);
|
||||
m_saveFile->deleteFile(playerFiles->at(i));
|
||||
}
|
||||
@@ -602,7 +602,7 @@ int DirectoryLevelStorage::getAuxValueForMap(PlayerUID xuid, int dimension,
|
||||
|
||||
// If we had an old map file for a mapping that is no longer valid,
|
||||
// delete it
|
||||
std::wstring id = std::wstring(L"map_") + _toString(mapId);
|
||||
std::wstring id = std::wstring(L"map_") + toWString(mapId);
|
||||
ConsoleSavePath file = getDataFile(id);
|
||||
|
||||
if (m_saveFile->doesFileExist(file)) {
|
||||
@@ -644,7 +644,7 @@ void DirectoryLevelStorage::saveMapIdLookup() {
|
||||
#if defined(__linux__)
|
||||
app.DebugPrintf(" -- %d\n", it->first);
|
||||
#else
|
||||
app.DebugPrintf(" -- %ls\n", it->first.toString().c_str());
|
||||
app.DebugPrintf(" -- %ls\n", it->first.toWString().c_str());
|
||||
#endif
|
||||
#endif
|
||||
dos.writePlayerUID(it->first);
|
||||
@@ -701,7 +701,7 @@ void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid) {
|
||||
if (it != m_playerMappings.end()) {
|
||||
for (auto itMap = it->second.m_mappings.begin();
|
||||
itMap != it->second.m_mappings.end(); ++itMap) {
|
||||
std::wstring id = std::wstring(L"map_") + _toString(itMap->second);
|
||||
std::wstring id = std::wstring(L"map_") + toWString(itMap->second);
|
||||
ConsoleSavePath file = getDataFile(id);
|
||||
|
||||
if (m_saveFile->doesFileExist(file)) {
|
||||
@@ -725,7 +725,7 @@ void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid) {
|
||||
if (m_mapDataMappings.xuids[i] == xuid) {
|
||||
changed = true;
|
||||
|
||||
std::wstring id = std::wstring(L"map_") + _toString(i);
|
||||
std::wstring id = std::wstring(L"map_") + toWString(i);
|
||||
ConsoleSavePath file = getDataFile(id);
|
||||
|
||||
if (m_saveFile->doesFileExist(file)) {
|
||||
@@ -765,7 +765,7 @@ void DirectoryLevelStorage::saveAllCachedData() {
|
||||
|
||||
for (auto it = m_mapFilesToDelete.begin(); it != m_mapFilesToDelete.end();
|
||||
++it) {
|
||||
std::wstring id = std::wstring(L"map_") + _toString(*it);
|
||||
std::wstring id = std::wstring(L"map_") + toWString(*it);
|
||||
ConsoleSavePath file = getDataFile(id);
|
||||
if (m_saveFile->doesFileExist(file)) {
|
||||
m_saveFile->deleteFile(m_saveFile->createFile(file));
|
||||
|
||||
@@ -27,6 +27,6 @@ int CarrotTile::getBasePlantId() { return Item::carrots_Id; }
|
||||
void CarrotTile::registerIcons(IconRegister* iconRegister) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
icons[i] = iconRegister->registerIcon(getIconName() + L"_stage_" +
|
||||
_toString(i));
|
||||
toWString(i));
|
||||
}
|
||||
}
|
||||
@@ -142,6 +142,6 @@ void CropTile::registerIcons(IconRegister* iconRegister) {
|
||||
icons = new Icon*[8];
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
icons[i] = iconRegister->registerIcon(L"crops_" + _toString(i));
|
||||
icons[i] = iconRegister->registerIcon(L"crops_" + toWString(i));
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,6 @@ int NetherWartTile::cloneTileId(Level* level, int x, int y, int z) {
|
||||
void NetherWartTile::registerIcons(IconRegister* iconRegister) {
|
||||
for (int i = 0; i < NETHER_STALK_TEXTURE_COUNT; i++) {
|
||||
icons[i] = iconRegister->registerIcon(getIconName() + L"_stage_" +
|
||||
_toString<int>(i));
|
||||
toWString<int>(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,6 @@ void PotatoTile::spawnResources(Level* level, int x, int y, int z, int data,
|
||||
void PotatoTile::registerIcons(IconRegister* iconRegister) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
icons[i] = iconRegister->registerIcon(getIconName() + L"_stage_" +
|
||||
_toString<int>(i));
|
||||
toWString<int>(i));
|
||||
}
|
||||
}
|
||||
@@ -2623,8 +2623,8 @@ Tile* Tile::setIconName(const std::wstring& iconName) {
|
||||
}
|
||||
|
||||
std::wstring Tile::getIconName() {
|
||||
return iconName.empty() ? L"MISSING_ICON_TILE_" + _toString<int>(id) +
|
||||
L"_" + _toString<int>(descriptionId)
|
||||
return iconName.empty() ? L"MISSING_ICON_TILE_" + toWString<int>(id) +
|
||||
L"_" + toWString<int>(descriptionId)
|
||||
: iconName;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user