From fed9cf2d95396befa9c6497ba3d435065b91716c Mon Sep 17 00:00:00 2001 From: MatthewBeshay <92357869+MatthewBeshay@users.noreply.github.com> Date: Mon, 23 Mar 2026 18:53:18 +1100 Subject: [PATCH] fix: resolve all build warnings and notes --- Minecraft.Client/Level/MultiPlayerLevel.cpp | 2 +- Minecraft.Client/Minecraft.cpp | 23 +++++------- .../Platform/Common/DLC/DLCPack.cpp | 6 +-- .../Platform/Common/DLC/DLCSkinFile.cpp | 5 ++- .../GameRules/LevelGenerationOptions.cpp | 6 +++ .../Platform/Common/Tutorial/Tutorial.cpp | 8 ++-- .../Common/UI/IUIScene_BeaconMenu.cpp | 13 ++++++- .../Common/UI/IUIScene_HorseInventoryMenu.cpp | 6 ++- .../Platform/Common/UI/UIControl_Base.cpp | 7 ++-- .../Platform/Common/UI/UIScene.cpp | 16 ++++---- .../Platform/Common/UI/UIScene_BeaconMenu.cpp | 10 ++++- .../Common/UI/UIScene_CraftingMenu.cpp | 2 + .../Platform/Common/UI/UIScene_HowToPlay.cpp | 7 ++-- .../Common/UI/UIScene_HowToPlayMenu.cpp | 8 ++-- .../Platform/Common/UI/UIScene_JoinMenu.cpp | 37 ++++++++----------- .../Common/UI/UIScene_LeaderboardsMenu.cpp | 4 +- .../Common/UI/UIScene_TradingMenu.cpp | 9 +++-- .../Player/MultiPlayerLocalPlayer.cpp | 4 +- Minecraft.Client/Player/ServerPlayer.cpp | 23 ++++++------ .../Rendering/Culling/DirtyChunkSorter.h | 5 +-- .../Rendering/Culling/DistanceChunkSorter.h | 5 +-- Minecraft.Client/Rendering/GameRenderer.cpp | 29 ++++++++------- Minecraft.Client/Rendering/LevelRenderer.cpp | 26 ++++++------- .../Rendering/Models/HumanoidModel.cpp | 4 +- .../Rendering/Models/LeashKnotModel.cpp | 4 +- Minecraft.Client/Textures/Textures.cpp | 22 +++++------ Minecraft.World/AI/Goals/MeleeAttackGoal.cpp | 18 ++++----- Minecraft.World/AI/Goals/MeleeAttackGoal.h | 6 ++- .../Blocks/PistonMovingTileEntity.cpp | 6 ++- Minecraft.World/Core/DispenseItemBehavior.h | 4 +- Minecraft.World/Core/Position.h | 3 +- Minecraft.World/Entities/EntitySelector.h | 3 +- Minecraft.World/Entities/Mobs/Animal.cpp | 28 +++++++------- Minecraft.World/Entities/Mobs/Minecart.cpp | 32 ++++++++-------- Minecraft.World/Entities/Mobs/Villager.cpp | 26 +++++++++++-- Minecraft.World/Level/BaseMobSpawner.h | 4 +- Minecraft.World/Level/CustomLevelSource.cpp | 12 +++--- Minecraft.World/Level/LevelChunk.cpp | 27 +++++++------- Minecraft.World/Level/RandomLevelSource.cpp | 12 +++--- Minecraft.World/Network/Connection.cpp | 20 ++-------- Minecraft.World/Network/Connection.h | 2 +- Minecraft.World/Util/CombatTracker.cpp | 28 ++++++++------ Minecraft.World/Util/StringHelpers.cpp | 10 +++-- .../Sources/HellRandomLevelSource.cpp | 4 +- .../WorldGen/Structures/StructureStart.h | 2 +- 45 files changed, 294 insertions(+), 244 deletions(-) diff --git a/Minecraft.Client/Level/MultiPlayerLevel.cpp b/Minecraft.Client/Level/MultiPlayerLevel.cpp index 29a1e9617..5f87af715 100644 --- a/Minecraft.Client/Level/MultiPlayerLevel.cpp +++ b/Minecraft.Client/Level/MultiPlayerLevel.cpp @@ -523,7 +523,7 @@ bool MultiPlayerLevel::setData( // better to early out here int d = getData(x, y, z); - if ((d == data)) { + if (d == data) { // If we early-out, its important that we still do a checkLight here // (which would otherwise have happened as part of // Level::setTileAndDataNoUpdate) This is because since we are diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index f4e577d90..e76765dd0 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -583,7 +583,6 @@ void Minecraft::setScreen(Screen* screen) { gui->clearMessages(); } - this->screen = screen; if (screen != NULL) { // releaseMouse(); // 4J - removed ScreenSizeCalculator ssc(options, width, height); @@ -668,7 +667,6 @@ void Minecraft::destroy() { gui->clearMessages(); } - this->screen = screen; if (screen != NULL) { // releaseMouse(); // 4J - removed ScreenSizeCalculator ssc(options, width, height); @@ -1921,7 +1919,7 @@ void Minecraft::run_middle() { timer->advanceTime(); } - //int64_t beforeTickTime = System::nanoTime(); + // int64_t beforeTickTime = System::nanoTime(); for (int i = 0; i < timer->ticks; i++) { bool bLastTimerTick = (i == (timer->ticks - 1)); // 4J-PB - the tick here can run more than once, and this is a @@ -2010,7 +2008,7 @@ void Minecraft::run_middle() { // SparseDataStorage::tick(); // // 4J added } - //int64_t tickDuraction = System::nanoTime() - beforeTickTime; + // int64_t tickDuraction = System::nanoTime() - beforeTickTime; MemSect(31); checkGlError(L"Pre render"); MemSect(0); @@ -2090,11 +2088,9 @@ void Minecraft::run_middle() { // If there's an unoccupied quadrant, then clear that to black if (unoccupiedQuadrant > -1) { // render a logo - RenderManager.StateSetViewport(( - C4JRender:: - eViewportType)(C4JRender:: - VIEWPORT_TYPE_QUADRANT_TOP_LEFT + - unoccupiedQuadrant)); + RenderManager.StateSetViewport((C4JRender::eViewportType)( + C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT + + unoccupiedQuadrant)); glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); @@ -2612,8 +2608,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { if (player->isRiding()) { std::shared_ptr mount = player->riding; - if (mount->instanceof(eTYPE_MINECART) || - mount->instanceof(eTYPE_BOAT)) { + if (mount->instanceof (eTYPE_MINECART) || mount->instanceof + (eTYPE_BOAT)) { *piAlt = IDS_TOOLTIPS_EXIT; } else { *piAlt = IDS_TOOLTIPS_DISMOUNT; @@ -3639,7 +3635,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { break; default: - if (hitResult->entity->instanceof(eTYPE_MOB)) { + if (hitResult->entity->instanceof (eTYPE_MOB)) { std::shared_ptr mob = std::dynamic_pointer_cast( hitResult->entity); @@ -4529,7 +4525,8 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/, player->setXuid(playerXUIDOffline); player->setOnlineXuid(playerXUIDOnline); - player->m_displayName = ProfileManager.GetDisplayName(iPrimaryPlayer); + player->m_displayName = + ProfileManager.GetDisplayName(iPrimaryPlayer); player->resetPos(); gameMode->initPlayer(player); diff --git a/Minecraft.Client/Platform/Common/DLC/DLCPack.cpp b/Minecraft.Client/Platform/Common/DLC/DLCPack.cpp index 372f81240..81d3ab80d 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCPack.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCPack.cpp @@ -365,14 +365,10 @@ bool DLCPack::hasPurchasedFile(DLCManager::EDLCType type, void DLCPack::UpdateLanguage() { // find the language file - DLCManager::e_DLCType_LocalisationData; - DLCFile* file = NULL; - if (m_files[DLCManager::e_DLCType_LocalisationData].size() > 0) { - file = m_files[DLCManager::e_DLCType_LocalisationData][0]; DLCLocalisationFile* localisationFile = (DLCLocalisationFile*)getFile( DLCManager::e_DLCType_LocalisationData, L"languages.loc"); StringTable* strTable = localisationFile->getStringTable(); strTable->ReloadStringTable(); } -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/DLC/DLCSkinFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCSkinFile.cpp index 3773d336f..da9e7df83 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCSkinFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCSkinFile.cpp @@ -135,7 +135,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, // add this to the skin's vector of parts m_AdditionalBoxes.push_back(pSkinBox); } break; - case DLCManager::e_DLCParamType_Anim: + case DLCManager::e_DLCParamType_Anim: { #ifdef __PS3__ // 4J Stu - The Xbox version used swscanf_s which isn't available in // GCC. @@ -147,6 +147,9 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, DWORD skinId = app.getSkinIdFromPath(m_path); app.SetAnimOverrideBitmask(skinId, m_uiAnimOverrideBitmask); break; + } + default: + break; } } diff --git a/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp b/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp index cc5b5dfcf..8e2260a11 100644 --- a/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp @@ -675,6 +675,8 @@ std::wstring LevelGenerationOptions::getDefaultSaveName() { return getString(info()->getDefaultSaveName()); case eSrc_tutorial: return app.GetString(IDS_TUTORIALSAVENAME); + default: + break; } return L""; } @@ -686,6 +688,8 @@ LPCWSTR LevelGenerationOptions::getWorldName() { return getString(info()->getWorldName()); case eSrc_tutorial: return app.GetString(IDS_PLAY_TUTORIAL); + default: + break; } return L""; } @@ -697,6 +701,8 @@ LPCWSTR LevelGenerationOptions::getDisplayName() { return getString(info()->getDisplayName()); case eSrc_tutorial: return L""; + default: + break; } return L""; } diff --git a/Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp b/Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp index 8520d4de4..fe45db1fb 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp @@ -2533,7 +2533,7 @@ bool Tutorial::setMessage(PopupMessageDetails* message) { } else if ((m_lastMessage != NULL && m_lastMessage->m_messageId != -1)) //&& (lastMessageTime + m_iTutorialReminderTime ) > - //GetTickCount() ) + // GetTickCount() ) { // This should cause the popup to dissappear TutorialPopupInfo popupInfo; @@ -2819,8 +2819,8 @@ void Tutorial::onLookAtEntity(std::shared_ptr entity) { } } - if ((m_CurrentState == e_Tutorial_State_Gameplay) && - entity->instanceof(eTYPE_HORSE)) { + if ((m_CurrentState == e_Tutorial_State_Gameplay) && entity->instanceof + (eTYPE_HORSE)) { changeTutorialState(e_Tutorial_State_Horse); } @@ -2839,6 +2839,8 @@ void Tutorial::onRideEntity(std::shared_ptr entity) { case eTYPE_BOAT: changeTutorialState(e_Tutorial_State_Riding_Boat); break; + default: + break; } } diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.cpp index d61dd508e..6869ce689 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_BeaconMenu.cpp @@ -192,6 +192,8 @@ bool IUIScene_BeaconMenu::IsSectionSlotList(ESceneSection eSection) { case eSectionBeaconInventory: case eSectionBeaconUsing: return true; + default: + break; } return false; } @@ -238,7 +240,7 @@ void IUIScene_BeaconMenu::handleOtherClicked(int iPad, ESceneSection eSection, case eSectionBeaconPrimaryTierTwoTwo: case eSectionBeaconPrimaryTierThree: case eSectionBeaconSecondaryOne: - case eSectionBeaconSecondaryTwo: + case eSectionBeaconSecondaryTwo: { if (IsPowerButtonSelected(eSection)) { return; } @@ -254,6 +256,9 @@ void IUIScene_BeaconMenu::handleOtherClicked(int iPad, ESceneSection eSection, } SetPowerButtonSelected(eSection); break; + } + default: + break; }; } @@ -364,6 +369,8 @@ std::vector* IUIScene_BeaconMenu::GetSectionHoverText( eHTMLColor_White); desc->push_back(string); } break; + default: + break; } return desc; } @@ -375,6 +382,8 @@ bool IUIScene_BeaconMenu::IsVisible(ESceneSection eSection) { // This isn't visible return false; } + default: + break; } return true; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_HorseInventoryMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_HorseInventoryMenu.cpp index 7ae9307dc..edb469933 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_HorseInventoryMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_HorseInventoryMenu.cpp @@ -168,6 +168,8 @@ bool IUIScene_HorseInventoryMenu::IsSectionSlotList(ESceneSection eSection) { case eSectionHorseInventory: case eSectionHorseUsing: return true; + default: + break; } return false; } @@ -188,6 +190,8 @@ bool IUIScene_HorseInventoryMenu::IsVisible(ESceneSection eSection) { case eSectionHorseInventory: case eSectionHorseUsing: return true; + default: + break; } return false; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_Base.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_Base.cpp index db51be74a..9b5f75e8a 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_Base.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_Base.cpp @@ -6,7 +6,6 @@ UIControl_Base::UIControl_Base() { m_bLabelChanged = false; - m_label; m_id = 0; } @@ -29,7 +28,8 @@ void UIControl_Base::tick() { // app.DebugPrintf("Calling SetLabel - '%ls'\n", m_label.c_str()); m_bLabelChanged = false; - const std::u16string convLabel = wstring_to_u16string(m_label.getString()); + const std::u16string convLabel = + wstring_to_u16string(m_label.getString()); IggyDataValue result; IggyDataValue value[1]; @@ -57,7 +57,8 @@ void UIControl_Base::setLabel(UIString label, bool instant, bool force) { if (m_bLabelChanged && instant) { m_bLabelChanged = false; - const std::u16string convLabel = wstring_to_u16string(m_label.getString()); + const std::u16string convLabel = + wstring_to_u16string(m_label.getString()); IggyDataValue result; IggyDataValue value[1]; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene.cpp b/Minecraft.Client/Platform/Common/UI/UIScene.cpp index f45a6ab13..e9bb40f96 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene.cpp @@ -373,10 +373,10 @@ void UIScene::getDebugMemoryUseRecursive(const std::wstring& moviePath, rrbool res; IggyMemoryUseInfo internalMemoryInfo; int internalIteration = 0; - while (res = IggyDebugGetMemoryUseInfo(swf, NULL, memoryInfo.subcategory, - memoryInfo.subcategory_stringlen, - internalIteration, - &internalMemoryInfo)) { + while ((res = IggyDebugGetMemoryUseInfo(swf, 0, memoryInfo.subcategory, + memoryInfo.subcategory_stringlen, + internalIteration, + &internalMemoryInfo))) { app.DebugPrintf( app.USER_SR, "%ls - %.*s static: %d ( %d ) dynamic: %d ( %d )\n", moviePath.c_str(), internalMemoryInfo.subcategory_stringlen, @@ -401,8 +401,8 @@ void UIScene::PrintTotalMemoryUsage(int64_t& totalStatic, int iteration = 0; int64_t sceneStatic = 0; int64_t sceneDynamic = 0; - while (res = IggyDebugGetMemoryUseInfo(swf, NULL, "", 0, iteration, - &memoryInfo)) { + while ((res = IggyDebugGetMemoryUseInfo(swf, 0, "", 0, iteration, + &memoryInfo))) { sceneStatic += memoryInfo.static_allocation_bytes; sceneDynamic += memoryInfo.dynamic_allocation_bytes; totalStatic += memoryInfo.static_allocation_bytes; @@ -771,7 +771,7 @@ void UIScene::_customDrawSlotControl(CustomDrawData* region, int iPad, // if(m_parentLayer == NULL) // { // app.DebugPrintf("A scene is trying to navigate forwards, but -//it's parent layer is NULL!\n"); #ifndef _CONTENT_PACKAGE +// it's parent layer is NULL!\n"); #ifndef _CONTENT_PACKAGE // __debugbreak(); // #endif // } @@ -789,7 +789,7 @@ void UIScene::navigateBack() { if (m_parentLayer == NULL) { // app.DebugPrintf("A scene is trying to navigate back, but it's -//parent layer is NULL!\n"); +// parent layer is NULL!\n"); #ifndef _CONTENT_PACKAGE // __debugbreak(); #endif diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.cpp index 2f60599e6..7ef5b3768 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_BeaconMenu.cpp @@ -419,6 +419,8 @@ int UIScene_BeaconMenu::GetPowerButtonId(ESceneSection eSection) { case eSectionBeaconSecondaryTwo: return m_buttonsPowers[eControl_Secondary2].GetData(); break; + default: + break; }; return 0; } @@ -446,6 +448,8 @@ bool UIScene_BeaconMenu::IsPowerButtonSelected(ESceneSection eSection) { case eSectionBeaconSecondaryTwo: return m_buttonsPowers[eControl_Secondary2].IsButtonSelected(); break; + default: + break; }; return false; } @@ -468,6 +472,8 @@ void UIScene_BeaconMenu::SetPowerButtonSelected(ESceneSection eSection) { m_buttonsPowers[eControl_Secondary1].SetButtonSelected(false); m_buttonsPowers[eControl_Secondary2].SetButtonSelected(false); break; + default: + break; }; switch (eSection) { @@ -492,5 +498,7 @@ void UIScene_BeaconMenu::SetPowerButtonSelected(ESceneSection eSection) { case eSectionBeaconSecondaryTwo: return m_buttonsPowers[eControl_Secondary2].SetButtonSelected(true); break; + default: + return; }; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp index eeab7ea06..f486bea1e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp @@ -730,6 +730,8 @@ void UIScene_CraftingMenu::HandleMessage(EUIMessage message, void* data) { case eUIMessage_InventoryUpdated: handleInventoryUpdated(data); break; + default: + break; }; } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlay.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlay.cpp index 8dc2fcdc0..a18b42fd0 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlay.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlay.cpp @@ -163,11 +163,11 @@ UIScene_HowToPlay::UIScene_HowToPlay(int iPad, void* initData, // Extract pad and required page from init data. We just put the data into // the pointer rather than using it as an address. - size_t uiInitData = (size_t)(initData); + uintptr_t uiInitData = reinterpret_cast(initData); EHowToPlayPage eStartPage = (EHowToPlayPage)((uiInitData >> 16) & - 0xFFF); // Ignores MSB which is set to 1! + 0xFFFu); // Ignores MSB which is set to 1! TelemetryManager->RecordMenuShown( m_iPad, eUIScene_HowToPlay, (ETelemetry_HowToPlay_SubMenuId)eStartPage); @@ -342,7 +342,8 @@ void UIScene_HowToPlay::StartPage(EHowToPlayPage ePage) { value[0].number = gs_pageToFlashMapping[(int)ePage]; for (unsigned int i = 0; i < paragraphs.size(); ++i) { - const std::u16string convParagraph = wstring_to_u16string(paragraphs[i]); + const std::u16string convParagraph = + wstring_to_u16string(paragraphs[i]); stringVal[i].string = convParagraph.c_str(); stringVal[i].length = convParagraph.length(); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.cpp index a10427f3a..291e01c6b 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_HowToPlayMenu.cpp @@ -129,9 +129,7 @@ void UIScene_HowToPlayMenu::handleReload() { } else #endif - { - m_buttonListHowTo.addItem(app.GetString(m_uiHTPButtonNameA[i]), i); - } + { m_buttonListHowTo.addItem(app.GetString(m_uiHTPButtonNameA[i]), i); } } doHorizontalResizeCheck(); @@ -174,6 +172,8 @@ void UIScene_HowToPlayMenu::handlePress(F64 controlId, F64 childId) { unsigned int uiInitData; uiInitData = ((1 << 31) | (m_uiHTPSceneA[(int)childId] << 16) | (short)(m_iPad)); - ui.NavigateToScene(m_iPad, eUIScene_HowToPlay, (void*)(uiInitData)); + ui.NavigateToScene( + m_iPad, eUIScene_HowToPlay, + reinterpret_cast(static_cast(uiInitData))); } } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp index 9c345a710..cf30a50a2 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp @@ -383,29 +383,22 @@ void UIScene_JoinMenu::StartSharedLaunchFlow() { int UIScene_JoinMenu::StartGame_SignInReturned(void* pParam, bool bContinue, int iPad) { - UIScene_JoinMenu* pClass = (UIScene_JoinMenu*)pParam; - - if (bContinue == true) { - // It's possible that the player has not signed in - they can back out - UIScene_JoinMenu* pClass = - (UIScene_JoinMenu*)ui.GetSceneFromCallbackId((size_t)pParam); - - if (pClass) { - if (bContinue == true) { - // It's possible that the player has not signed in - they can - // back out - if (ProfileManager.IsSignedIn(iPad)) { - JoinGame(pClass); - } else { - pClass->m_bIgnoreInput = false; - } - } else { - pClass->m_bIgnoreInput = false; - } - pClass->m_bIgnoreInput = false; - } - return 0; + UIScene_JoinMenu* pClass = (UIScene_JoinMenu*)ui.GetSceneFromCallbackId( + reinterpret_cast(pParam)); + if (pClass == NULL) { + pClass = (UIScene_JoinMenu*)pParam; } + + if (bContinue == true && pClass != NULL && + ProfileManager.IsSignedIn(iPad)) { + JoinGame(pClass); + } + + if (pClass != NULL) { + pClass->m_bIgnoreInput = false; + } + + return 0; } // Shared function to join the game that is the same whether we used the diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp index 9deae896d..1563973d0 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp @@ -14,11 +14,11 @@ const int UIScene_LeaderboardsMenu::TitleIcons [UIScene_LeaderboardsMenu::NUM_LEADERBOARDS][7] = { {UIControl_LeaderboardList::e_ICON_TYPE_WALKED, UIControl_LeaderboardList::e_ICON_TYPE_FALLEN, Item::minecart_Id, - Item::boat_Id, NULL}, + Item::boat_Id, 0}, {Tile::dirt_Id, Tile::cobblestone_Id, Tile::sand_Id, Tile::stone_Id, Tile::gravel_Id, Tile::clay_Id, Tile::obsidian_Id}, {Item::egg_Id, Item::wheat_Id, Tile::mushroom_brown_Id, Tile::reeds_Id, - Item::bucket_milk_Id, Tile::pumpkin_Id, NULL}, + Item::bucket_milk_Id, Tile::pumpkin_Id, 0}, {UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIE, UIControl_LeaderboardList::e_ICON_TYPE_SKELETON, UIControl_LeaderboardList::e_ICON_TYPE_CREEPER, diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.cpp index be4e5d4ae..2eea5bb91 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_TradingMenu.cpp @@ -256,8 +256,9 @@ void UIScene_TradingMenu::setTradeRedBox(int index, bool show) { m_slotListTrades.showSlotRedBox(index, show); } -void UIScene_TradingMenu::setOfferDescription(std::vector* description) { - std::wstring descriptionStr = HtmlString::Compose(description); +void UIScene_TradingMenu::setOfferDescription( + std::vector* description) { + std::wstring descriptionStr = HtmlString::Compose(description); const std::u16string conv = wstring_to_u16string(descriptionStr); IggyDataValue result; @@ -279,9 +280,11 @@ void UIScene_TradingMenu::HandleMessage(EUIMessage message, void* data) { case eUIMessage_InventoryUpdated: handleInventoryUpdated(data); break; + default: + break; }; } void UIScene_TradingMenu::handleInventoryUpdated(LPVOID data) { HandleInventoryUpdated(); -} \ No newline at end of file +} diff --git a/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp b/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp index 9e1c5babd..4d287b9cc 100644 --- a/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp +++ b/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp @@ -351,6 +351,8 @@ void MultiplayerLocalPlayer::ride(std::shared_ptr e) { case eTYPE_PIG: eventType = eTelemetryInGame_Ride_Pig; break; + default: + break; }; } TelemetryManager->RecordEnemyKilledOrOvercome(GetXboxPad(), 0, y, 0, 0, @@ -480,4 +482,4 @@ void MultiplayerLocalPlayer::StressTestMove(double* tempX, double* tempY, absMoveTo(nx, ny, nz, yRot, xRot); stressTestCount++; } -#endif \ No newline at end of file +#endif diff --git a/Minecraft.Client/Player/ServerPlayer.cpp b/Minecraft.Client/Player/ServerPlayer.cpp index 1070f54cf..43562a96f 100644 --- a/Minecraft.Client/Player/ServerPlayer.cpp +++ b/Minecraft.Client/Player/ServerPlayer.cpp @@ -42,10 +42,10 @@ ServerPlayer::ServerPlayer(MinecraftServer* server, Level* level, lastMoveX = lastMoveZ = 0; spewTimer = 0; lastRecordedHealthAndAbsorption = FLT_MIN; - lastSentHealth = -99999999; + lastSentHealth = -99999999.0f; lastSentFood = -99999999; lastFoodSaturationZero = true; - lastSentExp = -99999999; + lastSentExp = -99999999.0f; invulnerableTime = 20 * 3; containerCounter = 0; ignoreSlotUpdateHack = false; @@ -656,19 +656,20 @@ bool ServerPlayer::hurt(DamageSource* dmgSource, float dmg) { // sometimes NULL. std::shared_ptr source = dmgSource->getDirectEntity(); - if (source->instanceof(eTYPE_PLAYER) && - !std::dynamic_pointer_cast(source)->canHarmPlayer( - std::dynamic_pointer_cast(shared_from_this()))) { + if (source->instanceof + (eTYPE_PLAYER) && + !std::dynamic_pointer_cast(source)->canHarmPlayer( + std::dynamic_pointer_cast(shared_from_this()))) { return false; } - if ((source != NULL) && source->instanceof(eTYPE_ARROW)) { + if ((source != NULL) && source->instanceof (eTYPE_ARROW)) { std::shared_ptr arrow = std::dynamic_pointer_cast(source); - if ((arrow->owner != NULL) && - arrow->owner->instanceof(eTYPE_PLAYER) && - !canHarmPlayer( - std::dynamic_pointer_cast(arrow->owner))) { + if ((arrow->owner != NULL) && arrow->owner->instanceof + (eTYPE_PLAYER) && + !canHarmPlayer( + std::dynamic_pointer_cast(arrow->owner))) { return false; } } @@ -1353,7 +1354,7 @@ void ServerPlayer::disconnect() { } } -void ServerPlayer::resetSentInfo() { lastSentHealth = -99999999; } +void ServerPlayer::resetSentInfo() { lastSentHealth = -99999999.0f; } void ServerPlayer::displayClientMessage(int messageId) { ChatPacket::EChatPacketMessage messageType = ChatPacket::e_ChatCustom; diff --git a/Minecraft.Client/Rendering/Culling/DirtyChunkSorter.h b/Minecraft.Client/Rendering/Culling/DirtyChunkSorter.h index be64b7ae0..cc5d1aeac 100644 --- a/Minecraft.Client/Rendering/Culling/DirtyChunkSorter.h +++ b/Minecraft.Client/Rendering/Culling/DirtyChunkSorter.h @@ -2,8 +2,7 @@ class Chunk; class Mob; -class DirtyChunkSorter - : public std::binary_function { +class DirtyChunkSorter { private: std::shared_ptr cameraEntity; int playerIndex; // 4J added @@ -12,4 +11,4 @@ public: DirtyChunkSorter(std::shared_ptr cameraEntity, int playerIndex); // 4J - added player index bool operator()(const Chunk* a, const Chunk* b) const; -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Rendering/Culling/DistanceChunkSorter.h b/Minecraft.Client/Rendering/Culling/DistanceChunkSorter.h index 6cf18578b..66c38fd3e 100644 --- a/Minecraft.Client/Rendering/Culling/DistanceChunkSorter.h +++ b/Minecraft.Client/Rendering/Culling/DistanceChunkSorter.h @@ -2,12 +2,11 @@ class Entity; class Chunk; -class DistanceChunkSorter - : public std::binary_function { +class DistanceChunkSorter { private: double ix, iy, iz; public: DistanceChunkSorter(std::shared_ptr player); bool operator()(const Chunk* a, const Chunk* b) const; -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index f4b1608a1..e099f7e18 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -331,7 +331,11 @@ void GameRenderer::pick(float a) { } } else if (p != NULL) { double dd = from->distanceTo(p->pos); - if (e == mc->cameraTargetPlayer->riding != NULL) { + std::shared_ptr ridingEntity = + mc->cameraTargetPlayer->riding; + // 4jcraft: compare the mounted entity explicitly so riding the hit + // target does not get collapsed into a boolean/null comparison. + if (ridingEntity != nullptr && e == ridingEntity) { if (nearest == 0) { hovered = e; } @@ -347,7 +351,7 @@ void GameRenderer::pick(float a) { if (nearest < dist || (mc->hitResult == NULL)) { if (mc->hitResult != NULL) delete mc->hitResult; mc->hitResult = new HitResult(hovered); - if (hovered->instanceof(eTYPE_LIVINGENTITY)) { + if (hovered->instanceof (eTYPE_LIVINGENTITY)) { mc->crosshairPickMob = std::dynamic_pointer_cast(hovered); } @@ -420,7 +424,7 @@ void GameRenderer::bobHurt(float a) { } void GameRenderer::bobView(float a) { - if (!mc->cameraTargetPlayer->instanceof(eTYPE_LIVINGENTITY)) return; + if (!mc->cameraTargetPlayer->instanceof (eTYPE_LIVINGENTITY)) return; std::shared_ptr player = std::dynamic_pointer_cast(mc->cameraTargetPlayer); @@ -669,7 +673,8 @@ void GameRenderer::renderItemInHand(float a, int eye) { // 4J-JEV: I'm fairly confident this method would crash if the cameratarget // isnt a local player anyway, but oh well. std::shared_ptr localplayer = - mc->cameraTargetPlayer->instanceof(eTYPE_LOCALPLAYER) + mc->cameraTargetPlayer->instanceof + (eTYPE_LOCALPLAYER) ? std::dynamic_pointer_cast(mc->cameraTargetPlayer) : nullptr; @@ -1215,9 +1220,7 @@ void GameRenderer::renderLevel(float a, int64_t until) { // if (mc->cameraTargetPlayer == NULL) // 4J - removed condition as we // want to update this is mc->player changes for different local players - { - mc->cameraTargetPlayer = mc->player; - } + { mc->cameraTargetPlayer = mc->player; } pick(a); std::shared_ptr cameraEntity = mc->cameraTargetPlayer; @@ -1357,9 +1360,9 @@ void GameRenderer::renderLevel(float a, int64_t until) { turnOffLightLayer(a); // 4J - brought forward from 1.8.2 if ((mc->hitResult != NULL) && - cameraEntity->isUnderLiquid(Material::water) && - cameraEntity->instanceof( - eTYPE_PLAYER)) //&& !mc->options.hideGui) + cameraEntity->isUnderLiquid(Material::water) && + cameraEntity->instanceof + (eTYPE_PLAYER)) //&& !mc->options.hideGui) { std::shared_ptr player = std::dynamic_pointer_cast(cameraEntity); @@ -1435,8 +1438,8 @@ void GameRenderer::renderLevel(float a, int64_t until) { glEnable(GL_CULL_FACE); glDisable(GL_BLEND); - if ((zoom == 1) && - cameraEntity->instanceof(eTYPE_PLAYER)) //&& !mc->options.hideGui) + if ((zoom == 1) && cameraEntity->instanceof + (eTYPE_PLAYER)) //&& !mc->options.hideGui) { if (mc->hitResult != NULL && !cameraEntity->isUnderLiquid(Material::water)) { @@ -1975,7 +1978,7 @@ void GameRenderer::setupFog(int i, float alpha) { // 4J - check for creative mode brought forward from 1.2.3 bool creative = false; - if (player->instanceof(eTYPE_PLAYER)) { + if (player->instanceof (eTYPE_PLAYER)) { creative = (std::dynamic_pointer_cast(player))->abilities.instabuild; } diff --git a/Minecraft.Client/Rendering/LevelRenderer.cpp b/Minecraft.Client/Rendering/LevelRenderer.cpp index f9773b79e..26dfc10e0 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.cpp +++ b/Minecraft.Client/Rendering/LevelRenderer.cpp @@ -430,7 +430,7 @@ void LevelRenderer::allChanged(int playerIndex) { // called then (on 360 at least) we can get a deadlock when starting a game // in splitscreen. // EnterCriticalSection(&m_csDirtyChunks); - if (level == NULL) { + if (level[playerIndex] == NULL) { return; } @@ -506,7 +506,7 @@ void LevelRenderer::allChanged(int playerIndex) { } nonStackDirtyChunksAdded(); - if (level != NULL) { + if (level[playerIndex] != NULL) { std::shared_ptr player = mc->cameraTargetPlayer; if (player != NULL) { this->resortChunks(Mth::floor(player->x), Mth::floor(player->y), @@ -584,7 +584,7 @@ void LevelRenderer::renderEntities(Vec3* cam, Culler* culler, float a) { (entity->noCulling || culler->isVisible(entity->bb))); // Render the mob if the mob's leash holder is within the culler - if (!shouldRender && entity->instanceof(eTYPE_MOB)) { + if (!shouldRender && entity->instanceof (eTYPE_MOB)) { std::shared_ptr mob = std::dynamic_pointer_cast(entity); if (mob->isLeashed() && (mob->getLeashHolder() != NULL)) { std::shared_ptr leashHolder = mob->getLeashHolder(); @@ -598,10 +598,10 @@ void LevelRenderer::renderEntities(Vec3* cam, Culler* culler, float a) { // !mc->options->thirdPersonView && // !mc->cameraTargetPlayer->isSleeping()) continue; std::shared_ptr localplayer = - mc->cameraTargetPlayer->instanceof(eTYPE_LOCALPLAYER) - ? std::dynamic_pointer_cast( - mc->cameraTargetPlayer) - : nullptr; + mc->cameraTargetPlayer->instanceof + (eTYPE_LOCALPLAYER) ? std::dynamic_pointer_cast( + mc->cameraTargetPlayer) + : nullptr; if (localplayer && entity == mc->cameraTargetPlayer && !localplayer->ThirdPersonView() && @@ -766,8 +766,8 @@ int LevelRenderer::render(std::shared_ptr player, int layer, resortChunks(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z)); // sort(sortedChunks[playerIndex]->begin(),sortedChunks[playerIndex]->end(), - //DistanceChunkSorter(player)); // 4J - removed - not sorting our chunks - //anymore + // DistanceChunkSorter(player)); // 4J - removed - not sorting + // our chunks anymore } Lighting::turnOff(); glColor4f(1, 1, 1, 1); @@ -2746,9 +2746,7 @@ void LevelRenderer::cull_SPU(int playerIndex, Culler* culler, float a) { m_jobPort_CullSPU->submitSync(); // static int doSort = false; // if(doSort) - { - m_jobPort_CullSPU->submitJob(&sortJob); - } + { m_jobPort_CullSPU->submitJob(&sortJob); } // doSort ^= 1; m_bSPUCullStarted[playerIndex] = true; } @@ -3221,7 +3219,7 @@ std::shared_ptr LevelRenderer::addParticleInternal( } void LevelRenderer::entityAdded(std::shared_ptr entity) { - if (entity->instanceof(eTYPE_PLAYER)) { + if (entity->instanceof (eTYPE_PLAYER)) { std::shared_ptr player = std::dynamic_pointer_cast(entity); player->prepareCustomTextures(); @@ -3239,7 +3237,7 @@ void LevelRenderer::entityAdded(std::shared_ptr entity) { } void LevelRenderer::entityRemoved(std::shared_ptr entity) { - if (entity->instanceof(eTYPE_PLAYER)) { + if (entity->instanceof (eTYPE_PLAYER)) { std::shared_ptr player = std::dynamic_pointer_cast(entity); if (player->customTextureUrl != L"") { diff --git a/Minecraft.Client/Rendering/Models/HumanoidModel.cpp b/Minecraft.Client/Rendering/Models/HumanoidModel.cpp index 39dbb0610..926fe5195 100644 --- a/Minecraft.Client/Rendering/Models/HumanoidModel.cpp +++ b/Minecraft.Client/Rendering/Models/HumanoidModel.cpp @@ -10,6 +10,8 @@ ModelPart* HumanoidModel::AddOrRetrievePart(SKIN_BOX* pBox) { ModelPart* pAttachTo = NULL; switch (pBox->ePart) { + case eBodyPart_Unknown: + return nullptr; case eBodyPart_Head: pAttachTo = head; break; @@ -243,7 +245,7 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, leg1->yRot = 0.0f; if (riding) { - if (uiBitmaskOverrideAnim & (1 << eAnim_SmallModel) == 0) { + if ((uiBitmaskOverrideAnim & (1 << eAnim_SmallModel)) == 0) { arm0->xRot += -HALF_PI * 0.4f; arm1->xRot += -HALF_PI * 0.4f; leg0->xRot = -HALF_PI * 0.8f; diff --git a/Minecraft.Client/Rendering/Models/LeashKnotModel.cpp b/Minecraft.Client/Rendering/Models/LeashKnotModel.cpp index e94fc1695..2d45af79b 100644 --- a/Minecraft.Client/Rendering/Models/LeashKnotModel.cpp +++ b/Minecraft.Client/Rendering/Models/LeashKnotModel.cpp @@ -1,4 +1,4 @@ -#include "../../Platform/stdafx.h"; +#include "../../Platform/stdafx.h" #include "LeashKnotModel.h" #include "ModelPart.h" @@ -32,4 +32,4 @@ void LeashKnotModel::setupAnim(float time, float r, float bob, float yRot, knot->yRot = yRot / (180 / PI); knot->xRot = xRot / (180 / PI); -} \ No newline at end of file +} diff --git a/Minecraft.Client/Textures/Textures.cpp b/Minecraft.Client/Textures/Textures.cpp index d058b198c..d80099cca 100644 --- a/Minecraft.Client/Textures/Textures.cpp +++ b/Minecraft.Client/Textures/Textures.cpp @@ -541,11 +541,11 @@ ResourceLocation* Textures::getTextureLocation(int iconType) { switch (iconType) { case Icon::TYPE_TERRAIN: return &TextureAtlas::LOCATION_BLOCKS; - break; case Icon::TYPE_ITEM: return &TextureAtlas::LOCATION_ITEMS; - break; } + + return &TextureAtlas::LOCATION_ITEMS; } void Textures::clearLastBoundId() { lastBoundId = -1; } @@ -1425,16 +1425,16 @@ TEXTURE_NAME TUImages[] = { }; // This is for any TU textures that aren't part of our enum indexed preload set -wchar_t* TUImagePaths[] = {L"font/Default", L"font/Mojangles_7", - L"font/Mojangles_11", +const wchar_t* const TUImagePaths[] = { + L"font/Default", L"font/Mojangles_7", L"font/Mojangles_11", - // TU12 - L"armor/cloth_1.png", L"armor/cloth_1_b.png", - L"armor/cloth_2.png", L"armor/cloth_2_b.png", + // TU12 + L"armor/cloth_1.png", L"armor/cloth_1_b.png", L"armor/cloth_2.png", + L"armor/cloth_2_b.png", - // + // - NULL}; + nullptr}; bool Textures::IsTUImage(TEXTURE_NAME texId, const std::wstring& name) { int i = 0; @@ -1464,9 +1464,9 @@ TEXTURE_NAME OriginalImages[] = {TN_MOB_CHAR, TN_MOB_CHAR1, TN_MOB_CHAR2, TN_COUNT}; -wchar_t* OriginalImagesPaths[] = {L"misc/watercolor.png", +const wchar_t* const OriginalImagesPaths[] = {L"misc/watercolor.png", - NULL}; + nullptr}; bool Textures::IsOriginalImage(TEXTURE_NAME texId, const std::wstring& name) { int i = 0; diff --git a/Minecraft.World/AI/Goals/MeleeAttackGoal.cpp b/Minecraft.World/AI/Goals/MeleeAttackGoal.cpp index 306cf4c89..b3f059d8e 100644 --- a/Minecraft.World/AI/Goals/MeleeAttackGoal.cpp +++ b/Minecraft.World/AI/Goals/MeleeAttackGoal.cpp @@ -3,6 +3,7 @@ #include "../../Headers/net.minecraft.world.entity.monster.h" #include "../../Headers/net.minecraft.world.level.h" #include "../../Headers/net.minecraft.world.entity.ai.control.h" +#include "../Navigation/Path.h" #include "../../Headers/net.minecraft.world.entity.ai.navigation.h" #include "../../Headers/net.minecraft.world.entity.ai.sensing.h" #include "../../Headers/net.minecraft.world.phys.h" @@ -19,7 +20,7 @@ void MeleeAttackGoal::_init(PathfinderMob* mob, double speedModifier, Control::LookControlFlag); attackTime = 0; - path = NULL; + path = nullptr; timeToRecalcPath = 0; } @@ -34,18 +35,16 @@ MeleeAttackGoal::MeleeAttackGoal(PathfinderMob* mob, double speedModifier, _init(mob, speedModifier, trackTarget); } -MeleeAttackGoal::~MeleeAttackGoal() { - if (path != NULL) delete path; -} +MeleeAttackGoal::~MeleeAttackGoal() = default; bool MeleeAttackGoal::canUse() { std::shared_ptr target = mob->getTarget(); if (target == NULL) return false; if (!target->isAlive()) return false; - if (attackType != NULL && !target->instanceof(attackType)) return false; - delete path; - path = mob->getNavigation()->createPath(target); - return path != NULL; + if (attackType != eTYPE_NOTSET && !target->instanceof (attackType)) + return false; + path.reset(mob->getNavigation()->createPath(target)); + return path != nullptr; } bool MeleeAttackGoal::canContinueToUse() { @@ -60,8 +59,7 @@ bool MeleeAttackGoal::canContinueToUse() { } void MeleeAttackGoal::start() { - mob->getNavigation()->moveTo(path, speedModifier); - path = NULL; + mob->getNavigation()->moveTo(path.release(), speedModifier); timeToRecalcPath = 0; } diff --git a/Minecraft.World/AI/Goals/MeleeAttackGoal.h b/Minecraft.World/AI/Goals/MeleeAttackGoal.h index 8a5a4a0c6..7f481e00c 100644 --- a/Minecraft.World/AI/Goals/MeleeAttackGoal.h +++ b/Minecraft.World/AI/Goals/MeleeAttackGoal.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "Goal.h" class Level; @@ -13,7 +15,7 @@ private: int attackTime; double speedModifier; bool trackTarget; - Path* path; + std::unique_ptr path; eINSTANCEOF attackType; int timeToRecalcPath; @@ -34,4 +36,4 @@ public: // 4J Added override to update ai elements when loading entity from // schematics virtual void setLevel(Level* level) { this->level = level; } -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Blocks/PistonMovingTileEntity.cpp b/Minecraft.World/Blocks/PistonMovingTileEntity.cpp index 33364559c..bc21314b8 100644 --- a/Minecraft.World/Blocks/PistonMovingTileEntity.cpp +++ b/Minecraft.World/Blocks/PistonMovingTileEntity.cpp @@ -78,8 +78,10 @@ void PistonMovingPiece::spawnResources(Level* level, int x, int y, int z, void PistonMovingPiece::neighborChanged(Level* level, int x, int y, int z, int type) { - if (!level->isClientSide) { - level->getTileEntity(x, y, z) == NULL; + if (!level->isClientSide && level->getTileEntity(x, y, z) == nullptr) { + // 4jcraft: remove orphaned moving piston blocks once their tile entity + // has already vanished, matching the cleanup path used on interaction. + level->removeTile(x, y, z); } } diff --git a/Minecraft.World/Core/DispenseItemBehavior.h b/Minecraft.World/Core/DispenseItemBehavior.h index 0f33e3e65..af3904631 100644 --- a/Minecraft.World/Core/DispenseItemBehavior.h +++ b/Minecraft.World/Core/DispenseItemBehavior.h @@ -12,6 +12,8 @@ public: */ static DispenseItemBehavior* NOOP; + virtual ~DispenseItemBehavior() = default; + /** * * @param source The source of this call (the dispenser that calls it) @@ -26,4 +28,4 @@ class NoOpDispenseItemBehavior : public DispenseItemBehavior { public: std::shared_ptr dispense( BlockSource* source, std::shared_ptr dispensed); -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Core/Position.h b/Minecraft.World/Core/Position.h index d38e99487..e60d35ec3 100644 --- a/Minecraft.World/Core/Position.h +++ b/Minecraft.World/Core/Position.h @@ -2,7 +2,8 @@ class Position { public: + virtual ~Position() = default; virtual double getX() = 0; virtual double getY() = 0; virtual double getZ() = 0; -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Entities/EntitySelector.h b/Minecraft.World/Entities/EntitySelector.h index fa952ab5b..350f73d75 100644 --- a/Minecraft.World/Entities/EntitySelector.h +++ b/Minecraft.World/Entities/EntitySelector.h @@ -5,6 +5,7 @@ public: static const EntitySelector* ENTITY_STILL_ALIVE; static const EntitySelector* CONTAINER_ENTITY_SELECTOR; + virtual ~EntitySelector() = default; virtual bool matches(std::shared_ptr entity) const = 0; }; @@ -25,4 +26,4 @@ private: public: MobCanWearArmourEntitySelector(std::shared_ptr item); bool matches(std::shared_ptr entity) const; -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Entities/Mobs/Animal.cpp b/Minecraft.World/Entities/Mobs/Animal.cpp index 7c72ea23b..b404a0102 100644 --- a/Minecraft.World/Entities/Mobs/Animal.cpp +++ b/Minecraft.World/Entities/Mobs/Animal.cpp @@ -61,7 +61,7 @@ void Animal::aiStep() { void Animal::checkHurtTarget(std::shared_ptr target, float d) { // 4J-JEV: Changed from dynamic cast to use eINSTANCEOF - if (target->instanceof(eTYPE_PLAYER)) { + if (target->instanceof (eTYPE_PLAYER)) { if (d < 3) { double xd = target->x - x; double zd = target->z - z; @@ -77,7 +77,7 @@ void Animal::checkHurtTarget(std::shared_ptr target, float d) { } // 4J-JEV: Changed from dynamic cast to use eINSTANCEOF - else if (target->instanceof(eTYPE_ANIMAL)) { + else if (target->instanceof (eTYPE_ANIMAL)) { std::shared_ptr a = std::dynamic_pointer_cast(target); if (getAge() > 0 && a->getAge() < 0) { if (d < 2.5) { @@ -162,22 +162,22 @@ bool Animal::hurt(DamageSource* dmgSource, float dmg) { std::shared_ptr source = dmgSource->getDirectEntity(); // 4J-JEV: Changed from dynamic cast to use eINSTANCEOF - if (source->instanceof(eTYPE_PLAYER) && - !std::dynamic_pointer_cast(source) - ->isAllowedToAttackAnimals()) { + if (source->instanceof + (eTYPE_PLAYER) && !std::dynamic_pointer_cast(source) + ->isAllowedToAttackAnimals()) { return false; } - if ((source != NULL) && source->instanceof(eTYPE_ARROW)) { + if ((source != NULL) && source->instanceof (eTYPE_ARROW)) { std::shared_ptr arrow = std::dynamic_pointer_cast(source); // 4J: Check that the arrow's owner can attack animals (dispenser // arrows are not owned) - if (arrow->owner != NULL && - arrow->owner->instanceof(eTYPE_PLAYER) && - !std::dynamic_pointer_cast(arrow->owner) - ->isAllowedToAttackAnimals()) { + if (arrow->owner != NULL && arrow->owner->instanceof + (eTYPE_PLAYER) && + !std::dynamic_pointer_cast(arrow->owner) + ->isAllowedToAttackAnimals()) { return false; } } @@ -332,7 +332,7 @@ bool Animal::mobInteract(std::shared_ptr player) { return false; } - } else if (instanceof(eTYPE_MONSTER)) { + } else if (instanceof (eTYPE_MONSTER)) { } break; } @@ -371,8 +371,10 @@ bool Animal::isInLove() { return entityData->getInteger(DATA_IN_LOVE) > 0; } void Animal::resetLove() { entityData->set(DATA_IN_LOVE, 0); } bool Animal::canMate(std::shared_ptr partner) { + if (partner == nullptr) return false; if (partner == shared_from_this()) return false; - if (typeid(*partner) != typeid(*this)) return false; + Animal* partnerAnimal = partner.get(); + if (typeid(*partnerAnimal) != typeid(*this)) return false; return isInLove() && partner->isInLove(); } @@ -436,4 +438,4 @@ void Animal::setDespawnProtected() { m_maxWanderZ = zt; m_isDespawnProtected = true; -} \ No newline at end of file +} diff --git a/Minecraft.World/Entities/Mobs/Minecart.cpp b/Minecraft.World/Entities/Mobs/Minecart.cpp index f6d401704..4351c4ad8 100644 --- a/Minecraft.World/Entities/Mobs/Minecart.cpp +++ b/Minecraft.World/Entities/Mobs/Minecart.cpp @@ -56,7 +56,7 @@ Minecart::Minecart(Level* level) : Entity(level) { // soundUpdater = level != NULL ? level->makeSoundUpdater(this) : NULL; } -Minecart::~Minecart() { delete soundUpdater; } +Minecart::~Minecart() {} std::shared_ptr Minecart::createMinecart(Level* level, double x, double y, double z, @@ -129,9 +129,10 @@ bool Minecart::hurt(DamageSource* source, float hurtDamage) { if (dynamic_cast(source) != NULL) { std::shared_ptr attacker = source->getDirectEntity(); - if (attacker->instanceof(eTYPE_PLAYER) && - !std::dynamic_pointer_cast(attacker)->isAllowedToHurtEntity( - shared_from_this())) { + if (attacker->instanceof + (eTYPE_PLAYER) && + !std::dynamic_pointer_cast(attacker) + ->isAllowedToHurtEntity(shared_from_this())) { return false; } } @@ -148,9 +149,9 @@ bool Minecart::hurt(DamageSource* source, float hurtDamage) { if (rider.lock() != NULL && rider.lock() == source->getEntity()) hurtDamage += 1; - bool creativePlayer = source->getEntity() != NULL && - source->getEntity()->instanceof(eTYPE_PLAYER) && - std::dynamic_pointer_cast(source->getEntity()) + bool creativePlayer = + source->getEntity() != NULL && source->getEntity()->instanceof + (eTYPE_PLAYER) && std::dynamic_pointer_cast(source->getEntity()) ->abilities.instabuild; if (creativePlayer || getDamage() > 20 * 2) { @@ -309,8 +310,8 @@ void Minecart::tick() { AUTO_VAR(itEnd, entities->end()); for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) { std::shared_ptr e = (*it); // entities->at(i); - if (e != rider.lock() && e->isPushable() && - e->instanceof(eTYPE_MINECART)) { + if (e != rider.lock() && e->isPushable() && e->instanceof + (eTYPE_MINECART)) { std::shared_ptr cart = std::dynamic_pointer_cast(e); cart->m_bHasPushedCartThisTick = false; @@ -404,7 +405,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, xd = pow * xD / dd; zd = pow * zD / dd; - if (rider.lock() != NULL && rider.lock()->instanceof(eTYPE_LIVINGENTITY)) { + if (rider.lock() != NULL && rider.lock()->instanceof (eTYPE_LIVINGENTITY)) { std::shared_ptr living = std::dynamic_pointer_cast(rider.lock()); @@ -688,9 +689,10 @@ void Minecart::push(std::shared_ptr e) { if (level->isClientSide) return; if (e == rider.lock()) return; - if (e->instanceof(eTYPE_LIVINGENTITY) && !e->instanceof(eTYPE_PLAYER) && - !e->instanceof(eTYPE_VILLAGERGOLEM) && (getType() == TYPE_RIDEABLE) && - (xd * xd + zd * zd > 0.01)) { + if (e->instanceof (eTYPE_LIVINGENTITY) && !e->instanceof + (eTYPE_PLAYER) && !e->instanceof + (eTYPE_VILLAGERGOLEM) && (getType() == TYPE_RIDEABLE) && + (xd * xd + zd * zd > 0.01)) { if ((rider.lock() == NULL) && (e->riding == NULL)) { e->ride(shared_from_this()); } @@ -716,7 +718,7 @@ void Minecart::push(std::shared_ptr e) { xa *= 0.5; za *= 0.5; - if (e->instanceof(eTYPE_MINECART)) { + if (e->instanceof (eTYPE_MINECART)) { double xo = e->x - x; double zo = e->z - z; @@ -891,4 +893,4 @@ std::wstring Minecart::getAName() { bool Minecart::hasCustomName() { return !name.empty(); } -std::wstring Minecart::getCustomName() { return name; } \ No newline at end of file +std::wstring Minecart::getCustomName() { return name; } diff --git a/Minecraft.World/Entities/Mobs/Villager.cpp b/Minecraft.World/Entities/Mobs/Villager.cpp index 71144d3f0..0c790add7 100644 --- a/Minecraft.World/Entities/Mobs/Villager.cpp +++ b/Minecraft.World/Entities/Mobs/Villager.cpp @@ -17,6 +17,23 @@ #include "../../../Minecraft.Client/Textures/Textures.h" #include "Villager.h" +namespace { +struct VillagerShuffleRandom { + using result_type = unsigned int; + + explicit VillagerShuffleRandom(Random* random) : random(random) {} + + static constexpr result_type min() { return 0; } + static constexpr result_type max() { return 0xFFFFFFFFu; } + + result_type operator()() { + return static_cast(random->nextInt()); + } + + Random* random; +}; +} // namespace + std::unordered_map > Villager::MIN_MAX_VALUES; std::unordered_map > Villager::MIN_MAX_PRICES; @@ -217,7 +234,7 @@ void Villager::setLastHurtByMob(std::shared_ptr mob) { if (_village != NULL && mob != NULL) { _village->addAggressor(mob); - if (mob->instanceof(eTYPE_PLAYER)) { + if (mob->instanceof (eTYPE_PLAYER)) { int amount = -1; if (isBaby()) { amount = -3; @@ -237,11 +254,11 @@ void Villager::die(DamageSource* source) { if (_village != NULL) { std::shared_ptr sourceEntity = source->getEntity(); if (sourceEntity != NULL) { - if (sourceEntity->instanceof(eTYPE_PLAYER)) { + if (sourceEntity->instanceof (eTYPE_PLAYER)) { _village->modifyStanding( std::dynamic_pointer_cast(sourceEntity)->getName(), -2); - } else if (sourceEntity->instanceof(eTYPE_ENEMY)) { + } else if (sourceEntity->instanceof (eTYPE_ENEMY)) { _village->resetNoBreedTimer(); } } else if (sourceEntity == NULL) { @@ -508,7 +525,8 @@ void Villager::addOffers(int addCount) { } // shuffle the list to make it more interesting - std::random_shuffle(newOffers->begin(), newOffers->end()); + std::shuffle(newOffers->begin(), newOffers->end(), + VillagerShuffleRandom(random)); if (offers == NULL) { offers = new MerchantRecipeList(); diff --git a/Minecraft.World/Level/BaseMobSpawner.h b/Minecraft.World/Level/BaseMobSpawner.h index 334e8a078..0933908b1 100644 --- a/Minecraft.World/Level/BaseMobSpawner.h +++ b/Minecraft.World/Level/BaseMobSpawner.h @@ -41,7 +41,7 @@ private: public: BaseMobSpawner(); - ~BaseMobSpawner(); + virtual ~BaseMobSpawner(); virtual std::wstring getEntityId(); virtual void setEntityId(const std::wstring& entityId); @@ -66,4 +66,4 @@ public: virtual int getX() = 0; virtual int getY() = 0; virtual int getZ() = 0; -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Level/CustomLevelSource.cpp b/Minecraft.World/Level/CustomLevelSource.cpp index a2b774fe9..de97afca9 100644 --- a/Minecraft.World/Level/CustomLevelSource.cpp +++ b/Minecraft.World/Level/CustomLevelSource.cpp @@ -121,8 +121,6 @@ CustomLevelSource::~CustomLevelSource() { delete mineShaftFeature; delete canyonFeature; - this->level = level; - delete random; delete perlinNoise3; #endif @@ -658,10 +656,10 @@ void CustomLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ) { if (generateStructures) { #ifdef _OVERRIDE_HEIGHTMAP - mineShaftFeature->apply(this, level, chunkX, chunkZ, NULL); - villageFeature->apply(this, level, chunkX, chunkZ, NULL); - strongholdFeature->apply(this, level, chunkX, chunkZ, NULL); - scatteredFeature->apply(this, level, chunkX, chunkZ, NULL); + mineShaftFeature->apply(this, level, chunkX, chunkZ, byteArray()); + villageFeature->apply(this, level, chunkX, chunkZ, byteArray()); + strongholdFeature->apply(this, level, chunkX, chunkZ, byteArray()); + scatteredFeature->apply(this, level, chunkX, chunkZ, byteArray()); #endif } -} \ No newline at end of file +} diff --git a/Minecraft.World/Level/LevelChunk.cpp b/Minecraft.World/Level/LevelChunk.cpp index 567a91f17..6257ca132 100644 --- a/Minecraft.World/Level/LevelChunk.cpp +++ b/Minecraft.World/Level/LevelChunk.cpp @@ -499,8 +499,8 @@ void LevelChunk::recalcHeightmapOnly() { // value changed from -999 to 255 int y = Level::maxBuildHeight - 1; - // int p = x << level->depthBitsPlusFour | z << - // level->depthBits; // 4J - removed + // int p = x << level->depthBitsPlusFour | z << + // level->depthBits; // 4J - removed #ifdef __PSVITA__ int Index = ((unsigned)x << 11) + ((unsigned)z << 7); int offset = Level::COMPRESSED_CHUNK_SECTION_TILES; @@ -567,8 +567,8 @@ void LevelChunk::recalcHeightmap() { for (int x = 0; x < 16; x++) for (int z = 0; z < 16; z++) { int y = Level::maxBuildHeight - 1; - // int p = x << level->depthBitsPlusFour | z << - // level->depthBits; // 4J - removed + // int p = x << level->depthBitsPlusFour | z << + // level->depthBits; // 4J - removed #ifdef __PSVITA__ int Index = ((unsigned)x << 11) + ((unsigned)z << 7); @@ -1747,22 +1747,23 @@ void LevelChunk::getEntitiesOfClass(const std::type_info& ec, AABB* bb, // our class may be derived from, otherwise do a direct comparison // of type_info if (ec == typeid(Player)) - isAssignableFrom = e->instanceof(eTYPE_PLAYER); + isAssignableFrom = e->instanceof (eTYPE_PLAYER); else if (ec == typeid(Entity)) - isAssignableFrom = e->instanceof(eTYPE_ENTITY); + isAssignableFrom = e->instanceof (eTYPE_ENTITY); else if (ec == typeid(Mob)) - isAssignableFrom = e->instanceof(eTYPE_MOB); + isAssignableFrom = e->instanceof (eTYPE_MOB); else if (ec == typeid(LivingEntity)) - isAssignableFrom = e->instanceof(eTYPE_LIVINGENTITY); + isAssignableFrom = e->instanceof (eTYPE_LIVINGENTITY); else if (ec == typeid(ItemEntity)) - isAssignableFrom = e->instanceof(eTYPE_ITEMENTITY); + isAssignableFrom = e->instanceof (eTYPE_ITEMENTITY); else if (ec == typeid(Minecart)) - isAssignableFrom = e->instanceof(eTYPE_MINECART); + isAssignableFrom = e->instanceof (eTYPE_MINECART); else if (ec == typeid(Monster)) - isAssignableFrom = e->instanceof(eTYPE_MONSTER); + isAssignableFrom = e->instanceof (eTYPE_MONSTER); else if (ec == typeid(Zombie)) - isAssignableFrom = e->instanceof(eTYPE_ZOMBIE); - else if (e != NULL && ec == typeid(*(e.get()))) + isAssignableFrom = e->instanceof (eTYPE_ZOMBIE); + else if (Entity* entity = e.get(); + entity != NULL && ec == typeid(*entity)) isAssignableFrom = true; if (isAssignableFrom && e->bb->intersects(bb)) { if (selector == NULL || selector->matches(e)) { diff --git a/Minecraft.World/Level/RandomLevelSource.cpp b/Minecraft.World/Level/RandomLevelSource.cpp index 500318bc3..62c72926a 100644 --- a/Minecraft.World/Level/RandomLevelSource.cpp +++ b/Minecraft.World/Level/RandomLevelSource.cpp @@ -73,8 +73,6 @@ RandomLevelSource::~RandomLevelSource() { delete scatteredFeature; delete canyonFeature; - this->level = level; - delete random; ; delete lperlinNoise1; @@ -906,9 +904,9 @@ TilePos* RandomLevelSource::findNearestMapFeature( void RandomLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ) { if (generateStructures) { - mineShaftFeature->apply(this, level, chunkX, chunkZ, NULL); - villageFeature->apply(this, level, chunkX, chunkZ, NULL); - strongholdFeature->apply(this, level, chunkX, chunkZ, NULL); - scatteredFeature->apply(this, level, chunkX, chunkZ, NULL); + mineShaftFeature->apply(this, level, chunkX, chunkZ, byteArray()); + villageFeature->apply(this, level, chunkX, chunkZ, byteArray()); + strongholdFeature->apply(this, level, chunkX, chunkZ, byteArray()); + scatteredFeature->apply(this, level, chunkX, chunkZ, byteArray()); } -} \ No newline at end of file +} diff --git a/Minecraft.World/Network/Connection.cpp b/Minecraft.World/Network/Connection.cpp index a4de80ee4..942634ed9 100644 --- a/Minecraft.World/Network/Connection.cpp +++ b/Minecraft.World/Network/Connection.cpp @@ -27,6 +27,7 @@ void Connection::_init() { quitting = false; disconnected = false; disconnectReason = DisconnectPacket::eDisconnect_None; + disconnectReasonObjects = NULL; noInputTicks = 0; estimatedRemaining = 0; fakeLag = 0; @@ -375,29 +376,14 @@ e.printStackTrace(); close("disconnect.genericReason", "Internal exception: " + e.toString()); }*/ -void Connection::close(DisconnectPacket::eDisconnectReason reason, ...) { +void Connection::close(DisconnectPacket::eDisconnectReason reason) { // printf("Con:0x%x close\n",this); if (!running) return; // printf("Con:0x%x close doing something\n",this); disconnected = true; - va_list input; - va_start(input, reason); - disconnectReason = reason; // va_arg( input, const wstring ); - - std::vector objs = std::vector(); - void* i = NULL; - while (i != NULL) { - i = va_arg(input, void*); - objs.push_back(i); - } - - if (objs.size()) { - disconnectReasonObjects = &objs[0]; - } else { - disconnectReasonObjects = NULL; - } + disconnectReasonObjects = NULL; // int count = 0, sum = 0, i = first; // va_list marker; diff --git a/Minecraft.World/Network/Connection.h b/Minecraft.World/Network/Connection.h index 4c6bf7311..8930cfb69 100644 --- a/Minecraft.World/Network/Connection.h +++ b/Minecraft.World/Network/Connection.h @@ -128,7 +128,7 @@ private: }*/ public: - void close(DisconnectPacket::eDisconnectReason reason, ...); + void close(DisconnectPacket::eDisconnectReason reason); void tick(); diff --git a/Minecraft.World/Util/CombatTracker.cpp b/Minecraft.World/Util/CombatTracker.cpp index b3cf2bff6..0dbc0a2d3 100644 --- a/Minecraft.World/Util/CombatTracker.cpp +++ b/Minecraft.World/Util/CombatTracker.cpp @@ -65,7 +65,8 @@ std::shared_ptr CombatTracker::getDeathMessagePacket() { if (knockOffEntry->getSource()->equals(DamageSource::fall) || knockOffEntry->getSource()->equals(DamageSource::outOfWorld)) { - ChatPacket::EChatPacketMessage message; + ChatPacket::EChatPacketMessage message = + ChatPacket::e_ChatDeathFellAccidentGeneric; switch (getFallLocation(knockOffEntry)) { case eLocation_GENERIC: @@ -80,6 +81,8 @@ std::shared_ptr CombatTracker::getDeathMessagePacket() { case eLocation_WATER: message = ChatPacket::e_ChatDeathFellAccidentWater; break; + case eLocation_COUNT: + break; } result = std::shared_ptr( @@ -87,7 +90,8 @@ std::shared_ptr CombatTracker::getDeathMessagePacket() { } else if (attackerEntity != NULL && (killingEntity == NULL || attackerEntity != killingEntity)) { std::shared_ptr attackerItem = - attackerEntity->instanceof(eTYPE_LIVINGENTITY) + attackerEntity->instanceof + (eTYPE_LIVINGENTITY) ? std::dynamic_pointer_cast(attackerEntity) ->getCarriedItem() : nullptr; @@ -105,8 +109,8 @@ std::shared_ptr CombatTracker::getDeathMessagePacket() { attackerEntity->getNetworkName())); } } else if (killingEntity != NULL) { - std::shared_ptr killerItem = - killingEntity->instanceof(eTYPE_LIVINGENTITY) + std::shared_ptr killerItem = killingEntity->instanceof + (eTYPE_LIVINGENTITY) ? std::dynamic_pointer_cast(killingEntity) ->getCarriedItem() : nullptr; @@ -142,18 +146,20 @@ std::shared_ptr CombatTracker::getKiller() { for (AUTO_VAR(it, entries.begin()); it != entries.end(); ++it) { CombatEntry* entry = *it; if (entry->getSource() != NULL && - entry->getSource()->getEntity() != NULL && - entry->getSource()->getEntity()->instanceof(eTYPE_PLAYER) && - (bestPlayer == NULL || entry->getDamage() > bestPlayerDamage)) { + entry->getSource()->getEntity() != NULL && + entry->getSource()->getEntity()->instanceof + (eTYPE_PLAYER) && + (bestPlayer == NULL || entry->getDamage() > bestPlayerDamage)) { bestPlayerDamage = entry->getDamage(); bestPlayer = std::dynamic_pointer_cast( entry->getSource()->getEntity()); } if (entry->getSource() != NULL && - entry->getSource()->getEntity() != NULL && - entry->getSource()->getEntity()->instanceof(eTYPE_LIVINGENTITY) && - (bestMob == NULL || entry->getDamage() > bestMobDamage)) { + entry->getSource()->getEntity() != NULL && + entry->getSource()->getEntity()->instanceof + (eTYPE_LIVINGENTITY) && + (bestMob == NULL || entry->getDamage() > bestMobDamage)) { bestMobDamage = entry->getDamage(); bestMob = std::dynamic_pointer_cast( entry->getSource()->getEntity()); @@ -233,4 +239,4 @@ void CombatTracker::recheckStatus() { takingDamage = false; inCombat = false; } -} \ No newline at end of file +} diff --git a/Minecraft.World/Util/StringHelpers.cpp b/Minecraft.World/Util/StringHelpers.cpp index c5998b565..73d3591de 100644 --- a/Minecraft.World/Util/StringHelpers.cpp +++ b/Minecraft.World/Util/StringHelpers.cpp @@ -55,8 +55,10 @@ std::wstring u16string_to_wstring(const std::u16string& converting) { std::wstring result( simdutf::utf32_length_from_utf16(converting.data(), converting.size()), L'\0'); - simdutf::convert_utf16_to_utf32(converting.data(), converting.size(), - reinterpret_cast(result.data())); + std::size_t convertedLength = simdutf::convert_utf16_to_utf32( + converting.data(), converting.size(), + reinterpret_cast(result.data())); + result.resize(convertedLength); return result; #endif @@ -77,7 +79,9 @@ std::u16string wstring_to_u16string(const std::wstring& converting) { std::u16string result(simdutf::utf16_length_from_utf32(data32, len32), u'\0'); - simdutf::convert_utf32_to_utf16(data32, len32, result.data()); + std::size_t convertedLength = + simdutf::convert_utf32_to_utf16(data32, len32, result.data()); + result.resize(convertedLength); return result; #endif diff --git a/Minecraft.World/WorldGen/Sources/HellRandomLevelSource.cpp b/Minecraft.World/WorldGen/Sources/HellRandomLevelSource.cpp index 9a84d8277..905804fef 100644 --- a/Minecraft.World/WorldGen/Sources/HellRandomLevelSource.cpp +++ b/Minecraft.World/WorldGen/Sources/HellRandomLevelSource.cpp @@ -561,5 +561,5 @@ TilePos* HellRandomLevelSource::findNearestMapFeature( void HellRandomLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ) { - netherBridgeFeature->apply(this, level, chunkX, chunkZ, NULL); -} \ No newline at end of file + netherBridgeFeature->apply(this, level, chunkX, chunkZ, byteArray()); +} diff --git a/Minecraft.World/WorldGen/Structures/StructureStart.h b/Minecraft.World/WorldGen/Structures/StructureStart.h index b1f1cfbbb..11e682228 100644 --- a/Minecraft.World/WorldGen/Structures/StructureStart.h +++ b/Minecraft.World/WorldGen/Structures/StructureStart.h @@ -17,7 +17,7 @@ private: public: StructureStart(); StructureStart(int x, int z); - ~StructureStart(); + virtual ~StructureStart(); BoundingBox* getBoundingBox(); std::list* getPieces(); void postProcess(Level* level, Random* random, BoundingBox* chunkBB);