From 0da697cbd46c1a6857fe3598a4eb2a272c4920b6 Mon Sep 17 00:00:00 2001 From: MatthewBeshay <92357869+MatthewBeshay@users.noreply.github.com> Date: Thu, 9 Apr 2026 09:55:13 +1000 Subject: [PATCH] fix: clear all build warnings and clean up review nits --- targets/app/common/DLC/DLCSkinFile.cpp | 5 +-- .../Leaderboards/LeaderboardInterface.cpp | 2 +- .../app/common/Network/GameNetworkManager.cpp | 4 +- .../All Platforms/IUIScene_CraftingMenu.cpp | 2 +- .../UIScene_LoadMenu.cpp | 2 +- .../UIScene_MainMenu.cpp | 8 ++-- .../Help & Options/UIScene_SkinSelectMenu.cpp | 2 + targets/app/common/UI/UIScene.cpp | 2 +- targets/minecraft/client/gui/DeathScreen.h | 2 +- targets/minecraft/client/gui/Font.cpp | 4 +- targets/minecraft/client/gui/MessageScreen.h | 2 +- .../gui/achievement/AchievementScreen.h | 2 +- .../client/multiplayer/ClientConnection.cpp | 4 +- .../client/multiplayer/ConnectScreen.h | 2 +- .../client/multiplayer/DisconnectedScreen.h | 2 +- .../multiplayer/MultiPlayerLocalPlayer.cpp | 3 +- .../client/multiplayer/ReceivingLevelScreen.h | 2 +- .../client/skins/AbstractTexturePack.cpp | 3 +- .../minecraft/client/skins/DLCTexturePack.cpp | 6 ++- .../server/network/PlayerConnection.cpp | 8 ++-- targets/minecraft/world/level/Level.cpp | 2 +- .../world/level/chunk/SparseDataStorage.cpp | 45 ++++++++----------- .../world/level/chunk/SparseLightStorage.cpp | 45 ++++++++----------- .../level/tile/entity/SignTileEntity.cpp | 6 +-- targets/nbt/include/nbt/ByteArrayTag.h | 2 +- targets/nbt/include/nbt/IntArrayTag.h | 2 +- targets/nbt/include/nbt/LongTag.h | 2 +- targets/platform/PlatformTypes.h | 6 +-- targets/platform/renderer/gl/GLRenderer.cpp | 3 +- targets/platform/renderer/gl/gl_compat.h | 6 ++- 30 files changed, 88 insertions(+), 98 deletions(-) diff --git a/targets/app/common/DLC/DLCSkinFile.cpp b/targets/app/common/DLC/DLCSkinFile.cpp index be8c44cac..e120d94a8 100644 --- a/targets/app/common/DLC/DLCSkinFile.cpp +++ b/targets/app/common/DLC/DLCSkinFile.cpp @@ -110,7 +110,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, SKIN_BOX* pSkinBox = new SKIN_BOX; memset(pSkinBox, 0, sizeof(SKIN_BOX)); - sscanf(value.c_str(), "%9ls%f%f%f%f%f%f%f%f", wchBodyPart, 10, + sscanf(value.c_str(), "%9s%f%f%f%f%f%f%f%f", wchBodyPart, &pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ, &pSkinBox->fW, &pSkinBox->fH, &pSkinBox->fD, &pSkinBox->fU, &pSkinBox->fV); @@ -132,8 +132,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, m_AdditionalBoxes.push_back(pSkinBox); } break; case DLCManager::e_DLCParamType_Anim: { - sscanf(value.c_str(), "%X", &m_uiAnimOverrideBitmask, - sizeof(unsigned int)); + sscanf(value.c_str(), "%X", &m_uiAnimOverrideBitmask); uint32_t skinId = app.getSkinIdFromPath(m_path); app.SetAnimOverrideBitmask(skinId, m_uiAnimOverrideBitmask); break; diff --git a/targets/app/common/Leaderboards/LeaderboardInterface.cpp b/targets/app/common/Leaderboards/LeaderboardInterface.cpp index 979d7937b..41cef18ae 100644 --- a/targets/app/common/Leaderboards/LeaderboardInterface.cpp +++ b/targets/app/common/Leaderboards/LeaderboardInterface.cpp @@ -15,7 +15,7 @@ LeaderboardInterface::LeaderboardInterface(IPlatformLeaderboard* man) { m_startIndex = 0; m_readCount = 0; - m_manager->OpenSession(); + (void)m_manager->OpenSession(); } LeaderboardInterface::~LeaderboardInterface() { diff --git a/targets/app/common/Network/GameNetworkManager.cpp b/targets/app/common/Network/GameNetworkManager.cpp index a26907f0c..9fe851b20 100644 --- a/targets/app/common/Network/GameNetworkManager.cpp +++ b/targets/app/common/Network/GameNetworkManager.cpp @@ -717,7 +717,7 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void* pParam, // If the player was signed in before selecting play, we'll not // have read the profile yet, so query the sign-in status to get // this to happen - PlatformProfile.QuerySigninStatus(); + (void)PlatformProfile.QuerySigninStatus(); // 4J-PB - clear any previous connection errors Minecraft::GetInstance()->clearConnectionFailed(); @@ -1377,7 +1377,7 @@ void CGameNetworkManager::HandleInviteWhenInMenus( // If the player was signed in before selecting play, we'll not // have read the profile yet, so query the sign-in status to get // this to happen - PlatformProfile.QuerySigninStatus(); + (void)PlatformProfile.QuerySigninStatus(); // 4J-PB - clear any previous connection errors Minecraft::GetInstance()->clearConnectionFailed(); diff --git a/targets/app/common/UI/All Platforms/IUIScene_CraftingMenu.cpp b/targets/app/common/UI/All Platforms/IUIScene_CraftingMenu.cpp index 1affdedf7..334afbb18 100644 --- a/targets/app/common/UI/All Platforms/IUIScene_CraftingMenu.cpp +++ b/targets/app/common/UI/All Platforms/IUIScene_CraftingMenu.cpp @@ -875,7 +875,7 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() { app.DebugPrintf("Need more H slots - "); #if !defined(_CONTENT_PACKAGE) fprintf( - stderr, + stderr, "%s", app.GetString(pTempItemInst->getDescriptionId())); #endif app.DebugPrintf("\n"); diff --git a/targets/app/common/UI/Scenes/Frontend Menu screens/UIScene_LoadMenu.cpp b/targets/app/common/UI/Scenes/Frontend Menu screens/UIScene_LoadMenu.cpp index b5fccce01..f42d33b5d 100644 --- a/targets/app/common/UI/Scenes/Frontend Menu screens/UIScene_LoadMenu.cpp +++ b/targets/app/common/UI/Scenes/Frontend Menu screens/UIScene_LoadMenu.cpp @@ -302,7 +302,7 @@ void UIScene_LoadMenu::tick() { if (szSeed[0] != 0) { char TempString[256]; - snprintf(TempString, 256, "%s: %hs", app.GetString(IDS_SEED), + snprintf(TempString, 256, "%s: %s", app.GetString(IDS_SEED), szSeed); m_labelSeed.setLabel(TempString); } else { diff --git a/targets/app/common/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp b/targets/app/common/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp index d7300605e..861dabcbf 100644 --- a/targets/app/common/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp +++ b/targets/app/common/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp @@ -787,7 +787,7 @@ void UIScene_MainMenu::RunPlayGame(int iPad) { // If the player was signed in before selecting play, we'll not have // read the profile yet, so query the sign-in status to get this to // happen - PlatformProfile.QuerySigninStatus(); + (void)PlatformProfile.QuerySigninStatus(); // 4J-PB - Need to check for installed DLC if (!app.DLCInstallProcessCompleted()) app.StartInstallDLCProcess(iPad); @@ -896,7 +896,7 @@ void UIScene_MainMenu::RunLeaderboards(int iPad) { // If the player was signed in before selecting play, we'll not have // read the profile yet, so query the sign-in status to get this to // happen - PlatformProfile.QuerySigninStatus(); + (void)PlatformProfile.QuerySigninStatus(); proceedToScene(iPad, eUIScene_LeaderboardsMenu); } @@ -916,7 +916,7 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) { // If the player was signed in before selecting play, we'll not // have read the profile yet, so query the sign-in status to get // this to happen - PlatformProfile.QuerySigninStatus(); + (void)PlatformProfile.QuerySigninStatus(); { bool bContentRestricted = false; @@ -1015,7 +1015,7 @@ void UIScene_MainMenu::RunHelpAndOptions(int iPad) { // If the player was signed in before selecting play, we'll not have // read the profile yet, so query the sign-in status to get this to // happen - PlatformProfile.QuerySigninStatus(); + (void)PlatformProfile.QuerySigninStatus(); #if TO_BE_IMPLEMENTED // 4J-PB - You can be offline and still can go into help and options diff --git a/targets/app/common/UI/Scenes/Help & Options/UIScene_SkinSelectMenu.cpp b/targets/app/common/UI/Scenes/Help & Options/UIScene_SkinSelectMenu.cpp index 2d8b03101..ffebcc195 100644 --- a/targets/app/common/UI/Scenes/Help & Options/UIScene_SkinSelectMenu.cpp +++ b/targets/app/common/UI/Scenes/Help & Options/UIScene_SkinSelectMenu.cpp @@ -885,6 +885,8 @@ TEXTURE_NAME UIScene_SkinSelectMenu::getTextureId(int skinIndex) { case EDefaultSkins::Skin7: texture = TN_MOB_CHAR7; break; + case EDefaultSkins::Count: + break; }; return texture; diff --git a/targets/app/common/UI/UIScene.cpp b/targets/app/common/UI/UIScene.cpp index 00677e4b8..11d23735d 100644 --- a/targets/app/common/UI/UIScene.cpp +++ b/targets/app/common/UI/UIScene.cpp @@ -586,7 +586,7 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region, } m_cachedSlotDraw.clear(); - if (useCommandBuffers) PlatformRenderer.CBuffCall(list); + if (useCommandBuffers) (void)PlatformRenderer.CBuffCall(list); // Finish GDraw and anything else that needs to be finalised ui.endCustomDraw(region); diff --git a/targets/minecraft/client/gui/DeathScreen.h b/targets/minecraft/client/gui/DeathScreen.h index 96e0d6260..a20c9ea55 100644 --- a/targets/minecraft/client/gui/DeathScreen.h +++ b/targets/minecraft/client/gui/DeathScreen.h @@ -6,7 +6,7 @@ public: virtual void init() override; protected: - virtual void keyPressed(char eventCharacter, int eventKey); + virtual void keyPressed(char eventCharacter, int eventKey) override; virtual void buttonClicked(Button* button) override; public: diff --git a/targets/minecraft/client/gui/Font.cpp b/targets/minecraft/client/gui/Font.cpp index c8fef7dc9..904afa844 100644 --- a/targets/minecraft/client/gui/Font.cpp +++ b/targets/minecraft/client/gui/Font.cpp @@ -188,8 +188,8 @@ void Font::draw(const std::string& str, bool dropShadow) { // 4jcraft: this is a check for §. This was easy in UTF-16, since a // single widechar can fit §, but it's encoded as 0xA7 0xC2 in UTF-8, so // we need to check both characters. - if (i + 2 < cleanStr.length() && c == '\xC2' && - (unsigned char)cleanStr[i + 1] == '\xA7') { + if (i + 2 < cleanStr.length() && c == 0xC2u && + (unsigned char)cleanStr[i + 1] == 0xA7u) { // 4J - following block was: // int colorN = // "0123456789abcdefk".indexOf(str.toLowerCase().charAt(i + 1)); diff --git a/targets/minecraft/client/gui/MessageScreen.h b/targets/minecraft/client/gui/MessageScreen.h index 83b3d3383..d04100717 100644 --- a/targets/minecraft/client/gui/MessageScreen.h +++ b/targets/minecraft/client/gui/MessageScreen.h @@ -13,7 +13,7 @@ public: protected: using Screen::keyPressed; - virtual void keyPressed(char eventCharacter, int eventKey); + virtual void keyPressed(char eventCharacter, int eventKey) override; public: virtual void init() override; diff --git a/targets/minecraft/client/gui/achievement/AchievementScreen.h b/targets/minecraft/client/gui/achievement/AchievementScreen.h index 1b4d35934..d2ba38f56 100644 --- a/targets/minecraft/client/gui/achievement/AchievementScreen.h +++ b/targets/minecraft/client/gui/achievement/AchievementScreen.h @@ -49,7 +49,7 @@ public: protected: virtual void buttonClicked(Button* button) override; - virtual void keyPressed(char eventCharacter, int eventKey); + virtual void keyPressed(char eventCharacter, int eventKey) override; public: virtual void render(int mouseX, int mouseY, float a) override; diff --git a/targets/minecraft/client/multiplayer/ClientConnection.cpp b/targets/minecraft/client/multiplayer/ClientConnection.cpp index c52899d53..b98a62d4a 100644 --- a/targets/minecraft/client/multiplayer/ClientConnection.cpp +++ b/targets/minecraft/client/multiplayer/ClientConnection.cpp @@ -2375,7 +2375,7 @@ void ClientConnection::handleTextureChange( #if !defined(_CONTENT_PACKAGE) printf("Skin for remote player %s has changed to %s (%d)\n", player->name.c_str(), player->customTextureUrl.c_str(), - player->getPlayerDefaultSkin()); + static_cast(player->getPlayerDefaultSkin())); #endif break; case TextureChangePacket::e_TextureChange_Cape: @@ -2431,7 +2431,7 @@ void ClientConnection::handleTextureAndGeometryChange( #if !defined(_CONTENT_PACKAGE) printf("Skin for remote player %s has changed to %s (%d)\n", player->name.c_str(), player->customTextureUrl.c_str(), - player->getPlayerDefaultSkin()); + static_cast(player->getPlayerDefaultSkin())); #endif if (!packet->path.empty() && diff --git a/targets/minecraft/client/multiplayer/ConnectScreen.h b/targets/minecraft/client/multiplayer/ConnectScreen.h index 9544d9895..90a4874f2 100644 --- a/targets/minecraft/client/multiplayer/ConnectScreen.h +++ b/targets/minecraft/client/multiplayer/ConnectScreen.h @@ -16,7 +16,7 @@ public: virtual void tick() override; protected: - virtual void keyPressed(char eventCharacter, int eventKey); + virtual void keyPressed(char eventCharacter, int eventKey) override; public: virtual void init() override; diff --git a/targets/minecraft/client/multiplayer/DisconnectedScreen.h b/targets/minecraft/client/multiplayer/DisconnectedScreen.h index 7b0b91ee2..32115e525 100644 --- a/targets/minecraft/client/multiplayer/DisconnectedScreen.h +++ b/targets/minecraft/client/multiplayer/DisconnectedScreen.h @@ -15,7 +15,7 @@ public: protected: using Screen::keyPressed; - virtual void keyPressed(char eventCharacter, int eventKey); + virtual void keyPressed(char eventCharacter, int eventKey) override; public: virtual void init() override; diff --git a/targets/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp b/targets/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp index 0647aaf4f..d1efdaf5b 100644 --- a/targets/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp +++ b/targets/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp @@ -373,7 +373,8 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(std::uint32_t skinId) { LocalPlayer::setCustomSkin(skinId); #if !defined(_CONTENT_PACKAGE) printf("Skin for local player %s has changed to %s (%d)\n", - name.c_str(), customTextureUrl.c_str(), getPlayerDefaultSkin()); + name.c_str(), customTextureUrl.c_str(), + static_cast(getPlayerDefaultSkin())); #endif if (getCustomSkin() != oldSkinIndex) connection->send(std::shared_ptr( diff --git a/targets/minecraft/client/multiplayer/ReceivingLevelScreen.h b/targets/minecraft/client/multiplayer/ReceivingLevelScreen.h index 91d0f13d6..a5eca2bf7 100644 --- a/targets/minecraft/client/multiplayer/ReceivingLevelScreen.h +++ b/targets/minecraft/client/multiplayer/ReceivingLevelScreen.h @@ -13,7 +13,7 @@ public: protected: using Screen::keyPressed; - virtual void keyPressed(char eventCharacter, int eventKey); + virtual void keyPressed(char eventCharacter, int eventKey) override; public: virtual void init() override; diff --git a/targets/minecraft/client/skins/AbstractTexturePack.cpp b/targets/minecraft/client/skins/AbstractTexturePack.cpp index ce0799dc0..b95dee1f0 100644 --- a/targets/minecraft/client/skins/AbstractTexturePack.cpp +++ b/targets/minecraft/client/skins/AbstractTexturePack.cpp @@ -3,6 +3,7 @@ #include "AbstractTexturePack.h" +#include #include #include @@ -222,7 +223,7 @@ std::string AbstractTexturePack::getXuiRootPath() { 256; // Use this to allocate space to hold a ResourceLocator string char szResourceLocator[LOCATOR_SIZE]; - snprintf(szResourceLocator, LOCATOR_SIZE, "section://%X,%s#%s", + snprintf(szResourceLocator, LOCATOR_SIZE, "section://%" PRIxPTR ",%s#%s", c_ModuleHandle, "media", "media/"); return szResourceLocator; } diff --git a/targets/minecraft/client/skins/DLCTexturePack.cpp b/targets/minecraft/client/skins/DLCTexturePack.cpp index 594d0aa69..cee737ec6 100644 --- a/targets/minecraft/client/skins/DLCTexturePack.cpp +++ b/targets/minecraft/client/skins/DLCTexturePack.cpp @@ -2,6 +2,7 @@ #include "minecraft/util/Log.h" #include "DLCTexturePack.h" +#include #include #include #include @@ -451,8 +452,9 @@ std::string DLCTexturePack::getXuiRootPath() { constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string char szResourceLocator[LOCATOR_SIZE]; - snprintf(szResourceLocator, LOCATOR_SIZE, "memory://%08X,%04X#", - pbData, dwSize); + snprintf(szResourceLocator, LOCATOR_SIZE, + "memory://%08" PRIxPTR ",%04X#", + reinterpret_cast(pbData), dwSize); path = szResourceLocator; } return path; diff --git a/targets/minecraft/server/network/PlayerConnection.cpp b/targets/minecraft/server/network/PlayerConnection.cpp index 3b2ca8a31..e149367cf 100644 --- a/targets/minecraft/server/network/PlayerConnection.cpp +++ b/targets/minecraft/server/network/PlayerConnection.cpp @@ -969,7 +969,7 @@ void PlayerConnection::handleTextureChange( #if !defined(_CONTENT_PACKAGE) printf("Skin for server player %s has changed to %s (%d)\n", player->name.c_str(), player->customTextureUrl.c_str(), - player->getPlayerDefaultSkin()); + static_cast(player->getPlayerDefaultSkin())); #endif break; case TextureChangePacket::e_TextureChange_Cape: @@ -1013,7 +1013,7 @@ void PlayerConnection::handleTextureAndGeometryChange( "PlayerConnection::handleTextureAndGeometryChange - Skin for server " "player %s has changed to %s (%d)\n", player->name.c_str(), player->customTextureUrl.c_str(), - player->getPlayerDefaultSkin()); + static_cast(player->getPlayerDefaultSkin())); #endif if (!packet->path.empty() && @@ -1423,7 +1423,7 @@ void PlayerConnection::handlePlayerInfo( gameType) { #if !defined(_CONTENT_PACKAGE) printf("Setting %s to game mode %d\n", - serverPlayer->name.c_str(), gameType); + serverPlayer->name.c_str(), gameType->getId()); #endif serverPlayer->setPlayerGamePrivilege( Player::ePlayerGamePrivilege_CreativeMode, @@ -1438,7 +1438,7 @@ void PlayerConnection::handlePlayerInfo( } else { #if !defined(_CONTENT_PACKAGE) printf("%s already has game mode %d\n", - serverPlayer->name.c_str(), gameType); + serverPlayer->name.c_str(), gameType->getId()); #endif } if (cheats) { diff --git a/targets/minecraft/world/level/Level.cpp b/targets/minecraft/world/level/Level.cpp index 17b0a37f4..ea7f6961d 100644 --- a/targets/minecraft/world/level/Level.cpp +++ b/targets/minecraft/world/level/Level.cpp @@ -2570,7 +2570,7 @@ std::string Level::gatherStats() { char buf[64]; { std::lock_guard lock(m_entitiesCS); - snprintf(buf, 64, "All:%d", entities.size()); + snprintf(buf, 64, "All:%zu", entities.size()); } return std::string(buf); } diff --git a/targets/minecraft/world/level/chunk/SparseDataStorage.cpp b/targets/minecraft/world/level/chunk/SparseDataStorage.cpp index e6dc4fd9a..b3b56e24c 100644 --- a/targets/minecraft/world/level/chunk/SparseDataStorage.cpp +++ b/targets/minecraft/world/level/chunk/SparseDataStorage.cpp @@ -422,15 +422,12 @@ void SparseDataStorage::addNewPlane(int y) { newDataAndCount |= ((int64_t)linesUsed) << 48; - // Attempt to update the data & count atomically. This command will Only - // succeed if the data stored at dataAndCount is equal to - // lastDataAndCount, and will return the value present just before the - // write took place - int64_t lastDataAndCount2 = lastDataAndCount; - std::atomic_ref(dataAndCount).compare_exchange_strong( - lastDataAndCount2, newDataAndCount, std::memory_order_release); - - if (lastDataAndCount2 == lastDataAndCount) { + // Attempt to update the data & count atomically. CAS only + // succeeds if dataAndCount currently equals lastDataAndCount. + int64_t expected = lastDataAndCount; + if (std::atomic_ref(dataAndCount) + .compare_exchange_strong(expected, newDataAndCount, + std::memory_order_release)) { success = true; // Queue old data to be deleted queueForDelete(lastDataPointer); @@ -497,15 +494,12 @@ void SparseDataStorage::updateDataAndCount(int64_t newDataAndCount) { unsigned char* lastDataPointer = (unsigned char*)(lastDataAndCount & 0x0000ffffffffffff); - // Attempt to update the data & count atomically. This command will Only - // succeed if the data stored at dataAndCount is equal to - // lastDataAndCount, and will return the value present just before the - // write took place - int64_t lastDataAndCount2 = lastDataAndCount; - std::atomic_ref(dataAndCount).compare_exchange_strong( - lastDataAndCount2, newDataAndCount, std::memory_order_release); - - if (lastDataAndCount2 == lastDataAndCount) { + // Attempt to update the data & count atomically. CAS only + // succeeds if dataAndCount currently equals lastDataAndCount. + int64_t expected = lastDataAndCount; + if (std::atomic_ref(dataAndCount) + .compare_exchange_strong(expected, newDataAndCount, + std::memory_order_release)) { success = true; // Queue old data to be deleted // printf("Marking for delete 0x%x (full @@ -573,15 +567,12 @@ int SparseDataStorage::compress() { newDataAndCount |= ((int64_t)planesToAlloc) << 48; - // Attempt to update the data & count atomically. This command will Only - // succeed if the data stored at dataAndCount is equal to - // lastDataAndCount, and will return the value present just before the - // write took place - int64_t lastDataAndCount2 = lastDataAndCount; - std::atomic_ref(dataAndCount).compare_exchange_strong( - lastDataAndCount2, newDataAndCount, std::memory_order_release); - - if (lastDataAndCount2 != lastDataAndCount) { + // Attempt to update the data & count atomically. CAS only + // succeeds if dataAndCount currently equals lastDataAndCount. + int64_t expected = lastDataAndCount; + if (!std::atomic_ref(dataAndCount) + .compare_exchange_strong(expected, newDataAndCount, + std::memory_order_release)) { // Failed to write. Don't bother trying again... being very // conservative here. // printf("Marking for delete 0x%x (compress diff --git a/targets/minecraft/world/level/chunk/SparseLightStorage.cpp b/targets/minecraft/world/level/chunk/SparseLightStorage.cpp index 4e4929a6c..5a29b0d52 100644 --- a/targets/minecraft/world/level/chunk/SparseLightStorage.cpp +++ b/targets/minecraft/world/level/chunk/SparseLightStorage.cpp @@ -426,15 +426,12 @@ void SparseLightStorage::addNewPlane(int y) { newDataAndCount |= ((int64_t)linesUsed) << 48; - // Attempt to update the data & count atomically. This command will Only - // succeed if the data stored at dataAndCount is equal to - // lastDataAndCount, and will return the value present just before the - // write took place - int64_t lastDataAndCount2 = lastDataAndCount; - std::atomic_ref(dataAndCount).compare_exchange_strong( - lastDataAndCount2, newDataAndCount, std::memory_order_release); - - if (lastDataAndCount2 == lastDataAndCount) { + // Attempt to update the data & count atomically. CAS only + // succeeds if dataAndCount currently equals lastDataAndCount. + int64_t expected = lastDataAndCount; + if (std::atomic_ref(dataAndCount) + .compare_exchange_strong(expected, newDataAndCount, + std::memory_order_release)) { success = true; // Queue old data to be deleted queueForDelete(lastDataPointer); @@ -501,15 +498,12 @@ void SparseLightStorage::updateDataAndCount(int64_t newDataAndCount) { unsigned char* lastDataPointer = (unsigned char*)(lastDataAndCount & 0x0000ffffffffffff); - // Attempt to update the data & count atomically. This command will Only - // succeed if the data stored at dataAndCount is equal to - // lastDataAndCount, and will return the value present just before the - // write took place - int64_t lastDataAndCount2 = lastDataAndCount; - std::atomic_ref(dataAndCount).compare_exchange_strong( - lastDataAndCount2, newDataAndCount, std::memory_order_release); - - if (lastDataAndCount2 == lastDataAndCount) { + // Attempt to update the data & count atomically. CAS only + // succeeds if dataAndCount currently equals lastDataAndCount. + int64_t expected = lastDataAndCount; + if (std::atomic_ref(dataAndCount) + .compare_exchange_strong(expected, newDataAndCount, + std::memory_order_release)) { success = true; // Queue old data to be deleted // printf("Marking for delete 0x%x (full @@ -584,15 +578,12 @@ int SparseLightStorage::compress() { newDataAndCount |= ((int64_t)planesToAlloc) << 48; - // Attempt to update the data & count atomically. This command will Only - // succeed if the data stored at dataAndCount is equal to - // lastDataAndCount, and will return the value present just before the - // write took place - int64_t lastDataAndCount2 = lastDataAndCount; - std::atomic_ref(dataAndCount).compare_exchange_strong( - lastDataAndCount2, newDataAndCount, std::memory_order_release); - - if (lastDataAndCount2 != lastDataAndCount) { + // Attempt to update the data & count atomically. CAS only + // succeeds if dataAndCount currently equals lastDataAndCount. + int64_t expected = lastDataAndCount; + if (!std::atomic_ref(dataAndCount) + .compare_exchange_strong(expected, newDataAndCount, + std::memory_order_release)) { // Failed to write. Don't bother trying again... being very // conservative here. // printf("Marking for delete 0x%x (compress diff --git a/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp b/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp index 2677f592a..e117afd61 100644 --- a/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp @@ -44,8 +44,7 @@ void SignTileEntity::save(CompoundTag* tag) { #if !defined(_CONTENT_PACKAGE) fprintf(stderr, "### - Saving a sign with text - \n"); for (int i = 0; i < 4; i++) { - fprintf(stderr, m_wsmessages[i].c_str()); - fprintf(stderr, "\n"); + fprintf(stderr, "%s\n", m_wsmessages[i].c_str()); } #endif } @@ -63,8 +62,7 @@ void SignTileEntity::load(CompoundTag* tag) { #if !defined(_CONTENT_PACKAGE) fprintf(stderr, "### - Loaded a sign with text - \n"); for (int i = 0; i < 4; i++) { - fprintf(stderr, m_wsmessages[i].c_str()); - fprintf(stderr, "\n"); + fprintf(stderr, "%s\n", m_wsmessages[i].c_str()); } #endif diff --git a/targets/nbt/include/nbt/ByteArrayTag.h b/targets/nbt/include/nbt/ByteArrayTag.h index d5409c018..58adda56f 100644 --- a/targets/nbt/include/nbt/ByteArrayTag.h +++ b/targets/nbt/include/nbt/ByteArrayTag.h @@ -32,7 +32,7 @@ public: std::string toString() { static char buf[32]; - snprintf(buf, 32, "[%d bytes]", data.size()); + snprintf(buf, 32, "[%zu bytes]", data.size()); return std::string(buf); } diff --git a/targets/nbt/include/nbt/IntArrayTag.h b/targets/nbt/include/nbt/IntArrayTag.h index 7c2525b7e..fd9f940f9 100644 --- a/targets/nbt/include/nbt/IntArrayTag.h +++ b/targets/nbt/include/nbt/IntArrayTag.h @@ -36,7 +36,7 @@ public: std::string toString() { static char buf[32]; - snprintf(buf, 32, "[%d bytes]", data.size()); + snprintf(buf, 32, "[%zu bytes]", data.size()); return std::string(buf); } diff --git a/targets/nbt/include/nbt/LongTag.h b/targets/nbt/include/nbt/LongTag.h index 9af3b75d0..755e845e8 100644 --- a/targets/nbt/include/nbt/LongTag.h +++ b/targets/nbt/include/nbt/LongTag.h @@ -15,7 +15,7 @@ public: uint8_t getId() { return TAG_Long; } std::string toString() { static char buf[32]; - snprintf(buf, 32, "%I64d", data); + snprintf(buf, 32, "%lld", static_cast(data)); return std::string(buf); } diff --git a/targets/platform/PlatformTypes.h b/targets/platform/PlatformTypes.h index 33b74fdbd..4e78dfc2a 100644 --- a/targets/platform/PlatformTypes.h +++ b/targets/platform/PlatformTypes.h @@ -14,7 +14,7 @@ struct ImageFileBuffer { ImageFileBuffer(EImageType type, std::size_t size) : m_type(type), m_pBuffer(size > 0 ? std::make_unique(size) : nullptr), - m_bufferSize(static_cast(size)) {} + m_bufferSize(size) {} // move-only ImageFileBuffer(ImageFileBuffer&&) noexcept = default; @@ -24,7 +24,7 @@ struct ImageFileBuffer { [[nodiscard]] EImageType GetType() const { return m_type; } [[nodiscard]] std::byte* GetBufferPointer() const { return m_pBuffer.get(); } - [[nodiscard]] int GetBufferSize() const { return m_bufferSize; } + [[nodiscard]] std::size_t GetBufferSize() const { return m_bufferSize; } [[nodiscard]] bool Allocated() const { return m_pBuffer != nullptr; } void Release() { m_pBuffer.reset(); @@ -33,7 +33,7 @@ struct ImageFileBuffer { EImageType m_type{e_typePNG}; std::unique_ptr m_pBuffer; - int m_bufferSize = 0; + std::size_t m_bufferSize = 0; }; struct D3DXIMAGE_INFO { diff --git a/targets/platform/renderer/gl/GLRenderer.cpp b/targets/platform/renderer/gl/GLRenderer.cpp index 46066d25c..96b5474da 100644 --- a/targets/platform/renderer/gl/GLRenderer.cpp +++ b/targets/platform/renderer/gl/GLRenderer.cpp @@ -1563,7 +1563,8 @@ void glCallLists_4J(IntBuffer* lists) { if (!lists) return; int count = lists->limit() - lists->position(); int* ids = getIntPtr(lists); - for (int i = 0; i < count; i++) PlatformRenderer.CBuffCall(ids[i], false); + for (int i = 0; i < count; i++) + (void)PlatformRenderer.CBuffCall(ids[i], false); } void glReadPixels_4J(int x, int y, int w, int h, int f, int t, ByteBuffer* p) { diff --git a/targets/platform/renderer/gl/gl_compat.h b/targets/platform/renderer/gl/gl_compat.h index 0e00d55a1..f7c84e535 100644 --- a/targets/platform/renderer/gl/gl_compat.h +++ b/targets/platform/renderer/gl/gl_compat.h @@ -264,7 +264,11 @@ #undef glEndList #define glEndList() PlatformRenderer.CBuffEnd() #undef glCallList -#define glCallList(_list) PlatformRenderer.CBuffCall(_list) +// CBuffCall is [[nodiscard]] because it can fail (chunk not ready), but +// legacy display list call sites treat it as fire-and-forget rendering - +// a missed call just means nothing draws this frame, which is what the +// old GL display list semantics already gave them. +#define glCallList(_list) ((void)PlatformRenderer.CBuffCall(_list)) // glGenLists / glDeleteLists, lists are not supported in core!!!!! #undef glGenLists