diff --git a/platforms/sdl/AppPlatform_sdl.cpp b/platforms/sdl/AppPlatform_sdl.cpp index 51d1a05..41db8f9 100644 --- a/platforms/sdl/AppPlatform_sdl.cpp +++ b/platforms/sdl/AppPlatform_sdl.cpp @@ -289,63 +289,7 @@ Texture AppPlatform_sdl::loadTexture(const std::string& path, bool b) return out; } -std::string AppPlatform_sdl::getOptionsFilePath() const +bool AppPlatform_sdl::hasFileSystemAccess() { - return _storageDir + "/options.txt"; -} - -std::vector AppPlatform_sdl::getOptionStrings() -{ - // TODO: This isn't specific to SDL2. Why isn't it in an AppPlatform base class? - std::vector o; - - LOG_I("Storage dir is %s", _storageDir.c_str()); - - std::ifstream ifs(getOptionsFilePath().c_str()); - if (!ifs.is_open()) - { - LOG_W("options.txt doesn't exist, resetting to defaults"); - return o; - } - - std::string str; - while (true) - { - if (!std::getline(ifs, str, '\n')) - break; - - if (str.empty() || str[0] == '#') - continue; - - std::stringstream ss; - ss << str; - - std::string key, value; - if (std::getline(ss, key, ':') && std::getline(ss, value)) - { - o.push_back(key); - o.push_back(value); - } - } - - return o; -} - -void AppPlatform_sdl::setOptionStrings(const std::vector& str) -{ - // TODO: This isn't specific to SDL2. Why isn't it in an AppPlatform base class? - assert(str.size() % 2 == 0); - - std::ofstream os; - os.open(getOptionsFilePath().c_str()); - if (!os.is_open()) - { - LOG_E("Failed to read options.txt"); - return; - } - - os << "#Config file for Minecraft PE. The # at the start denotes a comment, removing it makes it a command.\n\n"; - - for (int i = 0; i < int(str.size()); i += 2) - os << str[i] << ':' << str[i + 1] << '\n'; + return true; } diff --git a/platforms/sdl/AppPlatform_sdl.hpp b/platforms/sdl/AppPlatform_sdl.hpp index 9e4984b..5715ae5 100644 --- a/platforms/sdl/AppPlatform_sdl.hpp +++ b/platforms/sdl/AppPlatform_sdl.hpp @@ -11,10 +11,9 @@ public: void saveScreenshot(const std::string& fileName, int width, int height) override; Texture loadTexture(const std::string& path, bool b = false) override; - std::vector getOptionStrings() override; - void setOptionStrings(const std::vector& str) override; + + bool hasFileSystemAccess() override; protected: void ensureDirectoryExists(const char* path) override; - std::string getOptionsFilePath() const; }; diff --git a/platforms/windows/AppPlatform_windows.cpp b/platforms/windows/AppPlatform_windows.cpp index b47f359..ec620b5 100644 --- a/platforms/windows/AppPlatform_windows.cpp +++ b/platforms/windows/AppPlatform_windows.cpp @@ -176,47 +176,9 @@ Texture AppPlatform_windows::loadTexture(const std::string& str, bool b) return Texture(width, height, img2, 1, 0); } -std::vector AppPlatform_windows::getOptionStrings() +bool AppPlatform_windows::hasFileSystemAccess() { - std::vector o; - - std::ifstream ifs("options.txt"); - if (!ifs.is_open()) - return o; - - std::string str; - while (true) - { - if (!std::getline(ifs, str, '\n')) - break; - - if (str.empty() || str[0] == '#') - continue; - - std::stringstream ss; - ss << str; - - std::string key, value; - if (std::getline(ss, key, ':') && std::getline(ss, value)) - { - o.push_back(key); - o.push_back(value); - } - } - - return o; -} - -void AppPlatform_windows::setOptionStrings(const std::vector& str) -{ - assert(str.size() % 2 == 0); - - std::ofstream os("options.txt"); - - os << "#Config file for Minecraft PE. The # at the start denotes a comment, removing it makes it a command.\n\n"; - - for (int i = 0; i < int(str.size()); i += 2) - os << str[i] << ':' << str[i + 1] << '\n'; + return true; } std::string AppPlatform_windows::getPatchData() diff --git a/platforms/windows/AppPlatform_windows.hpp b/platforms/windows/AppPlatform_windows.hpp index d98da22..94a9096 100644 --- a/platforms/windows/AppPlatform_windows.hpp +++ b/platforms/windows/AppPlatform_windows.hpp @@ -34,7 +34,6 @@ public: void showDialog(eDialogType) override; std::string getDateString(int time) override; Texture loadTexture(const std::string& str, bool b) override; - std::vector getOptionStrings() override; // Also add these to allow proper turning within the game. void recenterMouse() override; @@ -46,9 +45,8 @@ public: // Also add these to allow proper text input within the game. bool shiftPressed() override { return m_bShiftPressed; } void setShiftPressed(bool b) { m_bShiftPressed = b; } - - // Also add these to allow saving options. - void setOptionStrings(const std::vector & str) override; + + bool hasFileSystemAccess() override; // Also add this to allow dynamic texture patching. std::string getPatchData() override; diff --git a/platforms/windows/projects/minecraftcpp.vcxproj b/platforms/windows/projects/minecraftcpp.vcxproj index 7ba6cb0..2cb458e 100644 --- a/platforms/windows/projects/minecraftcpp.vcxproj +++ b/platforms/windows/projects/minecraftcpp.vcxproj @@ -383,7 +383,7 @@ - + @@ -391,7 +391,7 @@ - + @@ -729,8 +729,8 @@ - - + + diff --git a/platforms/windows/projects/minecraftcpp.vcxproj.filters b/platforms/windows/projects/minecraftcpp.vcxproj.filters index eebb1da..2ee0397 100644 --- a/platforms/windows/projects/minecraftcpp.vcxproj.filters +++ b/platforms/windows/projects/minecraftcpp.vcxproj.filters @@ -1178,6 +1178,9 @@ source\common + + source\common + @@ -2206,10 +2209,10 @@ source\platforms\windows - + source\platforms\windows - + source\common diff --git a/source/AppPlatform.cpp b/source/AppPlatform.cpp index 9210a69..98ef2a2 100644 --- a/source/AppPlatform.cpp +++ b/source/AppPlatform.cpp @@ -9,6 +9,23 @@ #include "AppPlatform.hpp" #include "common/Utils.hpp" +AppPlatform* AppPlatform::m_singleton = nullptr; + +AppPlatform* const AppPlatform::singleton() +{ + return m_singleton; +} + +AppPlatform::AppPlatform() +{ + m_singleton = this; +} + +AppPlatform::~AppPlatform() +{ + +} + void AppPlatform::_tick() { @@ -89,11 +106,6 @@ Texture AppPlatform::loadTexture(const std::string&, bool) return Texture(0, 0, nullptr, 1, 0); } -std::vector AppPlatform::getOptionStrings() -{ - return std::vector(); -} - void AppPlatform::recenterMouse() { @@ -123,8 +135,9 @@ bool AppPlatform::shiftPressed() return false; } -void AppPlatform::setOptionStrings(const std::vector& vec) +bool AppPlatform::hasFileSystemAccess() { + return false; } std::string AppPlatform::getPatchData() diff --git a/source/AppPlatform.hpp b/source/AppPlatform.hpp index 170541c..7226ef0 100644 --- a/source/AppPlatform.hpp +++ b/source/AppPlatform.hpp @@ -24,7 +24,14 @@ public: DLG_RENAME_MP_WORLD, }; +private: + static AppPlatform* m_singleton; public: + static AppPlatform* const singleton(); + + AppPlatform(); + ~AppPlatform(); + virtual void buyGame(); virtual int checkLicense(); virtual void createUserInput(); @@ -39,7 +46,6 @@ public: virtual void showDialog(eDialogType); virtual void uploadPlatformDependentData(int, void*); virtual Texture loadTexture(const std::string&, bool); - virtual std::vector getOptionStrings(); #ifndef ORIGINAL_CODE // Also add these to allow proper turning within the game. @@ -50,8 +56,7 @@ public: virtual void updateFocused(bool focused); // Also add this to allow proper text input within the game. virtual bool shiftPressed(); - // Also add this to allow option saving. - virtual void setOptionStrings(const std::vector& vec); + virtual bool hasFileSystemAccess(); // Also add this to allow dynamic patching. virtual std::string getPatchData(); #endif diff --git a/source/Minecraft.cpp b/source/Minecraft.cpp index 8e0b76d..d3b880c 100644 --- a/source/Minecraft.cpp +++ b/source/Minecraft.cpp @@ -50,6 +50,7 @@ const char* Minecraft::progressMessages[] = Minecraft::Minecraft() : m_gui(this) { + m_options = nullptr; field_18 = false; field_288 = false; m_pLevelRenderer = nullptr; @@ -192,17 +193,10 @@ void Minecraft::onGraphicsReset() EntityRenderDispatcher::getInstance()->onGraphicsReset(); } -void Minecraft::reloadOptions() -{ - m_options.update(platform()->getOptionStrings()); - - // update the user's name. - m_pUser->field_0 = m_options.m_playerName; -} - void Minecraft::saveOptions() { - platform()->setOptionStrings(m_options.getOptionStrings()); + if (platform()->hasFileSystemAccess()) + getOptions()->save(); } bool Minecraft::isLevelGenerated() @@ -399,7 +393,7 @@ void Minecraft::tickInput() if (Mouse::isButtonDown(1)) m_gui.handleClick(1, Mouse::getX(), Mouse::getY()); - if (!bIsInGUI && m_options.field_19) + if (!bIsInGUI && getOptions()->field_19) { if (Mouse::getEventButton() == Mouse::LEFT && Mouse::getEventButtonState() == Mouse::DOWN) { @@ -456,19 +450,19 @@ void Minecraft::tickInput() for (int i = 0; i < 9; i++) { - if (m_options.isKey(eKeyMappingIndex(KM_SLOT_1 + i), keyCode)) + if (getOptions()->isKey(eKeyMappingIndex(KM_SLOT_1 + i), keyCode)) m_pLocalPlayer->m_pInventory->selectSlot(i); } - if (m_options.isKey(KM_TOGGLE3RD, keyCode)) + if (getOptions()->isKey(KM_TOGGLE3RD, keyCode)) { - m_options.m_bThirdPerson = !m_options.m_bThirdPerson; + getOptions()->m_bThirdPerson = !getOptions()->m_bThirdPerson; } - else if (m_options.isKey(KM_MENU_CANCEL, keyCode)) + else if (getOptions()->isKey(KM_MENU_CANCEL, keyCode)) { pauseGame(); } - else if (m_options.isKey(KM_DROP, keyCode)) + else if (getOptions()->isKey(KM_DROP, keyCode)) { int itemID = m_pLocalPlayer->m_pInventory->getSelectedItemId(); if (itemID > 0) @@ -477,33 +471,33 @@ void Minecraft::tickInput() m_pLocalPlayer->drop(&inst); } } - else if (m_options.isKey(KM_TOGGLEGUI, keyCode)) + else if (getOptions()->isKey(KM_TOGGLEGUI, keyCode)) { - m_options.m_bDontRenderGui = !m_options.m_bDontRenderGui; + getOptions()->m_bDontRenderGui = !getOptions()->m_bDontRenderGui; } - else if (m_options.isKey(KM_TOGGLEDEBUG, keyCode)) + else if (getOptions()->isKey(KM_TOGGLEDEBUG, keyCode)) { - m_options.m_bDebugText = !m_options.m_bDebugText; + getOptions()->m_bDebugText = !getOptions()->m_bDebugText; } #ifdef ENH_ALLOW_AO - else if (m_options.isKey(KM_TOGGLEAO, keyCode)) + else if (getOptions()->isKey(KM_TOGGLEAO, keyCode)) { // Toggle ambient occlusion. - m_options.m_bAmbientOcclusion = !m_options.m_bAmbientOcclusion; - Minecraft::useAmbientOcclusion = m_options.m_bAmbientOcclusion; + getOptions()->m_bAmbientOcclusion = !getOptions()->m_bAmbientOcclusion; + Minecraft::useAmbientOcclusion = getOptions()->m_bAmbientOcclusion; m_pLevelRenderer->allChanged(); } #endif } - if (m_options.field_19) + if (getOptions()->field_19) continue; if (getTimeMs() - field_2B4 <= 200) { - if (m_options.getKey(KM_DESTROY) == keyCode && bPressed) + if (getOptions()->getKey(KM_DESTROY) == keyCode && bPressed) handleMouseClick(1); - if (m_options.getKey(KM_PLACE) == keyCode && bPressed) + if (getOptions()->getKey(KM_PLACE) == keyCode && bPressed) handleMouseClick(2); } } @@ -511,12 +505,12 @@ void Minecraft::tickInput() // @TODO: fix gotos bool v12 = false; - if (m_options.field_19) + if (getOptions()->field_19) { if (!Mouse::isButtonDown(Mouse::LEFT) || bIsInGUI) goto label_12; } - else if (Keyboard::isKeyDown(m_options.getKey(KM_DESTROY))) + else if (Keyboard::isKeyDown(getOptions()->getKey(KM_DESTROY))) { goto label_12; } @@ -743,7 +737,23 @@ void Minecraft::update() void Minecraft::init() { - m_pTextures = new Textures(&m_options, platform()); + if (platform()->hasFileSystemAccess()) + m_options = new Options(m_externalStorageDir); + else + m_options = new Options(); + +#ifndef ORIGINAL_CODE + m_pTurnInput = new MouseTurnInput(this); +#else + m_pTurnInput = new ControllerTurnInput; +#endif + + m_pRakNetInstance = new RakNetInstance; + + m_pSoundEngine = new SoundEngine; + m_pSoundEngine->init(m_options); + + m_pTextures = new Textures(m_options, platform()); m_pTextures->addDynamicTexture(new WaterTexture); m_pTextures->addDynamicTexture(new WaterSideTexture); m_pTextures->addDynamicTexture(new LavaTexture); @@ -752,7 +762,7 @@ void Minecraft::init() m_pLevelRenderer = new LevelRenderer(this, m_pTextures); m_pGameRenderer = new GameRenderer(this); m_pParticleEngine = new ParticleEngine(m_pLevel, m_pTextures); - m_pUser = new User("TestUser", ""); + m_pUser = new User(getOptions()->m_playerName, ""); #ifdef TEST_SURVIVAL_MODE m_pGameMode = new SurvivalMode(this); @@ -760,9 +770,7 @@ void Minecraft::init() m_pGameMode = new CreativeMode(this); #endif - reloadOptions(); - - m_pFont = new Font(&m_options, "font/default.png", m_pTextures); + m_pFont = new Font(m_options, "font/default.png", m_pTextures); // Patch Manager GetPatchManager()->LoadPatchData(platform()->getPatchData()); @@ -777,6 +785,7 @@ void Minecraft::init() Minecraft::~Minecraft() { + SAFE_DELETE(m_options); SAFE_DELETE(m_pNetEventCallback); SAFE_DELETE(m_pRakNetInstance); SAFE_DELETE(m_pLevelRenderer); @@ -956,7 +965,7 @@ void Minecraft::generateLevel(const std::string& unused, Level* pLevel) if (pLocalPlayer) { - pLocalPlayer->m_pKeyboardInput = new KeyboardInput(&m_options); + pLocalPlayer->m_pKeyboardInput = new KeyboardInput(m_options); } if (m_pLevelRenderer) diff --git a/source/Minecraft.hpp b/source/Minecraft.hpp index 32f349f..2385a23 100644 --- a/source/Minecraft.hpp +++ b/source/Minecraft.hpp @@ -40,7 +40,6 @@ public: void grabMouse(); void tick(); void tickInput(); - void reloadOptions(); void saveOptions(); void handleMouseClick(int type); void handleMouseDown(int type, bool b); @@ -77,6 +76,7 @@ public: const char* getProgressMessage(); LevelStorageSource* getLevelSource(); ItemInstance* getSelectedItem(); + Options* getOptions() const { return m_options; } static void setGuiScaleMultiplier(float f); @@ -90,10 +90,10 @@ public: private: Logger *m_Logger; + Options *m_options; public: bool field_18; - Options m_options; bool field_288; LevelRenderer* m_pLevelRenderer; GameRenderer* m_pGameRenderer; diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index 641244e..d4459ef 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -382,12 +382,12 @@ void Gui::handleClick(int clickID, int mouseX, int mouseY) void Gui::handleKeyPressed(int keyCode) { - if (m_pMinecraft->m_options.isKey(KM_INVENTORY, keyCode)) + if (m_pMinecraft->getOptions()->isKey(KM_INVENTORY, keyCode)) { m_pMinecraft->setScreen(new IngameBlockSelectionScreen); return; } - if (m_pMinecraft->m_options.isKey(KM_SLOT_R, keyCode)) + if (m_pMinecraft->getOptions()->isKey(KM_SLOT_R, keyCode)) { int* slot = &m_pMinecraft->m_pLocalPlayer->m_pInventory->m_SelectedHotbarSlot; @@ -402,7 +402,7 @@ void Gui::handleKeyPressed(int keyCode) return; } - if (m_pMinecraft->m_options.isKey(KM_SLOT_L, keyCode)) + if (m_pMinecraft->getOptions()->isKey(KM_SLOT_L, keyCode)) { int* slot = &m_pMinecraft->m_pLocalPlayer->m_pInventory->m_SelectedHotbarSlot; @@ -412,12 +412,12 @@ void Gui::handleKeyPressed(int keyCode) return; } - if (m_pMinecraft->m_options.isKey(KM_CHAT_CMD, keyCode) || m_pMinecraft->m_options.isKey(KM_CHAT, keyCode)) + if (m_pMinecraft->getOptions()->isKey(KM_CHAT_CMD, keyCode) || m_pMinecraft->getOptions()->isKey(KM_CHAT, keyCode)) { if (m_pMinecraft->m_pScreen) return; - m_pMinecraft->setScreen(new ChatScreen(m_pMinecraft->m_options.isKey(KM_CHAT_CMD, keyCode))); + m_pMinecraft->setScreen(new ChatScreen(m_pMinecraft->getOptions()->isKey(KM_CHAT_CMD, keyCode))); return; } } diff --git a/source/client/gui/Screen.cpp b/source/client/gui/Screen.cpp index 234d4ee..91c870c 100644 --- a/source/client/gui/Screen.cpp +++ b/source/client/gui/Screen.cpp @@ -70,7 +70,7 @@ bool Screen::isInGameScreen() void Screen::keyPressed(int key) { - if (m_pMinecraft->m_options.isKey(KM_MENU_CANCEL, key)) + if (m_pMinecraft->getOptions()->isKey(KM_MENU_CANCEL, key)) { m_pMinecraft->setScreen(nullptr); } @@ -78,19 +78,19 @@ void Screen::keyPressed(int key) if (m_buttonTabList.size()) { #ifndef ENH_HIGHLIGHT_BY_HOVER - if (m_pMinecraft->m_options.isKey(MENU_NEXT, key)) + if (m_pMinecraft->getOptions()->isKey(MENU_NEXT, key)) { m_tabButtonIndex++; if (m_tabButtonIndex == int(m_buttonTabList.size())) m_tabButtonIndex = 0; } - if (m_pMinecraft->m_options.isKey(MENU_PREVIOUS, key)) + if (m_pMinecraft->getOptions()->isKey(MENU_PREVIOUS, key)) { m_tabButtonIndex--; if (m_tabButtonIndex == -1) m_tabButtonIndex = int(m_buttonTabList.size() - 1); } - if (m_pMinecraft->m_options.isKey(MENU_OK, key)) + if (m_pMinecraft->getOptions()->isKey(MENU_OK, key)) { if (m_buttonTabList[m_tabButtonIndex]->m_bEnabled) { diff --git a/source/client/gui/screens/ChatScreen.cpp b/source/client/gui/screens/ChatScreen.cpp index 125415d..020ff51 100644 --- a/source/client/gui/screens/ChatScreen.cpp +++ b/source/client/gui/screens/ChatScreen.cpp @@ -60,7 +60,7 @@ void ChatScreen::render(int mouseX, int mouseY, float f) void ChatScreen::keyPressed(int keyCode) { - if (m_pMinecraft->m_options.isKey(KM_MENU_OK, keyCode)) + if (m_pMinecraft->getOptions()->isKey(KM_MENU_OK, keyCode)) sendMessageAndExit(); Screen::keyPressed(keyCode); diff --git a/source/client/gui/screens/OptionsScreen.cpp b/source/client/gui/screens/OptionsScreen.cpp index 8092dda..144b9e9 100644 --- a/source/client/gui/screens/OptionsScreen.cpp +++ b/source/client/gui/screens/OptionsScreen.cpp @@ -65,7 +65,7 @@ static std::string ViewDistanceStr(int dist) void OptionsScreen::UpdateTexts() { - Options& o = m_pMinecraft->m_options; + Options& o = *(m_pMinecraft->getOptions()); m_AOButton.m_text = "Smooth lighting: " + BoolOptionStr(o.m_bAmbientOcclusion); m_invertYButton.m_text = "Invert Y-axis: " + BoolOptionStr(o.m_bInvertMouse); @@ -159,16 +159,13 @@ void OptionsScreen::render(int a, int b, float c) void OptionsScreen::removed() { -#ifdef ORIGINAL_CODE // Reloading options will reload the options.txt we introduced. Don't do this - m_pMinecraft->reloadOptions(); -#endif } #ifndef ORIGINAL_CODE void OptionsScreen::buttonClicked(Button* pButton) { - Options& o = m_pMinecraft->m_options; + Options& o = *(m_pMinecraft->getOptions()); bool* pOption = nullptr; switch (pButton->m_buttonId) diff --git a/source/client/gui/screens/SelectWorldScreen.cpp b/source/client/gui/screens/SelectWorldScreen.cpp index 63158db..1f0b718 100644 --- a/source/client/gui/screens/SelectWorldScreen.cpp +++ b/source/client/gui/screens/SelectWorldScreen.cpp @@ -59,7 +59,7 @@ bool SelectWorldScreen::isInGameScreen() void SelectWorldScreen::keyPressed(int code) { #ifndef ORIGINAL_CODE - if (m_pMinecraft->m_options.getKey(KM_MENU_OK) == code) + if (m_pMinecraft->getOptions()->getKey(KM_MENU_OK) == code) m_pWorldSelectionList->selectItem(m_pWorldSelectionList->getItemAtPosition(m_width / 2, m_height / 2), false); m_btnUnknown.field_36 = true; @@ -67,10 +67,10 @@ void SelectWorldScreen::keyPressed(int code) if (m_btnUnknown.field_36) { - if (m_pMinecraft->m_options.getKey(KM_LEFT) == code) + if (m_pMinecraft->getOptions()->getKey(KM_LEFT) == code) m_pWorldSelectionList->stepLeft(); - if (m_pMinecraft->m_options.getKey(KM_RIGHT) == code) + if (m_pMinecraft->getOptions()->getKey(KM_RIGHT) == code) m_pWorldSelectionList->stepRight(); } diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index e4d8557..d4c8a70 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -84,12 +84,12 @@ void GameRenderer::unZoomRegion() void GameRenderer::setupCamera(float f, int i) { - field_8 = float(256 >> m_pMinecraft->m_options.m_iViewDistance); + field_8 = float(256 >> m_pMinecraft->getOptions()->m_iViewDistance); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - if (m_pMinecraft->m_options.m_bAnaglyphs) + if (m_pMinecraft->getOptions()->m_bAnaglyphs) { glTranslatef(float(1 - 2 * i) * 0.07f, 0.0f, 0.0f); } @@ -106,13 +106,13 @@ void GameRenderer::setupCamera(float f, int i) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - if (m_pMinecraft->m_options.m_bAnaglyphs) + if (m_pMinecraft->getOptions()->m_bAnaglyphs) { glTranslatef(float(2 * i - 1) * 0.1f, 0.0f, 0.0f); } bobHurt(f); - if (m_pMinecraft->m_options.m_bViewBobbing) + if (m_pMinecraft->getOptions()->m_bViewBobbing) bobView(f); moveCameraToPlayer(f); @@ -130,10 +130,10 @@ void GameRenderer::moveCameraToPlayer(float f) glRotatef(field_5C + f * (field_58 - field_5C), 0.0f, 0.0f, 1.0f); - if (m_pMinecraft->m_options.m_bThirdPerson) + if (m_pMinecraft->getOptions()->m_bThirdPerson) { float v11 = field_30 + (field_2C - field_30) * f; - if (m_pMinecraft->m_options.field_241) + if (m_pMinecraft->getOptions()->field_241) { glTranslatef(0.0f, 0.0f, -v11); glRotatef(field_38 + (field_34 - field_38) * f, 1.0f, 0.0f, 0.0f); @@ -185,7 +185,7 @@ void GameRenderer::moveCameraToPlayer(float f) glTranslatef(0.0f, 0.0f, -0.1f); } - if (!m_pMinecraft->m_options.field_241) + if (!m_pMinecraft->getOptions()->field_241) { glRotatef(pMob->field_60 + f * (pMob->m_pitch - pMob->field_60), 1.0f, 0.0f, 0.0f); glRotatef(pMob->field_5C + f * (pMob->m_yaw - pMob->field_5C) + 180.0f, 0.0f, 1.0f, 0.0f); @@ -256,7 +256,7 @@ void GameRenderer::setupClearColor(float f) Level* pLevel = pMC->m_pLevel; Mob* pMob = pMC->m_pMobPersp; - float x1 = 1.0f - powf(1.0f / float(4 - pMC->m_options.m_iViewDistance), 0.25f); + float x1 = 1.0f - powf(1.0f / float(4 - pMC->getOptions()->m_iViewDistance), 0.25f); Vec3 skyColor = pLevel->getSkyColor(pMob, f), fogColor = pLevel->getFogColor(f); @@ -287,7 +287,7 @@ void GameRenderer::setupClearColor(float f) field_64 *= x2; field_68 *= x2; - if (pMC->m_options.m_bAnaglyphs) + if (pMC->getOptions()->m_bAnaglyphs) { float r = (field_60 * 30.0f + field_64 * 59.0f + field_68 * 11.0f) / 100.0f; float g = (field_60 * 30.0f + field_64 * 70.0f) / 100.0f; @@ -407,7 +407,7 @@ void GameRenderer::renderLevel(float f) fCamPos.y = pMob->field_98.y + (pMob->m_pos.y - pMob->field_98.y) * f; fCamPos.z = pMob->field_98.z + (pMob->m_pos.z - pMob->field_98.z) * f; - bool bAnaglyph = m_pMinecraft->m_options.m_bAnaglyphs; + bool bAnaglyph = m_pMinecraft->getOptions()->m_bAnaglyphs; LevelRenderer* pLR = m_pMinecraft->m_pLevelRenderer; ParticleEngine* pPE = m_pMinecraft->m_pParticleEngine; @@ -431,7 +431,7 @@ void GameRenderer::renderLevel(float f) saveMatrices(); /* - if (m_pMinecraft->m_options.m_iViewDistance <= 1) + if (m_pMinecraft->getOptions()->m_iViewDistance <= 1) { #ifndef ORIGINAL_CODE // @NOTE: For whatever reason, Minecraft doesn't enable GL_FOG right away. @@ -446,7 +446,7 @@ void GameRenderer::renderLevel(float f) glEnable(GL_FOG); setupFog(1); - if (m_pMinecraft->m_options.m_bAmbientOcclusion) + if (m_pMinecraft->getOptions()->m_bAmbientOcclusion) glShadeModel(GL_SMOOTH); Frustum& frust = Frustum::frustum; @@ -537,7 +537,7 @@ void GameRenderer::render(float f) #ifndef ENH_DISABLE_TURN_ACCEL float multPitch = -1.0f; - float mult1 = 2.0f * (0.2f + pMC->m_options.field_8 * 0.6f); + float mult1 = 2.0f * (0.2f + pMC->getOptions()->field_8 * 0.6f); mult1 = mult1 * mult1 * mult1; float xd = 4.0f * mult1 * pMC->field_D20; @@ -552,10 +552,10 @@ void GameRenderer::render(float f) if (diff_field_84 > 3.0f) diff_field_84 = 3.0f; - if (pMC->m_options.m_bInvertMouse) + if (pMC->getOptions()->m_bInvertMouse) multPitch = 1.0f; - if (!pMC->m_options.field_240) + if (!pMC->getOptions()->field_240) { // @TODO: untangle this code float v17 = xd + m_rotZ; @@ -580,7 +580,7 @@ void GameRenderer::render(float f) } #else float multPitch = -1.0f; - if (pMC->m_options.m_bInvertMouse) + if (pMC->getOptions()->m_bInvertMouse) multPitch = 1.0f; float diff_field_84 = 1.0f; @@ -601,7 +601,7 @@ void GameRenderer::render(float f) if (t_keepPic < 0) { renderLevel(f); - if (m_pMinecraft->m_options.m_bDontRenderGui) + if (m_pMinecraft->getOptions()->m_bDontRenderGui) { if (!m_pMinecraft->m_pScreen) return; @@ -638,7 +638,7 @@ void GameRenderer::render(float f) debugText << "ReMinecraftPE " << m_pMinecraft->getVersionString(); debugText << "\n" << m_shownFPS << " fps, " << m_shownChunkUpdates << " chunk updates"; - if (m_pMinecraft->m_options.m_bDebugText) + if (m_pMinecraft->getOptions()->m_bDebugText) { if (m_pMinecraft->m_pLocalPlayer) { @@ -701,7 +701,7 @@ void GameRenderer::tick() } float bright = m_pMinecraft->m_pLevel->getBrightness(Mth::floor(pMob->m_pos.x), Mth::floor(pMob->m_pos.y), Mth::floor(pMob->m_pos.z)); - float x3 = float(3 - m_pMinecraft->m_options.m_iViewDistance); + float x3 = float(3 - m_pMinecraft->getOptions()->m_iViewDistance); field_C++; @@ -718,27 +718,27 @@ void GameRenderer::renderItemInHand(float f, int i) { glLoadIdentity(); - if (m_pMinecraft->m_options.m_bAnaglyphs) + if (m_pMinecraft->getOptions()->m_bAnaglyphs) glTranslatef(float(2 * i - 1) * 0.1f, 0.0f, 0.0f); glPushMatrix(); bobHurt(f); - if (m_pMinecraft->m_options.m_bViewBobbing) + if (m_pMinecraft->getOptions()->m_bViewBobbing) bobView(f); - if (!m_pMinecraft->m_options.m_bThirdPerson && !m_pMinecraft->m_options.m_bDontRenderGui) + if (!m_pMinecraft->getOptions()->m_bThirdPerson && !m_pMinecraft->getOptions()->m_bDontRenderGui) m_pItemInHandRenderer->render(f); glPopMatrix(); - if (!m_pMinecraft->m_options.m_bThirdPerson) + if (!m_pMinecraft->getOptions()->m_bThirdPerson) { m_pItemInHandRenderer->renderScreenEffect(f); bobHurt(f); } - if (m_pMinecraft->m_options.m_bViewBobbing) + if (m_pMinecraft->getOptions()->m_bViewBobbing) bobView(f); } diff --git a/source/client/renderer/ItemInHandRenderer.cpp b/source/client/renderer/ItemInHandRenderer.cpp index c451f8c..bbb247c 100644 --- a/source/client/renderer/ItemInHandRenderer.cpp +++ b/source/client/renderer/ItemInHandRenderer.cpp @@ -327,7 +327,7 @@ void ItemInHandRenderer::renderScreenEffect(float f) renderFire(f); } - if (m_pMinecraft->m_pLocalPlayer->isInWall() && !m_pMinecraft->m_options.m_bFlyCheat) + if (m_pMinecraft->m_pLocalPlayer->isInWall() && !m_pMinecraft->getOptions()->m_bFlyCheat) { int fx = Mth::floor(m_pMinecraft->m_pLocalPlayer->m_pos.x); int fy = Mth::floor(m_pMinecraft->m_pLocalPlayer->m_pos.y); diff --git a/source/client/renderer/LevelRenderer.cpp b/source/client/renderer/LevelRenderer.cpp index f408dc8..0feb8e8 100644 --- a/source/client/renderer/LevelRenderer.cpp +++ b/source/client/renderer/LevelRenderer.cpp @@ -132,10 +132,10 @@ void LevelRenderer::allChanged() LeafTile* pLeaves = (LeafTile*)Tile::leaves; - pLeaves->m_bTransparent = m_pMinecraft->m_options.m_bFancyGraphics; + pLeaves->m_bTransparent = m_pMinecraft->getOptions()->m_bFancyGraphics; pLeaves->m_TextureFrame = !pLeaves->m_bTransparent + pLeaves->field_74; - field_BC = m_pMinecraft->m_options.m_iViewDistance; + field_BC = m_pMinecraft->getOptions()->m_iViewDistance; int x1 = 64 << (3 - field_BC); if (x1 >= 400) @@ -491,7 +491,7 @@ void LevelRenderer::render(Mob* pMob, int a, float b) field_88.push_back(pChunk); } - if (m_pMinecraft->m_options.m_iViewDistance != field_BC) + if (m_pMinecraft->getOptions()->m_iViewDistance != field_BC) allChanged(); if (!a) @@ -519,7 +519,7 @@ void LevelRenderer::render(Mob* pMob, int a, float b) // @TODO: Fix goto hell // @NOTE: Field_B8 doesn't appear to be used?? - if (field_B8 && !a && !m_pMinecraft->m_options.m_bAnaglyphs) + if (field_B8 && !a && !m_pMinecraft->getOptions()->m_bAnaglyphs) { checkQueryResults(0, 16); @@ -1089,7 +1089,7 @@ void LevelRenderer::renderEntities(Vec3 pos, Culler* culler, float f) Mob* mob = m_pMinecraft->m_pMobPersp; - EntityRenderDispatcher::getInstance()->prepare(m_pLevel, m_pMinecraft->m_pTextures, m_pMinecraft->m_pFont, mob, &m_pMinecraft->m_options, f); + EntityRenderDispatcher::getInstance()->prepare(m_pLevel, m_pMinecraft->m_pTextures, m_pMinecraft->m_pFont, mob, m_pMinecraft->getOptions(), f); field_18 = 0; field_1C = 0; @@ -1111,7 +1111,7 @@ void LevelRenderer::renderEntities(Vec3 pos, Culler* culler, float f) if (!culler->isVisible(pEnt->m_hitbox)) continue; - if (m_pMinecraft->m_pMobPersp == pEnt && !m_pMinecraft->m_options.m_bThirdPerson) + if (m_pMinecraft->m_pMobPersp == pEnt && !m_pMinecraft->getOptions()->m_bThirdPerson) continue; if (m_pLevel->hasChunkAt(Mth::floor(pEnt->m_pos.x), Mth::floor(pEnt->m_pos.y), Mth::floor(pEnt->m_pos.z))) @@ -1127,8 +1127,8 @@ extern int t_keepPic; void LevelRenderer::takePicture(TripodCamera* pCamera, Entity* pOwner) { Mob* pOldMob = m_pMinecraft->m_pMobPersp; - bool bOldDontRenderGui = m_pMinecraft->m_options.m_bDontRenderGui; - bool bOldThirdPerson = m_pMinecraft->m_options.m_bThirdPerson; + bool bOldDontRenderGui = m_pMinecraft->getOptions()->m_bDontRenderGui; + bool bOldThirdPerson = m_pMinecraft->getOptions()->m_bThirdPerson; #ifdef ENH_CAMERA_NO_PARTICLES extern bool g_bDisableParticles; @@ -1136,12 +1136,12 @@ void LevelRenderer::takePicture(TripodCamera* pCamera, Entity* pOwner) #endif m_pMinecraft->m_pMobPersp = pCamera; - m_pMinecraft->m_options.m_bDontRenderGui = true; - m_pMinecraft->m_options.m_bThirdPerson = false; // really from the perspective of the camera + m_pMinecraft->getOptions()->m_bDontRenderGui = true; + m_pMinecraft->getOptions()->m_bThirdPerson = false; // really from the perspective of the camera m_pMinecraft->m_pGameRenderer->render(0.0f); m_pMinecraft->m_pMobPersp = pOldMob; - m_pMinecraft->m_options.m_bDontRenderGui = bOldDontRenderGui; - m_pMinecraft->m_options.m_bThirdPerson = bOldThirdPerson; + m_pMinecraft->getOptions()->m_bDontRenderGui = bOldDontRenderGui; + m_pMinecraft->getOptions()->m_bThirdPerson = bOldThirdPerson; #ifdef ENH_CAMERA_NO_PARTICLES g_bDisableParticles = false; @@ -1229,7 +1229,7 @@ void LevelRenderer::renderSky(float f) glDisable(GL_TEXTURE_2D); Vec3 skyColor = m_pLevel->getSkyColor(m_pMinecraft->m_pMobPersp, f); - if (m_pMinecraft->m_options.m_bAnaglyphs) + if (m_pMinecraft->getOptions()->m_bAnaglyphs) { skyColor.x = (((skyColor.x * 30.0f) + (skyColor.y * 59.0f)) + (skyColor.z * 11.0f)) / 100.0f; skyColor.y = ((skyColor.x * 30.0f) + (skyColor.y * 70.0f)) / 100.0f; diff --git a/source/common/Options.cpp b/source/common/Options.cpp index f0021d7..50c2183 100644 --- a/source/common/Options.cpp +++ b/source/common/Options.cpp @@ -6,6 +6,8 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include + #include "Options.hpp" #include "Util.hpp" #include "compat/KeyCodes.hpp" @@ -25,7 +27,7 @@ Options::Option Options::Option::AMBIENT_OCCLUSION(10, "options.ao", false, true), Options::Option::GUI_SCALE (11, "options.guiScale", false, false); -void Options::initDefaultValues() +void Options::_initDefaultValues() { field_238 = 2; field_244 = 1.0f; @@ -201,7 +203,14 @@ void Options::initDefaultValues() Options::Options() { - initDefaultValues(); + _initDefaultValues(); +} + +Options::Options(const std::string& folderPath) +{ + m_filePath = folderPath + "/options.txt"; + _initDefaultValues(); + _load(); } std::string getMessage(const Options::Option& option) @@ -209,14 +218,34 @@ std::string getMessage(const Options::Option& option) return "Options::getMessage - Not implemented"; } -void Options::load() +void Options::_load() { - // stub + std::vector strings = readPropertiesFromFile(m_filePath); + + for (int i = 0; i < strings.size(); i += 2) + { + std::string key = strings[i], value = strings[i + 1]; + + if (key == "mp_username") + m_playerName = value; + else if (key == "ctrl_invertmouse") + m_bInvertMouse = readBool(value); + else if (key == "ctrl_autojump") + m_bAutoJump = readBool(value); + else if (key == "gfx_fancygraphics") + m_bFancyGraphics = readBool(value); + else if (key == "mp_server_visible_default") + m_bServerVisibleDefault = readBool(value); + else if (key == "gfx_smoothlighting") + Minecraft::useAmbientOcclusion = m_bAmbientOcclusion = readBool(value); + else if (key == "gfx_viewdistance") + m_iViewDistance = readInt(value); + } } void Options::save() { - // stub + savePropertiesToFile(m_filePath, getOptionStrings()); } std::string Options::getMessage(const Options::Option& option) @@ -257,27 +286,59 @@ std::string Options::saveInt(int i) return ss.str(); } -void Options::update(const std::vector& strings) +std::vector Options::readPropertiesFromFile(const std::string& filePath) { - for (int i = 0; i o; - if (key == "mp_username") - m_playerName = value; - else if (key == "ctrl_invertmouse") - m_bInvertMouse = readBool(value); - else if (key == "ctrl_autojump") - m_bAutoJump = readBool(value); - else if (key == "gfx_fancygraphics") - m_bFancyGraphics = readBool(value); - else if (key == "mp_server_visible_default") - m_bServerVisibleDefault = readBool(value); - else if (key == "gfx_smoothlighting") - Minecraft::useAmbientOcclusion = m_bAmbientOcclusion = readBool(value); - else if (key == "gfx_viewdistance") - m_iViewDistance = readInt(value); + const char* const path = filePath.c_str(); + LOG_I("Loading options from %s", path); + + std::ifstream ifs(path); + if (!ifs.is_open()) + { + LOG_W("%s doesn't exist, resetting to defaults", path); + return o; } + + std::string str; + while (true) + { + if (!std::getline(ifs, str, '\n')) + break; + + if (str.empty() || str[0] == '#') + continue; + + std::stringstream ss; + ss << str; + + std::string key, value; + if (std::getline(ss, key, ':') && std::getline(ss, value)) + { + o.push_back(key); + o.push_back(value); + } + } + + return o; +} + +void Options::savePropertiesToFile(const std::string& filePath, std::vector properties) +{ + assert(properties.size() % 2 == 0); + + std::ofstream os; + os.open(filePath.c_str()); + if (!os.is_open()) + { + LOG_E("Failed to read %s", filePath); + return; + } + + os << "#Config file for Minecraft PE. The # at the start denotes a comment, removing it makes it a command.\n\n"; + + for (int i = 0; i < properties.size(); i += 2) + os << properties[i] << ':' << properties[i + 1] << '\n'; } std::vector Options::getOptionStrings() diff --git a/source/common/Options.hpp b/source/common/Options.hpp index e407f21..7cc6459 100644 --- a/source/common/Options.hpp +++ b/source/common/Options.hpp @@ -67,44 +67,23 @@ class Options public: struct Option; struct KeyBind; -public: - Options(); - void initDefaultValues(); - void load(); - void save(); - std::string getMessage(const Options::Option&); - void update(const std::vector& string); - std::vector getOptionStrings(); - -public: +private: static bool readBool(const std::string& str); static int readInt(const std::string& str); static std::string saveBool(bool b); static std::string saveInt(int i); + static std::vector readPropertiesFromFile(const std::string& filePath); + static void savePropertiesToFile(const std::string& filePath, std::vector properties); +private: + void _initDefaultValues(); + void _load(); public: - struct Option - { - bool field_0; - bool field_1; - std::string str; - int field_1C; - - Option(int i, const std::string& str, bool b1, bool b2) : field_0(b1), field_1(b2), str(str), field_1C(i) {} - - static Option MUSIC; - static Option SOUND; - static Option INVERT_MOUSE; - static Option SENSITIVITY; - static Option RENDER_DISTANCE; - static Option VIEW_BOBBING; - static Option ANAGLYPH; - static Option LIMIT_FRAMERATE; - static Option DIFFICULTY; - static Option GRAPHICS; - static Option AMBIENT_OCCLUSION; - static Option GUI_SCALE; - }; + Options(); + Options(const std::string& folderPath); + void save(); + std::string getMessage(const Options::Option&); + std::vector getOptionStrings(); int getKey(eKeyMappingIndex idx) { @@ -115,6 +94,9 @@ public: return getKey(idx) == keyCode; } +private: + std::string m_filePath; + public: float field_0; float m_fMasterVolume; @@ -143,5 +125,29 @@ public: bool m_bServerVisibleDefault; bool m_bAutoJump; bool m_bDebugText; + +public: + struct Option + { + bool field_0; + bool field_1; + std::string str; + int field_1C; + + Option(int i, const std::string& str, bool b1, bool b2) : field_0(b1), field_1(b2), str(str), field_1C(i) {} + + static Option MUSIC; + static Option SOUND; + static Option INVERT_MOUSE; + static Option SENSITIVITY; + static Option RENDER_DISTANCE; + static Option VIEW_BOBBING; + static Option ANAGLYPH; + static Option LIMIT_FRAMERATE; + static Option DIFFICULTY; + static Option GRAPHICS; + static Option AMBIENT_OCCLUSION; + static Option GUI_SCALE; + }; }; diff --git a/source/common/StandardOut.cpp b/source/common/StandardOut.cpp new file mode 100644 index 0000000..b9524f0 --- /dev/null +++ b/source/common/StandardOut.cpp @@ -0,0 +1,46 @@ +#include +#include + +#ifdef _WIN32 +#include +#endif + +#include "StandardOut.hpp" +#include "Util.hpp" + +StandardOut* const StandardOut::singleton() +{ + // This is automatically allocated when accessed for the first time, + // and automatically deallocated when runtime concludes. + static StandardOut standardOut = StandardOut(); + return &standardOut; +} + +void StandardOut::print(const char* const str) +{ + std::cout << str << std::endl; +#ifdef _WIN32 + OutputDebugStringA(str); + OutputDebugStringA("\n"); +#endif +} + +void StandardOut::print(std::string str) +{ + print(str.c_str()); +} + +void StandardOut::vprintf(const char* const fmt, va_list argPtr) +{ + print(Util::vformat(fmt, argPtr)); +} + +void StandardOut::printf(const char* const fmt, ...) +{ + va_list argList; + va_start(argList, fmt); + + vprintf(fmt, argList); + + va_end(argList); +} \ No newline at end of file diff --git a/source/common/StandardOut.hpp b/source/common/StandardOut.hpp new file mode 100644 index 0000000..05862e5 --- /dev/null +++ b/source/common/StandardOut.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include + +class StandardOut +{ +public: + static StandardOut* const singleton(); + + void print(const char* const str); + void print(std::string str); + void vprintf(const char* const fmt, va_list argPtr); + void printf(const char* const fmt, ...); +}; + +#ifdef _DEBUG + +#define LOG(...) StandardOut::singleton()->printf(__VA_ARGS__) + +#ifdef PLATFORM_ANDROID +#define LOG_I(...) __android_log_print(ANDROID_LOG_INFO, "MinecraftPE", __VA_ARGS__) +#define LOG_W(...) __android_log_print(ANDROID_LOG_WARN, "MinecraftPE", __VA_ARGS__) +#define LOG_E(...) __android_log_print(ANDROID_LOG_ERROR, "MinecraftPE", __VA_ARGS__) +#else +#define LOG_I(...) LOG("[Info]: " __VA_ARGS__) +#define LOG_W(...) LOG("[WARN]: " __VA_ARGS__) +#define LOG_E(...) LOG("[ERROR]: " __VA_ARGS__) +#endif + +#else + +#define LOG(...) +#define LOG_I(...) +#define LOG_W(...) +#define LOG_E(...) + +#endif diff --git a/source/common/Util.cpp b/source/common/Util.cpp index 0357c25..398b43c 100644 --- a/source/common/Util.cpp +++ b/source/common/Util.cpp @@ -46,7 +46,7 @@ std::string Util::stringTrim(const std::string& str) std::string Util::vformat(const char *fmt, va_list argPtr) { - char str[8192]; + char str[1024]; vsnprintf(str, sizeof(str), fmt, argPtr); diff --git a/source/network/ServerSideNetworkHandler.cpp b/source/network/ServerSideNetworkHandler.cpp index 3afb3dc..4dd6f96 100644 --- a/source/network/ServerSideNetworkHandler.cpp +++ b/source/network/ServerSideNetworkHandler.cpp @@ -54,7 +54,7 @@ void ServerSideNetworkHandler::levelGenerated(Level* level) level->addListener(this); - allowIncomingConnections(m_pMinecraft->m_options.m_bServerVisibleDefault); + allowIncomingConnections(m_pMinecraft->getOptions()->m_bServerVisibleDefault); m_onlinePlayers[m_pMinecraft->m_pLocalPlayer->m_guid] = new OnlinePlayer(m_pMinecraft->m_pLocalPlayer, m_pMinecraft->m_pLocalPlayer->m_guid); } @@ -345,7 +345,7 @@ void ServerSideNetworkHandler::allowIncomingConnections(bool b) { if (b) { - m_pRakNetInstance->announceServer(m_pMinecraft->m_options.m_playerName); + m_pRakNetInstance->announceServer(m_pMinecraft->getOptions()->m_playerName); } else { diff --git a/source/world/entity/LocalPlayer.cpp b/source/world/entity/LocalPlayer.cpp index d06794e..c349d15 100644 --- a/source/world/entity/LocalPlayer.cpp +++ b/source/world/entity/LocalPlayer.cpp @@ -68,18 +68,18 @@ void LocalPlayer::animateRespawn() void LocalPlayer::calculateFlight(float x, float y, float z) { - float f1 = m_pMinecraft->m_options.field_244; + float f1 = m_pMinecraft->getOptions()->field_244; float x1 = f1 * x; float z1 = f1 * z; float y1 = 0.0f; - if (Keyboard::isKeyDown(m_pMinecraft->m_options.getKey(KM_FLY_UP))) + if (Keyboard::isKeyDown(m_pMinecraft->getOptions()->getKey(KM_FLY_UP))) y1 = f1 * 0.2f; - if (Keyboard::isKeyDown(m_pMinecraft->m_options.getKey(KM_FLY_DOWN))) + if (Keyboard::isKeyDown(m_pMinecraft->getOptions()->getKey(KM_FLY_DOWN))) y1 = f1 * -0.2f; field_BFC += x1; - float f2 = m_pMinecraft->m_options.field_8 * 0.35f; + float f2 = m_pMinecraft->getOptions()->field_8 * 0.35f; float f3 = f2 * (field_BFC - field_C00); float f4 = field_C04 + 0.5f * (f3 - field_C04); field_C04 = f4; @@ -128,7 +128,7 @@ int LocalPlayer::move(float x, float y, float z) int result = 0; LocalPlayer* pLP = m_pMinecraft->m_pLocalPlayer; - if (Minecraft::DEADMAU5_CAMERA_CHEATS && pLP == this && m_pMinecraft->m_options.m_bFlyCheat) + if (Minecraft::DEADMAU5_CAMERA_CHEATS && pLP == this && m_pMinecraft->getOptions()->m_bFlyCheat) { //@HUH: Using m_pMinecraft->m_pLocalPlayer instead of this, even though they're the same pLP->m_bNoCollision = true; @@ -194,7 +194,7 @@ int LocalPlayer::move(float x, float y, float z) return 1; // are we trying to walk into stairs or a slab? - if (tileOnTop != Tile::stairs_stone->m_ID && tileOnTop != Tile::stairs_wood->m_ID && tileOnTop != Tile::stoneSlabHalf->m_ID && m_pMinecraft->m_options.m_bAutoJump) + if (tileOnTop != Tile::stairs_stone->m_ID && tileOnTop != Tile::stairs_wood->m_ID && tileOnTop != Tile::stoneSlabHalf->m_ID && m_pMinecraft->getOptions()->m_bAutoJump) // Nope, we're walking towards a full block. Trigger an auto jump. m_nAutoJumpFrames = 1; }